From b04996924d055dffe49297a28d106f827f57b29a Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Wed, 14 Feb 2024 06:41:58 +0000 Subject: [PATCH] Bug 1037100 - Scoped.h removed because no outstanding uses. r=glandium,dom-storage-reviewers,jesup,janv Differential Revision: https://phabricator.services.mozilla.com/D201763 --- dom/canvas/WebGLTexture.cpp | 1 - dom/canvas/WebGLTextureUpload.cpp | 1 - dom/indexedDB/ActorsParent.cpp | 1 - .../webrtc/MediaEngineRemoteVideoSource.h | 1 - dom/media/webrtc/common/MediaEngineWrapper.h | 32 --- dom/media/webrtc/libwebrtcglue/AudioConduit.h | 1 - dom/media/webrtc/libwebrtcglue/VideoConduit.h | 1 - gfx/2d/DrawTargetCairo.cpp | 5 - mfbt/Scoped.h | 225 ------------------ mfbt/moz.build | 1 - .../ThreadStackHelper.cpp | 1 - xpcom/build/LateWriteChecks.cpp | 1 - 12 files changed, 271 deletions(-) delete mode 100644 dom/media/webrtc/common/MediaEngineWrapper.h delete mode 100644 mfbt/Scoped.h diff --git a/dom/canvas/WebGLTexture.cpp b/dom/canvas/WebGLTexture.cpp index 7b50e85ed3a6..db8906f7f508 100644 --- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -12,7 +12,6 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/IntegerRange.h" #include "mozilla/MathAlgorithms.h" -#include "mozilla/Scoped.h" #include "mozilla/ScopeExit.h" #include "mozilla/Unused.h" #include "ScopedGLHelpers.h" diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp index d2d13edfa3e7..6686c3417883 100644 --- a/dom/canvas/WebGLTextureUpload.cpp +++ b/dom/canvas/WebGLTextureUpload.cpp @@ -22,7 +22,6 @@ #include "mozilla/dom/ImageData.h" #include "mozilla/dom/OffscreenCanvas.h" #include "mozilla/MathAlgorithms.h" -#include "mozilla/Scoped.h" #include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs_webgl.h" #include "mozilla/Unused.h" diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 7b48f8f7c6f1..bc0baf115727 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -82,7 +82,6 @@ #include "mozilla/Result.h" #include "mozilla/ResultExtensions.h" #include "mozilla/SchedulerGroup.h" -#include "mozilla/Scoped.h" #include "mozilla/SnappyCompressOutputStream.h" #include "mozilla/SpinEventLoopUntil.h" #include "mozilla/StaticPtr.h" diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.h b/dom/media/webrtc/MediaEngineRemoteVideoSource.h index 7e4f852701aa..e88671b3129f 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.h +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.h @@ -25,7 +25,6 @@ #include "AudioSegment.h" #include "MediaTrackGraph.h" -#include "MediaEngineWrapper.h" #include "mozilla/dom/MediaStreamTrackBinding.h" // Camera Access via IPC diff --git a/dom/media/webrtc/common/MediaEngineWrapper.h b/dom/media/webrtc/common/MediaEngineWrapper.h deleted file mode 100644 index ba48ad57d8c9..000000000000 --- a/dom/media/webrtc/common/MediaEngineWrapper.h +++ /dev/null @@ -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 - -namespace mozilla { -/** - * A Custom scoped template to release a resoure of Type T - * with a function of Type F - * ScopedCustomReleasePtr ptr = - * webrtc::VoENetwork->GetInterface(voiceEngine); - * - */ -template -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 diff --git a/dom/media/webrtc/libwebrtcglue/AudioConduit.h b/dom/media/webrtc/libwebrtcglue/AudioConduit.h index 8e736d14dda1..64bf5a59ec2b 100644 --- a/dom/media/webrtc/libwebrtcglue/AudioConduit.h +++ b/dom/media/webrtc/libwebrtcglue/AudioConduit.h @@ -12,7 +12,6 @@ #include "mozilla/TimeStamp.h" #include "MediaConduitInterface.h" -#include "common/MediaEngineWrapper.h" /** * This file hosts several structures identifying different aspects of a RTP diff --git a/dom/media/webrtc/libwebrtcglue/VideoConduit.h b/dom/media/webrtc/libwebrtcglue/VideoConduit.h index 4ca33cc2a626..bb15cd35a9b1 100644 --- a/dom/media/webrtc/libwebrtcglue/VideoConduit.h +++ b/dom/media/webrtc/libwebrtcglue/VideoConduit.h @@ -15,7 +15,6 @@ #include "nsITimer.h" #include "MediaConduitInterface.h" -#include "common/MediaEngineWrapper.h" #include "RtpRtcpConfig.h" #include "RunningStat.h" #include "transport/runnable_utils.h" diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 8f0f3bc094f7..e189fe24455f 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -11,7 +11,6 @@ #include "HelpersCairo.h" #include "BorrowedContext.h" #include "FilterNodeSoftware.h" -#include "mozilla/Scoped.h" #include "mozilla/UniquePtr.h" #include "mozilla/Vector.h" #include "mozilla/StaticPrefs_gfx.h" @@ -50,10 +49,6 @@ #define CAIRO_COORD_MAX (Float(0x7fffff)) namespace mozilla { - -MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCairoSurface, cairo_surface_t, - cairo_surface_destroy); - namespace gfx { cairo_surface_t* DrawTargetCairo::mDummySurface; diff --git a/mfbt/Scoped.h b/mfbt/Scoped.h deleted file mode 100644 index 94a8890e1e2c..000000000000 --- a/mfbt/Scoped.h +++ /dev/null @@ -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 - -#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 -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 \ - struct MOZ_NON_TEMPORARY_CLASS name \ - : public mozilla::Scoped > { \ - typedef mozilla::Scoped > 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 name; - -template -void TypeSpecificDelete(T* aValue); - -template -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 */ diff --git a/mfbt/moz.build b/mfbt/moz.build index 1571473bfd12..3a3ab46f7142 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -97,7 +97,6 @@ EXPORTS.mozilla = [ "ReverseIterator.h", "RollingMean.h", "Saturate.h", - "Scoped.h", "ScopeExit.h", "SegmentedVector.h", "SHA1.h", diff --git a/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp b/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp index 501317c746bb..c43a322fd49f 100644 --- a/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp +++ b/toolkit/components/backgroundhangmonitor/ThreadStackHelper.cpp @@ -22,7 +22,6 @@ #include "mozilla/HangTypes.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/MemoryChecking.h" -#include "mozilla/Scoped.h" #include "mozilla/Sprintf.h" #include "mozilla/UniquePtr.h" #include "nsThread.h" diff --git a/xpcom/build/LateWriteChecks.cpp b/xpcom/build/LateWriteChecks.cpp index e3bf73d73cac..515b484aef3b 100644 --- a/xpcom/build/LateWriteChecks.cpp +++ b/xpcom/build/LateWriteChecks.cpp @@ -10,7 +10,6 @@ #include "mozilla/PoisonIOInterposer.h" #include "mozilla/ProcessedStack.h" #include "mozilla/SHA1.h" -#include "mozilla/Scoped.h" #include "mozilla/StaticPtr.h" #include "mozilla/Telemetry.h" #include "mozilla/Unused.h"