forked from mirrors/gecko-dev
Bug 1037100 - Scoped.h removed because no outstanding uses. r=glandium,dom-storage-reviewers,jesup,janv
Differential Revision: https://phabricator.services.mozilla.com/D201763
This commit is contained in:
parent
19c9e7fca2
commit
b04996924d
12 changed files with 0 additions and 271 deletions
|
|
@ -12,7 +12,6 @@
|
||||||
#include "mozilla/gfx/Logging.h"
|
#include "mozilla/gfx/Logging.h"
|
||||||
#include "mozilla/IntegerRange.h"
|
#include "mozilla/IntegerRange.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/ScopeExit.h"
|
#include "mozilla/ScopeExit.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "ScopedGLHelpers.h"
|
#include "ScopedGLHelpers.h"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include "mozilla/dom/ImageData.h"
|
#include "mozilla/dom/ImageData.h"
|
||||||
#include "mozilla/dom/OffscreenCanvas.h"
|
#include "mozilla/dom/OffscreenCanvas.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/ScopeExit.h"
|
#include "mozilla/ScopeExit.h"
|
||||||
#include "mozilla/StaticPrefs_webgl.h"
|
#include "mozilla/StaticPrefs_webgl.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@
|
||||||
#include "mozilla/Result.h"
|
#include "mozilla/Result.h"
|
||||||
#include "mozilla/ResultExtensions.h"
|
#include "mozilla/ResultExtensions.h"
|
||||||
#include "mozilla/SchedulerGroup.h"
|
#include "mozilla/SchedulerGroup.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/SnappyCompressOutputStream.h"
|
#include "mozilla/SnappyCompressOutputStream.h"
|
||||||
#include "mozilla/SpinEventLoopUntil.h"
|
#include "mozilla/SpinEventLoopUntil.h"
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "AudioSegment.h"
|
#include "AudioSegment.h"
|
||||||
#include "MediaTrackGraph.h"
|
#include "MediaTrackGraph.h"
|
||||||
|
|
||||||
#include "MediaEngineWrapper.h"
|
|
||||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||||
|
|
||||||
// Camera Access via IPC
|
// Camera Access via IPC
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#ifndef MEDIA_ENGINE_WRAPPER_H_
|
|
||||||
#define MEDIA_ENGINE_WRAPPER_H_
|
|
||||||
|
|
||||||
#include <mozilla/Scoped.h>
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
/**
|
|
||||||
* A Custom scoped template to release a resoure of Type T
|
|
||||||
* with a function of Type F
|
|
||||||
* ScopedCustomReleasePtr<webrtc::VoENetwork> ptr =
|
|
||||||
* webrtc::VoENetwork->GetInterface(voiceEngine);
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
struct ScopedCustomReleaseTraits0 {
|
|
||||||
typedef T* type;
|
|
||||||
static T* empty() { return nullptr; }
|
|
||||||
static void release(T* ptr) {
|
|
||||||
if (ptr) {
|
|
||||||
(ptr)->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SCOPED_TEMPLATE(ScopedCustomReleasePtr, ScopedCustomReleaseTraits0)
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
|
|
||||||
#include "MediaConduitInterface.h"
|
#include "MediaConduitInterface.h"
|
||||||
#include "common/MediaEngineWrapper.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file hosts several structures identifying different aspects of a RTP
|
* This file hosts several structures identifying different aspects of a RTP
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
|
|
||||||
#include "MediaConduitInterface.h"
|
#include "MediaConduitInterface.h"
|
||||||
#include "common/MediaEngineWrapper.h"
|
|
||||||
#include "RtpRtcpConfig.h"
|
#include "RtpRtcpConfig.h"
|
||||||
#include "RunningStat.h"
|
#include "RunningStat.h"
|
||||||
#include "transport/runnable_utils.h"
|
#include "transport/runnable_utils.h"
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#include "HelpersCairo.h"
|
#include "HelpersCairo.h"
|
||||||
#include "BorrowedContext.h"
|
#include "BorrowedContext.h"
|
||||||
#include "FilterNodeSoftware.h"
|
#include "FilterNodeSoftware.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/Vector.h"
|
#include "mozilla/Vector.h"
|
||||||
#include "mozilla/StaticPrefs_gfx.h"
|
#include "mozilla/StaticPrefs_gfx.h"
|
||||||
|
|
@ -50,10 +49,6 @@
|
||||||
#define CAIRO_COORD_MAX (Float(0x7fffff))
|
#define CAIRO_COORD_MAX (Float(0x7fffff))
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCairoSurface, cairo_surface_t,
|
|
||||||
cairo_surface_destroy);
|
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
|
|
||||||
cairo_surface_t* DrawTargetCairo::mDummySurface;
|
cairo_surface_t* DrawTargetCairo::mDummySurface;
|
||||||
|
|
|
||||||
225
mfbt/Scoped.h
225
mfbt/Scoped.h
|
|
@ -1,225 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
/* DEPRECATED: Use UniquePtr.h instead. */
|
|
||||||
|
|
||||||
#ifndef mozilla_Scoped_h
|
|
||||||
#define mozilla_Scoped_h
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DEPRECATED: Use UniquePtr.h instead.
|
|
||||||
*
|
|
||||||
* Resource Acquisition Is Initialization is a programming idiom used
|
|
||||||
* to write robust code that is able to deallocate resources properly,
|
|
||||||
* even in presence of execution errors or exceptions that need to be
|
|
||||||
* propagated. The Scoped* classes defined via the |SCOPED_TEMPLATE|
|
|
||||||
* and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLTE| macros perform the
|
|
||||||
* deallocation of the resource they hold once program execution
|
|
||||||
* reaches the end of the scope for which they have been defined.
|
|
||||||
* These macros have been used to automatically close file
|
|
||||||
* descriptors/file handles when reaching the end of the scope,
|
|
||||||
* graphics contexts, etc.
|
|
||||||
*
|
|
||||||
* The general scenario for RAII classes created by the above macros
|
|
||||||
* is the following:
|
|
||||||
*
|
|
||||||
* ScopedClass foo(create_value());
|
|
||||||
* // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()|
|
|
||||||
* to access the value.
|
|
||||||
* // ... In case of |return| or |throw|, |foo| is deallocated automatically.
|
|
||||||
* // ... If |foo| needs to be returned or stored, use |foo.forget()|
|
|
||||||
*
|
|
||||||
* Note that the RAII classes defined in this header do _not_ perform any form
|
|
||||||
* of reference-counting or garbage-collection. These classes have exactly two
|
|
||||||
* behaviors:
|
|
||||||
*
|
|
||||||
* - if |forget()| has not been called, the resource is always deallocated at
|
|
||||||
* the end of the scope;
|
|
||||||
* - if |forget()| has been called, any control on the resource is unbound
|
|
||||||
* and the resource is not deallocated by the class.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
|
||||||
#include "mozilla/Attributes.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Scoped is a helper to create RAII wrappers
|
|
||||||
* Type argument |Traits| is expected to have the following structure:
|
|
||||||
*
|
|
||||||
* struct Traits
|
|
||||||
* {
|
|
||||||
* // Define the type of the value stored in the wrapper
|
|
||||||
* typedef value_type type;
|
|
||||||
* // Returns the value corresponding to the uninitialized or freed state
|
|
||||||
* const static type empty();
|
|
||||||
* // Release resources corresponding to the wrapped value
|
|
||||||
* // This function is responsible for not releasing an |empty| value
|
|
||||||
* const static void release(type);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
template <typename Traits>
|
|
||||||
class MOZ_NON_TEMPORARY_CLASS Scoped {
|
|
||||||
public:
|
|
||||||
typedef typename Traits::type Resource;
|
|
||||||
|
|
||||||
explicit Scoped() : mValue(Traits::empty()) {}
|
|
||||||
|
|
||||||
explicit Scoped(const Resource& aValue) : mValue(aValue) {}
|
|
||||||
|
|
||||||
/* Move constructor. */
|
|
||||||
Scoped(Scoped&& aOther) : mValue(std::move(aOther.mValue)) {
|
|
||||||
aOther.mValue = Traits::empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Scoped() { Traits::release(mValue); }
|
|
||||||
|
|
||||||
// Constant getter
|
|
||||||
operator const Resource&() const { return mValue; }
|
|
||||||
const Resource& operator->() const { return mValue; }
|
|
||||||
const Resource& get() const { return mValue; }
|
|
||||||
// Non-constant getter.
|
|
||||||
Resource& rwget() { return mValue; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Forget the resource.
|
|
||||||
*
|
|
||||||
* Once |forget| has been called, the |Scoped| is neutralized, i.e. it will
|
|
||||||
* have no effect at destruction (unless it is reset to another resource by
|
|
||||||
* |operator=|).
|
|
||||||
*
|
|
||||||
* @return The original resource.
|
|
||||||
*/
|
|
||||||
Resource forget() {
|
|
||||||
Resource tmp = mValue;
|
|
||||||
mValue = Traits::empty();
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Perform immediate clean-up of this |Scoped|.
|
|
||||||
*
|
|
||||||
* If this |Scoped| is currently empty, this method has no effect.
|
|
||||||
*/
|
|
||||||
void dispose() {
|
|
||||||
Traits::release(mValue);
|
|
||||||
mValue = Traits::empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Resource& aOther) const { return mValue == aOther; }
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Replace the resource with another resource.
|
|
||||||
*
|
|
||||||
* Calling |operator=| has the side-effect of triggering clean-up. If you do
|
|
||||||
* not want to trigger clean-up, you should first invoke |forget|.
|
|
||||||
*
|
|
||||||
* @return this
|
|
||||||
*/
|
|
||||||
Scoped& operator=(const Resource& aOther) { return reset(aOther); }
|
|
||||||
|
|
||||||
Scoped& reset(const Resource& aOther) {
|
|
||||||
Traits::release(mValue);
|
|
||||||
mValue = aOther;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Move assignment operator. */
|
|
||||||
Scoped& operator=(Scoped&& aRhs) {
|
|
||||||
MOZ_ASSERT(&aRhs != this, "self-move-assignment not allowed");
|
|
||||||
this->~Scoped();
|
|
||||||
new (this) Scoped(std::move(aRhs));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
explicit Scoped(const Scoped& aValue) = delete;
|
|
||||||
Scoped& operator=(const Scoped& aValue) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Resource mValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SCOPED_TEMPLATE defines a templated class derived from Scoped
|
|
||||||
* This allows to implement templates such as ScopedFreePtr.
|
|
||||||
*
|
|
||||||
* @param name The name of the class to define.
|
|
||||||
* @param Traits A struct implementing clean-up. See the implementations
|
|
||||||
* for more details.
|
|
||||||
*/
|
|
||||||
#define SCOPED_TEMPLATE(name, Traits) \
|
|
||||||
template <typename Type> \
|
|
||||||
struct MOZ_NON_TEMPORARY_CLASS name \
|
|
||||||
: public mozilla::Scoped<Traits<Type> > { \
|
|
||||||
typedef mozilla::Scoped<Traits<Type> > Super; \
|
|
||||||
typedef typename Super::Resource Resource; \
|
|
||||||
name& operator=(Resource aRhs) { \
|
|
||||||
Super::operator=(aRhs); \
|
|
||||||
return *this; \
|
|
||||||
} \
|
|
||||||
name& operator=(name&& aRhs) = default; \
|
|
||||||
\
|
|
||||||
explicit name() : Super() {} \
|
|
||||||
explicit name(Resource aRhs) : Super(aRhs) {} \
|
|
||||||
name(name&& aRhs) : Super(std::move(aRhs)) {} \
|
|
||||||
\
|
|
||||||
private: \
|
|
||||||
explicit name(const name&) = delete; \
|
|
||||||
name& operator=(const name&) = delete; \
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped
|
|
||||||
* pointers for types with custom deleters; just overload
|
|
||||||
* TypeSpecificDelete(T*) in the same namespace as T to call the deleter for
|
|
||||||
* type T.
|
|
||||||
*
|
|
||||||
* @param name The name of the class to define.
|
|
||||||
* @param Type A struct implementing clean-up. See the implementations
|
|
||||||
* for more details.
|
|
||||||
* *param Deleter The function that is used to delete/destroy/free a
|
|
||||||
* non-null value of Type*.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, \
|
|
||||||
* PR_Close)
|
|
||||||
* ...
|
|
||||||
* {
|
|
||||||
* ScopedPRFileDesc file(PR_OpenFile(...));
|
|
||||||
* ...
|
|
||||||
* } // file is closed with PR_Close here
|
|
||||||
*/
|
|
||||||
#define MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \
|
|
||||||
template <> \
|
|
||||||
inline void TypeSpecificDelete(Type* aValue) { \
|
|
||||||
Deleter(aValue); \
|
|
||||||
} \
|
|
||||||
typedef ::mozilla::TypeSpecificScopedPointer<Type> name;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void TypeSpecificDelete(T* aValue);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct TypeSpecificScopedPointerTraits {
|
|
||||||
typedef T* type;
|
|
||||||
static type empty() { return nullptr; }
|
|
||||||
static void release(type aValue) {
|
|
||||||
if (aValue) {
|
|
||||||
TypeSpecificDelete(aValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits)
|
|
||||||
|
|
||||||
} /* namespace mozilla */
|
|
||||||
|
|
||||||
#endif /* mozilla_Scoped_h */
|
|
||||||
|
|
@ -97,7 +97,6 @@ EXPORTS.mozilla = [
|
||||||
"ReverseIterator.h",
|
"ReverseIterator.h",
|
||||||
"RollingMean.h",
|
"RollingMean.h",
|
||||||
"Saturate.h",
|
"Saturate.h",
|
||||||
"Scoped.h",
|
|
||||||
"ScopeExit.h",
|
"ScopeExit.h",
|
||||||
"SegmentedVector.h",
|
"SegmentedVector.h",
|
||||||
"SHA1.h",
|
"SHA1.h",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include "mozilla/HangTypes.h"
|
#include "mozilla/HangTypes.h"
|
||||||
#include "mozilla/IntegerPrintfMacros.h"
|
#include "mozilla/IntegerPrintfMacros.h"
|
||||||
#include "mozilla/MemoryChecking.h"
|
#include "mozilla/MemoryChecking.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/Sprintf.h"
|
#include "mozilla/Sprintf.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "nsThread.h"
|
#include "nsThread.h"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include "mozilla/PoisonIOInterposer.h"
|
#include "mozilla/PoisonIOInterposer.h"
|
||||||
#include "mozilla/ProcessedStack.h"
|
#include "mozilla/ProcessedStack.h"
|
||||||
#include "mozilla/SHA1.h"
|
#include "mozilla/SHA1.h"
|
||||||
#include "mozilla/Scoped.h"
|
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue