Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato

Differential Revision: https://phabricator.services.mozilla.com/D152575
This commit is contained in:
Fabrice Desré
2022-08-03 16:39:41 +00:00
parent 330df58cc8
commit e29be44cb7
202 changed files with 1520 additions and 1445 deletions

View File

@@ -37,7 +37,7 @@ class ObservedDocShell : public MarkersStorage {
// Off the main thread only. // Off the main thread only.
Mutex mLock; Mutex mLock;
nsTArray<UniquePtr<AbstractTimelineMarker>> mOffTheMainThreadTimelineMarkers nsTArray<UniquePtr<AbstractTimelineMarker>> mOffTheMainThreadTimelineMarkers
GUARDED_BY(mLock); MOZ_GUARDED_BY(mLock);
public: public:
explicit ObservedDocShell(nsIDocShell* aDocShell); explicit ObservedDocShell(nsIDocShell* aDocShell);

View File

@@ -101,11 +101,11 @@ class TimelineConsumers {
private: private:
static StaticMutex sMutex; static StaticMutex sMutex;
static LinkedList<MarkersStorage>& MarkersStores() REQUIRES(sMutex); static LinkedList<MarkersStorage>& MarkersStores() MOZ_REQUIRES(sMutex);
static uint32_t sActiveConsumers GUARDED_BY(sMutex); static uint32_t sActiveConsumers MOZ_GUARDED_BY(sMutex);
static StaticAutoPtr<LinkedList<MarkersStorage>> sMarkersStores static StaticAutoPtr<LinkedList<MarkersStorage>> sMarkersStores
GUARDED_BY(sMutex); MOZ_GUARDED_BY(sMutex);
}; };
} // namespace mozilla } // namespace mozilla

View File

@@ -428,7 +428,7 @@ void BodyStream::EnqueueChunkWithSizeIntoStream(JSContext* aCx,
// thread-safety doesn't handle emplace well // thread-safety doesn't handle emplace well
NS_IMETHODIMP NS_IMETHODIMP
BodyStream::OnInputStreamReady(nsIAsyncInputStream* aStream) BodyStream::OnInputStreamReady(nsIAsyncInputStream* aStream)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
AssertIsOnOwningThread(); AssertIsOnOwningThread();
MOZ_DIAGNOSTIC_ASSERT(aStream); MOZ_DIAGNOSTIC_ASSERT(aStream);
mAsyncWaitWorkerRef = nullptr; mAsyncWaitWorkerRef = nullptr;

View File

@@ -141,17 +141,18 @@ class BodyStream final : public nsIInputStreamCallback,
void ErrorPropagation(JSContext* aCx, void ErrorPropagation(JSContext* aCx,
const MutexSingleWriterAutoLock& aProofOfLock, const MutexSingleWriterAutoLock& aProofOfLock,
ReadableStream* aStream, nsresult aRv) REQUIRES(mMutex); ReadableStream* aStream, nsresult aRv)
MOZ_REQUIRES(mMutex);
// TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605) // TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605)
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects( MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects(
JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock, JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock,
ReadableStream* aStream) REQUIRES(mMutex); ReadableStream* aStream) MOZ_REQUIRES(mMutex);
class WorkerShutdown; class WorkerShutdown;
void ReleaseObjects(const MutexSingleWriterAutoLock& aProofOfLock) void ReleaseObjects(const MutexSingleWriterAutoLock& aProofOfLock)
REQUIRES(mMutex); MOZ_REQUIRES(mMutex);
void ReleaseObjects(); void ReleaseObjects();
@@ -186,12 +187,12 @@ class BodyStream final : public nsIInputStreamCallback,
MutexSingleWriter mMutex; MutexSingleWriter mMutex;
// Protected by mutex. // Protected by mutex.
State mState GUARDED_BY(mMutex); // all writes are from the owning thread State mState MOZ_GUARDED_BY(mMutex); // all writes are from the owning thread
// mGlobal is set on creation, and isn't modified off the owning thread. // mGlobal is set on creation, and isn't modified off the owning thread.
// It isn't set to nullptr until ReleaseObjects() runs. // It isn't set to nullptr until ReleaseObjects() runs.
nsCOMPtr<nsIGlobalObject> mGlobal; nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<BodyStreamHolder> mStreamHolder GUARDED_BY(mMutex); RefPtr<BodyStreamHolder> mStreamHolder MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsIEventTarget> mOwningEventTarget; nsCOMPtr<nsIEventTarget> mOwningEventTarget;
// This is the original inputStream received during the CTOR. It will be // This is the original inputStream received during the CTOR. It will be

View File

@@ -272,7 +272,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
~LruPosition() { Reset(); } ~LruPosition() { Reset(); }
}; };
mutable LruPosition mLruPosition GUARDED_BY(sLruMutex); mutable LruPosition mLruPosition MOZ_GUARDED_BY(sLruMutex);
void BumpLruLocked(const StaticMutexAutoLock& aProofOfLock); void BumpLruLocked(const StaticMutexAutoLock& aProofOfLock);
@@ -740,7 +740,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
private: private:
static StaticMutex sLruMutex; static StaticMutex sLruMutex;
static std::list<WebGLContext*> sLru GUARDED_BY(sLruMutex); static std::list<WebGLContext*> sLru MOZ_GUARDED_BY(sLruMutex);
// State tracking slots // State tracking slots
bool mDitherEnabled = true; bool mDitherEnabled = true;

View File

@@ -81,7 +81,7 @@ class ConsoleReportCollector final : public nsIConsoleReportCollector {
Mutex mMutex; Mutex mMutex;
// protected by mMutex // protected by mMutex
nsTArray<PendingReport> mPendingReports GUARDED_BY(mMutex); nsTArray<PendingReport> mPendingReports MOZ_GUARDED_BY(mMutex);
public: public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS

View File

@@ -66,12 +66,12 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
~RemoteLazyInputStream(); ~RemoteLazyInputStream();
void StreamNeeded() REQUIRES(mMutex); void StreamNeeded() MOZ_REQUIRES(mMutex);
// Upon receiving the stream from our actor, we will not wrap it into an async // Upon receiving the stream from our actor, we will not wrap it into an async
// stream until needed. This allows callers to get access to the underlying // stream until needed. This allows callers to get access to the underlying
// potentially-sync stream using `TakeInternalStream` before reading. // potentially-sync stream using `TakeInternalStream` before reading.
nsresult EnsureAsyncRemoteStream() REQUIRES(mMutex); nsresult EnsureAsyncRemoteStream() MOZ_REQUIRES(mMutex);
// Note that data has been read from our input stream, and disconnect from our // Note that data has been read from our input stream, and disconnect from our
// remote actor. // remote actor.
@@ -82,7 +82,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
IPC::MessageReader* aReader); IPC::MessageReader* aReader);
// Helper method to generate a description of a stream for use in loggging. // Helper method to generate a description of a stream for use in loggging.
nsCString Describe() REQUIRES(mMutex); nsCString Describe() MOZ_REQUIRES(mMutex);
// Start and length of the slice to apply on this RemoteLazyInputStream when // Start and length of the slice to apply on this RemoteLazyInputStream when
// fetching the underlying stream with `SendStreamNeeded`. // fetching the underlying stream with `SendStreamNeeded`.
@@ -112,7 +112,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
// mInnerStream is released and any method will return // mInnerStream is released and any method will return
// NS_BASE_STREAM_CLOSED. // NS_BASE_STREAM_CLOSED.
eClosed, eClosed,
} mState GUARDED_BY(mMutex) = eClosed; } mState MOZ_GUARDED_BY(mMutex) = eClosed;
// The actor which will be used to provide the underlying stream or length // The actor which will be used to provide the underlying stream or length
// information when needed, as well as to efficiently allow transferring the // information when needed, as well as to efficiently allow transferring the
@@ -121,22 +121,25 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
// The connection to our actor will be cleared once the stream has been closed // The connection to our actor will be cleared once the stream has been closed
// or has started reading, at which point this stream will be serialized and // or has started reading, at which point this stream will be serialized and
// cloned as-if it was the underlying stream. // cloned as-if it was the underlying stream.
RefPtr<RemoteLazyInputStreamChild> mActor GUARDED_BY(mMutex); RefPtr<RemoteLazyInputStreamChild> mActor MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsIInputStream> mInnerStream GUARDED_BY(mMutex); nsCOMPtr<nsIInputStream> mInnerStream MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsIAsyncInputStream> mAsyncInnerStream GUARDED_BY(mMutex); nsCOMPtr<nsIAsyncInputStream> mAsyncInnerStream MOZ_GUARDED_BY(mMutex);
// These 2 values are set only if mState is ePending or eRunning. // These 2 values are set only if mState is ePending or eRunning.
// RefPtr is used instead of nsCOMPtr to avoid invoking QueryInterface when // RefPtr is used instead of nsCOMPtr to avoid invoking QueryInterface when
// assigning in debug builds, as `mInputStreamCallback` may not be threadsafe. // assigning in debug builds, as `mInputStreamCallback` may not be threadsafe.
RefPtr<nsIInputStreamCallback> mInputStreamCallback GUARDED_BY(mMutex); RefPtr<nsIInputStreamCallback> mInputStreamCallback MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsIEventTarget> mInputStreamCallbackEventTarget GUARDED_BY(mMutex); nsCOMPtr<nsIEventTarget> mInputStreamCallbackEventTarget
uint32_t mInputStreamCallbackFlags GUARDED_BY(mMutex) = 0; MOZ_GUARDED_BY(mMutex);
uint32_t mInputStreamCallbackRequestedCount GUARDED_BY(mMutex) = 0; uint32_t mInputStreamCallbackFlags MOZ_GUARDED_BY(mMutex) = 0;
uint32_t mInputStreamCallbackRequestedCount MOZ_GUARDED_BY(mMutex) = 0;
// These 2 values are set only if mState is ePending. // These 2 values are set only if mState is ePending.
nsCOMPtr<nsIFileMetadataCallback> mFileMetadataCallback GUARDED_BY(mMutex); nsCOMPtr<nsIFileMetadataCallback> mFileMetadataCallback
nsCOMPtr<nsIEventTarget> mFileMetadataCallbackEventTarget GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsIEventTarget> mFileMetadataCallbackEventTarget
MOZ_GUARDED_BY(mMutex);
}; };
} // namespace mozilla } // namespace mozilla

View File

@@ -156,21 +156,22 @@ class HangMonitorChild : public PProcessHangMonitorChild,
bool mSentReport; bool mSentReport;
// These fields must be accessed with mMonitor held. // These fields must be accessed with mMonitor held.
bool mTerminateScript GUARDED_BY(mMonitor); bool mTerminateScript MOZ_GUARDED_BY(mMonitor);
bool mStartDebugger GUARDED_BY(mMonitor); bool mStartDebugger MOZ_GUARDED_BY(mMonitor);
bool mFinishedStartingDebugger GUARDED_BY(mMonitor); bool mFinishedStartingDebugger MOZ_GUARDED_BY(mMonitor);
bool mPaintWhileInterruptingJS GUARDED_BY(mMonitor); bool mPaintWhileInterruptingJS MOZ_GUARDED_BY(mMonitor);
TabId mPaintWhileInterruptingJSTab GUARDED_BY(mMonitor); TabId mPaintWhileInterruptingJSTab MOZ_GUARDED_BY(mMonitor);
MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch
GUARDED_BY(mMonitor); MOZ_GUARDED_BY(mMonitor);
bool mCancelContentJS GUARDED_BY(mMonitor); bool mCancelContentJS MOZ_GUARDED_BY(mMonitor);
TabId mCancelContentJSTab GUARDED_BY(mMonitor); TabId mCancelContentJSTab MOZ_GUARDED_BY(mMonitor);
nsIRemoteTab::NavigationType mCancelContentJSNavigationType nsIRemoteTab::NavigationType mCancelContentJSNavigationType
GUARDED_BY(mMonitor); MOZ_GUARDED_BY(mMonitor);
int32_t mCancelContentJSNavigationIndex GUARDED_BY(mMonitor); int32_t mCancelContentJSNavigationIndex MOZ_GUARDED_BY(mMonitor);
mozilla::Maybe<nsCString> mCancelContentJSNavigationURI GUARDED_BY(mMonitor); mozilla::Maybe<nsCString> mCancelContentJSNavigationURI
int32_t mCancelContentJSEpoch GUARDED_BY(mMonitor); MOZ_GUARDED_BY(mMonitor);
bool mShutdownDone GUARDED_BY(mMonitor); int32_t mCancelContentJSEpoch MOZ_GUARDED_BY(mMonitor);
bool mShutdownDone MOZ_GUARDED_BY(mMonitor);
JSContext* mContext; // const after constructor JSContext* mContext; // const after constructor
@@ -293,14 +294,14 @@ class HangMonitorParent : public PProcessHangMonitorParent,
RefPtr<HangMonitoredProcess> mProcess; RefPtr<HangMonitoredProcess> mProcess;
// Must be accessed with mMonitor held. // Must be accessed with mMonitor held.
bool mShutdownDone GUARDED_BY(mMonitor); bool mShutdownDone MOZ_GUARDED_BY(mMonitor);
// Map from plugin ID to crash dump ID. Protected by // Map from plugin ID to crash dump ID. Protected by
// mBrowserCrashDumpHashLock. // mBrowserCrashDumpHashLock.
nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds
GUARDED_BY(mMonitor); MOZ_GUARDED_BY(mMonitor);
Mutex mBrowserCrashDumpHashLock GUARDED_BY(mMonitor); Mutex mBrowserCrashDumpHashLock MOZ_GUARDED_BY(mMonitor);
mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory
GUARDED_BY(mMonitor); MOZ_GUARDED_BY(mMonitor);
}; };
} // namespace } // namespace

View File

@@ -228,7 +228,7 @@ int AudioStream::InvokeCubeb(Function aFunction, Args&&... aArgs) {
} }
nsresult AudioStream::Init(AudioDeviceInfo* aSinkInfo) nsresult AudioStream::Init(AudioDeviceInfo* aSinkInfo)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
auto startTime = TimeStamp::Now(); auto startTime = TimeStamp::Now();
TRACE("AudioStream::Init"); TRACE("AudioStream::Init");

View File

@@ -112,7 +112,7 @@ class AudioClock {
// protected by the AudioStream monitor on other platforms. // protected by the AudioStream monitor on other platforms.
const UniquePtr<FrameHistory> mFrameHistory const UniquePtr<FrameHistory> mFrameHistory
# ifndef XP_MACOSX # ifndef XP_MACOSX
GUARDED_BY(mMutex) MOZ_GUARDED_BY(mMutex)
# endif # endif
; ;
# ifdef XP_MACOSX # ifdef XP_MACOSX
@@ -335,10 +335,10 @@ class AudioStream final {
// Return true if audio frames are valid (correct sampling rate and valid // Return true if audio frames are valid (correct sampling rate and valid
// channel count) otherwise false. // channel count) otherwise false.
bool IsValidAudioFormat(Chunk* aChunk) REQUIRES(mMonitor); bool IsValidAudioFormat(Chunk* aChunk) MOZ_REQUIRES(mMonitor);
template <typename Function, typename... Args> template <typename Function, typename... Args>
int InvokeCubeb(Function aFunction, Args&&... aArgs) REQUIRES(mMonitor); int InvokeCubeb(Function aFunction, Args&&... aArgs) MOZ_REQUIRES(mMonitor);
bool CheckThreadIdChanged(); bool CheckThreadIdChanged();
void AssertIsOnAudioThread() const; void AssertIsOnAudioThread() const;
@@ -382,7 +382,8 @@ class AudioStream final {
std::atomic<ProfilerThreadId> mAudioThreadId; std::atomic<ProfilerThreadId> mAudioThreadId;
const bool mSandboxed = false; const bool mSandboxed = false;
MozPromiseHolder<MediaSink::EndedPromise> mEndedPromise GUARDED_BY(mMonitor); MozPromiseHolder<MediaSink::EndedPromise> mEndedPromise
MOZ_GUARDED_BY(mMonitor);
std::atomic<bool> mPlaybackComplete; std::atomic<bool> mPlaybackComplete;
// Both written on the MDSM thread, read on the audio thread. // Both written on the MDSM thread, read on the audio thread.
std::atomic<float> mPlaybackRate; std::atomic<float> mPlaybackRate;

View File

@@ -151,9 +151,9 @@ class FileBlockCache : public MediaBlockCacheBase {
nsresult WriteBlockToFile(int32_t aBlockIndex, const uint8_t* aBlockData); nsresult WriteBlockToFile(int32_t aBlockIndex, const uint8_t* aBlockData);
// File descriptor we're writing to. This is created externally, but // File descriptor we're writing to. This is created externally, but
// shutdown by us. // shutdown by us.
PRFileDesc* mFD PT_GUARDED_BY(mFileMutex); PRFileDesc* mFD MOZ_PT_GUARDED_BY(mFileMutex);
// The current file offset in the file. // The current file offset in the file.
int64_t mFDCurrentPos GUARDED_BY(mFileMutex); int64_t mFDCurrentPos MOZ_GUARDED_BY(mFileMutex);
// Mutex which controls access to all data in this class, except mFD // Mutex which controls access to all data in this class, except mFD
// and mFDCurrentPos. Don't hold mDataMutex while holding mFileMutex! // and mFDCurrentPos. Don't hold mDataMutex while holding mFileMutex!
@@ -170,22 +170,22 @@ class FileBlockCache : public MediaBlockCacheBase {
// mBlockChanges[offset/BLOCK_SIZE] != nullptr, then either there's a block // mBlockChanges[offset/BLOCK_SIZE] != nullptr, then either there's a block
// cached in memory waiting to be written, or this block is the target of a // cached in memory waiting to be written, or this block is the target of a
// block move. // block move.
nsTArray<RefPtr<BlockChange> > mBlockChanges GUARDED_BY(mDataMutex); nsTArray<RefPtr<BlockChange> > mBlockChanges MOZ_GUARDED_BY(mDataMutex);
// Event target upon which block writes and block moves are performed. This is // Event target upon which block writes and block moves are performed. This is
// created upon open, and dropped on close. // created upon open, and dropped on close.
nsCOMPtr<nsISerialEventTarget> mBackgroundET GUARDED_BY(mDataMutex); nsCOMPtr<nsISerialEventTarget> mBackgroundET MOZ_GUARDED_BY(mDataMutex);
// Queue of pending block indexes that need to be written or moved. // Queue of pending block indexes that need to be written or moved.
std::deque<int32_t> mChangeIndexList GUARDED_BY(mDataMutex); std::deque<int32_t> mChangeIndexList MOZ_GUARDED_BY(mDataMutex);
// True if we've dispatched an event to commit all pending block changes // True if we've dispatched an event to commit all pending block changes
// to file on mBackgroundET. // to file on mBackgroundET.
bool mIsWriteScheduled GUARDED_BY(mDataMutex); bool mIsWriteScheduled MOZ_GUARDED_BY(mDataMutex);
// True when a read is happening. Pending writes may be postponed, to give // True when a read is happening. Pending writes may be postponed, to give
// higher priority to reads (which may be blocking the caller). // higher priority to reads (which may be blocking the caller).
bool mIsReading GUARDED_BY(mDataMutex); bool mIsReading MOZ_GUARDED_BY(mDataMutex);
// True if we've got a temporary file descriptor. Note: we don't use mFD // True if we've got a temporary file descriptor. Note: we don't use mFD
// directly as that's synchronized via mFileMutex and we need to make // directly as that's synchronized via mFileMutex and we need to make
// decisions about whether we can write while holding mDataMutex. // decisions about whether we can write while holding mDataMutex.
bool mInitialized GUARDED_BY(mDataMutex) = false; bool mInitialized MOZ_GUARDED_BY(mDataMutex) = false;
}; };
} // End namespace mozilla. } // End namespace mozilla.

View File

@@ -91,21 +91,21 @@ class FileMediaResource : public BaseMediaResource {
// calling. The implmentation of Read, Seek and ReadAt obtains the // calling. The implmentation of Read, Seek and ReadAt obtains the
// lock before calling these Unsafe variants to read or seek. // lock before calling these Unsafe variants to read or seek.
nsresult UnsafeRead(char* aBuffer, uint32_t aCount, uint32_t* aBytes) nsresult UnsafeRead(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
nsresult UnsafeSeek(int32_t aWhence, int64_t aOffset) REQUIRES(mLock); nsresult UnsafeSeek(int32_t aWhence, int64_t aOffset) MOZ_REQUIRES(mLock);
private: private:
// Ensures mSize is initialized, if it can be. // Ensures mSize is initialized, if it can be.
// mLock must be held when this is called, and mInput must be non-null. // mLock must be held when this is called, and mInput must be non-null.
void EnsureSizeInitialized() REQUIRES(mLock); void EnsureSizeInitialized() MOZ_REQUIRES(mLock);
already_AddRefed<MediaByteBuffer> UnsafeMediaReadAt(int64_t aOffset, already_AddRefed<MediaByteBuffer> UnsafeMediaReadAt(int64_t aOffset,
uint32_t aCount) uint32_t aCount)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// The file size, or -1 if not known. Immutable after Open(). // The file size, or -1 if not known. Immutable after Open().
// Can be used from any thread. // Can be used from any thread.
// XXX FIX? is this under mLock? comments are contradictory // XXX FIX? is this under mLock? comments are contradictory
int64_t mSize GUARDED_BY(mLock); int64_t mSize MOZ_GUARDED_BY(mLock);
// This lock handles synchronisation between calls to Close() and // This lock handles synchronisation between calls to Close() and
// the Read, Seek, etc calls. Close must not be called while a // the Read, Seek, etc calls. Close must not be called while a
@@ -116,16 +116,16 @@ class FileMediaResource : public BaseMediaResource {
// Seekable stream interface to file. This can be used from any // Seekable stream interface to file. This can be used from any
// thread. // thread.
nsCOMPtr<nsISeekableStream> mSeekable GUARDED_BY(mLock); nsCOMPtr<nsISeekableStream> mSeekable MOZ_GUARDED_BY(mLock);
// Input stream for the media data. This can be used from any // Input stream for the media data. This can be used from any
// thread. // thread.
nsCOMPtr<nsIInputStream> mInput GUARDED_BY(mLock); nsCOMPtr<nsIInputStream> mInput MOZ_GUARDED_BY(mLock);
// Whether we've attempted to initialize mSize. Note that mSize can be -1 // Whether we've attempted to initialize mSize. Note that mSize can be -1
// when mSizeInitialized is true if we tried and failed to get the size // when mSizeInitialized is true if we tried and failed to get the size
// of the file. // of the file.
bool mSizeInitialized GUARDED_BY(mLock); bool mSizeInitialized MOZ_GUARDED_BY(mLock);
// Set to true if NotifyDataEnded callback has been processed (which only // Set to true if NotifyDataEnded callback has been processed (which only
// occurs if resource size is known) // occurs if resource size is known)
bool mNotifyDataEndedProcessed = false; bool mNotifyDataEndedProcessed = false;

View File

@@ -86,9 +86,9 @@ class GraphRunner final : public Runnable {
MediaTrackGraphImpl* const mGraph; MediaTrackGraphImpl* const mGraph;
// State being handed over to the graph through OneIteration. Protected by // State being handed over to the graph through OneIteration. Protected by
// mMonitor. // mMonitor.
Maybe<IterationState> mIterationState GUARDED_BY(mMonitor); Maybe<IterationState> mIterationState MOZ_GUARDED_BY(mMonitor);
// Result from mGraph's OneIteration. Protected by mMonitor. // Result from mGraph's OneIteration. Protected by mMonitor.
IterationResult mIterationResult GUARDED_BY(mMonitor); IterationResult mIterationResult MOZ_GUARDED_BY(mMonitor);
enum class ThreadState { enum class ThreadState {
Wait, // Waiting for a message. This is the initial state. Wait, // Waiting for a message. This is the initial state.
@@ -100,7 +100,7 @@ class GraphRunner final : public Runnable {
}; };
// Protected by mMonitor until set to Shutdown, after which this is not // Protected by mMonitor until set to Shutdown, after which this is not
// modified. // modified.
ThreadState mThreadState GUARDED_BY(mMonitor); ThreadState mThreadState MOZ_GUARDED_BY(mMonitor);
// The thread running mGraph. Set on construction, after other members are // The thread running mGraph. Set on construction, after other members are
// initialized. Cleared at the end of Shutdown(). // initialized. Cleared at the end of Shutdown().

View File

@@ -1533,9 +1533,9 @@ auto MediaTrackGraphImpl::OneIterationImpl(GraphTime aStateTime,
// > LIFECYCLE_RUNNING) // > LIFECYCLE_RUNNING)
// Ignore mutex warning: static during execution of the graph // Ignore mutex warning: static during execution of the graph
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
MOZ_DIAGNOSTIC_ASSERT(mLifecycleState <= LIFECYCLE_RUNNING); MOZ_DIAGNOSTIC_ASSERT(mLifecycleState <= LIFECYCLE_RUNNING);
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
MOZ_ASSERT(OnGraphThread()); MOZ_ASSERT(OnGraphThread());
@@ -2725,7 +2725,7 @@ bool SourceMediaTrack::PullNewData(GraphTime aDesiredUpToTime) {
static void MoveToSegment(SourceMediaTrack* aTrack, MediaSegment* aIn, static void MoveToSegment(SourceMediaTrack* aTrack, MediaSegment* aIn,
MediaSegment* aOut, TrackTime aCurrentTime, MediaSegment* aOut, TrackTime aCurrentTime,
TrackTime aDesiredUpToTime) TrackTime aDesiredUpToTime)
REQUIRES(aTrack->GetMutex()) { MOZ_REQUIRES(aTrack->GetMutex()) {
MOZ_ASSERT(aIn->GetType() == aOut->GetType()); MOZ_ASSERT(aIn->GetType() == aOut->GetType());
MOZ_ASSERT(aOut->GetDuration() >= aCurrentTime); MOZ_ASSERT(aOut->GetDuration() >= aCurrentTime);
MOZ_ASSERT(aDesiredUpToTime >= aCurrentTime); MOZ_ASSERT(aDesiredUpToTime >= aCurrentTime);

View File

@@ -671,9 +671,9 @@ class SourceMediaTrack : public MediaTrack {
// The value set here is applied in MoveToSegment so we can avoid the // The value set here is applied in MoveToSegment so we can avoid the
// buffering delay in applying the change. See Bug 1443511. // buffering delay in applying the change. See Bug 1443511.
void SetVolume(float aVolume); void SetVolume(float aVolume);
float GetVolumeLocked() REQUIRES(mMutex); float GetVolumeLocked() MOZ_REQUIRES(mMutex);
Mutex& GetMutex() RETURN_CAPABILITY(mMutex) { return mMutex; } Mutex& GetMutex() MOZ_RETURN_CAPABILITY(mMutex) { return mMutex; }
friend class MediaTrackGraphImpl; friend class MediaTrackGraphImpl;
@@ -706,7 +706,8 @@ class SourceMediaTrack : public MediaTrack {
bool NeedsMixing(); bool NeedsMixing();
void ResampleAudioToGraphSampleRate(MediaSegment* aSegment) REQUIRES(mMutex); void ResampleAudioToGraphSampleRate(MediaSegment* aSegment)
MOZ_REQUIRES(mMutex);
void AddDirectListenerImpl( void AddDirectListenerImpl(
already_AddRefed<DirectMediaTrackListener> aListener) override; already_AddRefed<DirectMediaTrackListener> aListener) override;
@@ -718,7 +719,7 @@ class SourceMediaTrack : public MediaTrack {
* from AppendData on the thread providing the data, and will call * from AppendData on the thread providing the data, and will call
* the Listeners on this thread. * the Listeners on this thread.
*/ */
void NotifyDirectConsumers(MediaSegment* aSegment) REQUIRES(mMutex); void NotifyDirectConsumers(MediaSegment* aSegment) MOZ_REQUIRES(mMutex);
void OnGraphThreadDone() override { void OnGraphThreadDone() override {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
@@ -739,10 +740,10 @@ class SourceMediaTrack : public MediaTrack {
// held together. // held together.
Mutex mMutex; Mutex mMutex;
// protected by mMutex // protected by mMutex
float mVolume GUARDED_BY(mMutex) = 1.0; float mVolume MOZ_GUARDED_BY(mMutex) = 1.0;
UniquePtr<TrackData> mUpdateTrack GUARDED_BY(mMutex); UniquePtr<TrackData> mUpdateTrack MOZ_GUARDED_BY(mMutex);
nsTArray<RefPtr<DirectMediaTrackListener>> mDirectTrackListeners nsTArray<RefPtr<DirectMediaTrackListener>> mDirectTrackListeners
GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
}; };
/** /**

View File

@@ -189,7 +189,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/** /**
* Called to apply a TrackUpdate to its track. * Called to apply a TrackUpdate to its track.
*/ */
void ApplyTrackUpdate(TrackUpdate* aUpdate) REQUIRES(mMonitor); void ApplyTrackUpdate(TrackUpdate* aUpdate) MOZ_REQUIRES(mMonitor);
/** /**
* Append a ControlMessage to the message queue. This queue is drained * Append a ControlMessage to the message queue. This queue is drained
* during RunInStableState; the messages will run on the graph thread. * during RunInStableState; the messages will run on the graph thread.
@@ -280,12 +280,13 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* mMonitor must be held. * mMonitor must be held.
* See EnsureRunInStableState * See EnsureRunInStableState
*/ */
void EnsureStableStateEventPosted() REQUIRES(mMonitor); void EnsureStableStateEventPosted() MOZ_REQUIRES(mMonitor);
/** /**
* Generate messages to the main thread to update it for all state changes. * Generate messages to the main thread to update it for all state changes.
* mMonitor must be held. * mMonitor must be held.
*/ */
void PrepareUpdatesToMainThreadState(bool aFinalUpdate) REQUIRES(mMonitor); void PrepareUpdatesToMainThreadState(bool aFinalUpdate)
MOZ_REQUIRES(mMonitor);
/** /**
* If we are rendering in non-realtime mode, we don't want to send messages to * If we are rendering in non-realtime mode, we don't want to send messages to
* the main thread at each iteration for performance reasons. We instead * the main thread at each iteration for performance reasons. We instead
@@ -319,7 +320,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
*/ */
void UpdateGraph(GraphTime aEndBlockingDecisions); void UpdateGraph(GraphTime aEndBlockingDecisions);
void SwapMessageQueues() REQUIRES(mMonitor) { void SwapMessageQueues() MOZ_REQUIRES(mMonitor) {
MOZ_ASSERT(OnGraphThreadOrNotRunning()); MOZ_ASSERT(OnGraphThreadOrNotRunning());
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
MOZ_ASSERT(mFrontMessageQueue.IsEmpty()); MOZ_ASSERT(mFrontMessageQueue.IsEmpty());
@@ -553,7 +554,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/** /**
* Not safe to call off the MediaTrackGraph thread unless monitor is held! * Not safe to call off the MediaTrackGraph thread unless monitor is held!
*/ */
GraphDriver* CurrentDriver() const NO_THREAD_SAFETY_ANALYSIS { GraphDriver* CurrentDriver() const MOZ_NO_THREAD_SAFETY_ANALYSIS {
#ifdef DEBUG #ifdef DEBUG
if (!OnGraphThreadOrNotRunning()) { if (!OnGraphThreadOrNotRunning()) {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
@@ -787,11 +788,11 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/** /**
* State to copy to main thread * State to copy to main thread
*/ */
nsTArray<TrackUpdate> mTrackUpdates GUARDED_BY(mMonitor); nsTArray<TrackUpdate> mTrackUpdates MOZ_GUARDED_BY(mMonitor);
/** /**
* Runnables to run after the next update to main thread state. * Runnables to run after the next update to main thread state.
*/ */
nsTArray<nsCOMPtr<nsIRunnable>> mUpdateRunnables GUARDED_BY(mMonitor); nsTArray<nsCOMPtr<nsIRunnable>> mUpdateRunnables MOZ_GUARDED_BY(mMonitor);
/** /**
* A list of batches of messages to process. Each batch is processed * A list of batches of messages to process. Each batch is processed
* as an atomic unit. * as an atomic unit.
@@ -805,10 +806,10 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* Message queue in which the main thread appends messages. * Message queue in which the main thread appends messages.
* Access guarded by mMonitor. * Access guarded by mMonitor.
*/ */
nsTArray<MessageBlock> mBackMessageQueue GUARDED_BY(mMonitor); nsTArray<MessageBlock> mBackMessageQueue MOZ_GUARDED_BY(mMonitor);
/* True if there will messages to process if we swap the message queues. */ /* True if there will messages to process if we swap the message queues. */
bool MessagesQueued() const REQUIRES(mMonitor) { bool MessagesQueued() const MOZ_REQUIRES(mMonitor) {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
return !mBackMessageQueue.IsEmpty(); return !mBackMessageQueue.IsEmpty();
} }
@@ -862,8 +863,8 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP occur on the graph thread at * LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP occur on the graph thread at
* the end of an iteration. All other transitions occur on the main thread. * the end of an iteration. All other transitions occur on the main thread.
*/ */
LifecycleState mLifecycleState GUARDED_BY(mMonitor); LifecycleState mLifecycleState MOZ_GUARDED_BY(mMonitor);
LifecycleState& LifecycleStateRef() NO_THREAD_SAFETY_ANALYSIS { LifecycleState& LifecycleStateRef() MOZ_NO_THREAD_SAFETY_ANALYSIS {
#if DEBUG #if DEBUG
if (mGraphDriverRunning) { if (mGraphDriverRunning) {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
@@ -873,7 +874,8 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
#endif #endif
return mLifecycleState; return mLifecycleState;
} }
const LifecycleState& LifecycleStateRef() const NO_THREAD_SAFETY_ANALYSIS { const LifecycleState& LifecycleStateRef() const
MOZ_NO_THREAD_SAFETY_ANALYSIS {
#if DEBUG #if DEBUG
if (mGraphDriverRunning) { if (mGraphDriverRunning) {
mMonitor.AssertCurrentThreadOwns(); mMonitor.AssertCurrentThreadOwns();
@@ -899,7 +901,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* forced) has commenced. Set on the main thread under mMonitor and read on * forced) has commenced. Set on the main thread under mMonitor and read on
* the graph thread under mMonitor. * the graph thread under mMonitor.
**/ **/
bool mInterruptJSCalled GUARDED_BY(mMonitor) = false; bool mInterruptJSCalled MOZ_GUARDED_BY(mMonitor) = false;
/** /**
* Remove this blocker to unblock shutdown. * Remove this blocker to unblock shutdown.
@@ -912,7 +914,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* RunInStableState() and the event hasn't run yet. * RunInStableState() and the event hasn't run yet.
* Accessed on both main and MTG thread, mMonitor must be held. * Accessed on both main and MTG thread, mMonitor must be held.
*/ */
bool mPostedRunInStableStateEvent GUARDED_BY(mMonitor); bool mPostedRunInStableStateEvent MOZ_GUARDED_BY(mMonitor);
/** /**
* The JSContext of the graph thread. Set under mMonitor on only the graph * The JSContext of the graph thread. Set under mMonitor on only the graph
@@ -920,7 +922,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* the thread is about to exit. Read under mMonitor on the main thread to * the thread is about to exit. Read under mMonitor on the main thread to
* interrupt running JS for forced shutdown. * interrupt running JS for forced shutdown.
**/ **/
JSContext* mJSContext GUARDED_BY(mMonitor) = nullptr; JSContext* mJSContext MOZ_GUARDED_BY(mMonitor) = nullptr;
// Main thread only // Main thread only
@@ -1015,7 +1017,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* Set based on mProcessedTime at end of iteration. * Set based on mProcessedTime at end of iteration.
* Read by stable state runnable on main thread. Protected by mMonitor. * Read by stable state runnable on main thread. Protected by mMonitor.
*/ */
GraphTime mNextMainThreadGraphTime GUARDED_BY(mMonitor) = 0; GraphTime mNextMainThreadGraphTime MOZ_GUARDED_BY(mMonitor) = 0;
/** /**
* Cached audio output latency, in seconds. Main thread only. This is reset * Cached audio output latency, in seconds. Main thread only. This is reset

View File

@@ -20,12 +20,12 @@ namespace mozilla {
// Default reader locking strategy, using a mutex to ensure that concurrent // Default reader locking strategy, using a mutex to ensure that concurrent
// PopAll calls won't overlap. // PopAll calls won't overlap.
class CAPABILITY MultiWriterQueueReaderLocking_Mutex { class MOZ_CAPABILITY MultiWriterQueueReaderLocking_Mutex {
public: public:
MultiWriterQueueReaderLocking_Mutex() MultiWriterQueueReaderLocking_Mutex()
: mMutex("MultiWriterQueueReaderLocking_Mutex") {} : mMutex("MultiWriterQueueReaderLocking_Mutex") {}
void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); }; void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); };
void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); }; void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); };
private: private:
Mutex mMutex; Mutex mMutex;
@@ -33,17 +33,17 @@ class CAPABILITY MultiWriterQueueReaderLocking_Mutex {
// Reader non-locking strategy, trusting that PopAll will never be called // Reader non-locking strategy, trusting that PopAll will never be called
// concurrently (e.g., by only calling it from a specific thread). // concurrently (e.g., by only calling it from a specific thread).
class CAPABILITY MultiWriterQueueReaderLocking_None { class MOZ_CAPABILITY MultiWriterQueueReaderLocking_None {
public: public:
#ifndef DEBUG #ifndef DEBUG
void Lock() CAPABILITY_ACQUIRE(){}; void Lock() MOZ_CAPABILITY_ACQUIRE(){};
void Unlock() CAPABILITY_RELEASE(){}; void Unlock() MOZ_CAPABILITY_RELEASE(){};
#else #else
// DEBUG-mode checks to catch concurrent misuses. // DEBUG-mode checks to catch concurrent misuses.
void Lock() CAPABILITY_ACQUIRE() { void Lock() MOZ_CAPABILITY_ACQUIRE() {
MOZ_ASSERT(mLocked.compareExchange(false, true)); MOZ_ASSERT(mLocked.compareExchange(false, true));
}; };
void Unlock() CAPABILITY_RELEASE() { void Unlock() MOZ_CAPABILITY_RELEASE() {
MOZ_ASSERT(mLocked.compareExchange(true, false)); MOZ_ASSERT(mLocked.compareExchange(true, false));
}; };

View File

@@ -257,11 +257,11 @@ GMPMutexImpl::~GMPMutexImpl() { MOZ_COUNT_DTOR(GMPMutexImpl); }
void GMPMutexImpl::Destroy() { delete this; } void GMPMutexImpl::Destroy() { delete this; }
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
void GMPMutexImpl::Acquire() { mMonitor.Enter(); } void GMPMutexImpl::Acquire() { mMonitor.Enter(); }
void GMPMutexImpl::Release() { mMonitor.Exit(); } void GMPMutexImpl::Release() { mMonitor.Exit(); }
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
GMPTask* NewGMPTask(std::function<void()>&& aFunction) { GMPTask* NewGMPTask(std::function<void()>&& aFunction) {
class Task : public GMPTask { class Task : public GMPTask {

View File

@@ -36,11 +36,11 @@ using namespace gfx;
// launched serially. Protects sLaunchPromise // launched serially. Protects sLaunchPromise
StaticMutex sLaunchRDDMutex; StaticMutex sLaunchRDDMutex;
static StaticRefPtr<GenericNonExclusivePromise> sLaunchRDDPromise static StaticRefPtr<GenericNonExclusivePromise> sLaunchRDDPromise
GUARDED_BY(sLaunchRDDMutex); MOZ_GUARDED_BY(sLaunchRDDMutex);
StaticMutex sLaunchUtilityMutex; StaticMutex sLaunchUtilityMutex;
static StaticRefPtr<GenericNonExclusivePromise> sLaunchUtilityPromise static StaticRefPtr<GenericNonExclusivePromise> sLaunchUtilityPromise
GUARDED_BY(sLaunchUtilityMutex); MOZ_GUARDED_BY(sLaunchUtilityMutex);
// Only modified on the main-thread, read on any thread. While it could be read // Only modified on the main-thread, read on any thread. While it could be read
// on the main thread directly, for clarity we force access via the DataMutex // on the main thread directly, for clarity we force access via the DataMutex

View File

@@ -154,7 +154,7 @@ class TrackBuffersManager final
MediaResult& aResult); MediaResult& aResult);
int32_t FindCurrentPosition(TrackInfo::TrackType aTrack, int32_t FindCurrentPosition(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz) const const media::TimeUnit& aFuzz) const
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
// Will set the next GetSample index if needed. This information is determined // Will set the next GetSample index if needed. This information is determined
// through the value of mNextSampleTimecode. Return false if the index // through the value of mNextSampleTimecode. Return false if the index
@@ -163,7 +163,7 @@ class TrackBuffersManager final
// timecode or is empty. // timecode or is empty.
nsresult SetNextGetSampleIndexIfNeeded(TrackInfo::TrackType aTrack, nsresult SetNextGetSampleIndexIfNeeded(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz) const media::TimeUnit& aFuzz)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
media::TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack, media::TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz); const media::TimeUnit& aFuzz);
@@ -183,62 +183,62 @@ class TrackBuffersManager final
// All following functions run on the taskqueue. // All following functions run on the taskqueue.
RefPtr<AppendPromise> DoAppendData(already_AddRefed<MediaByteBuffer> aData, RefPtr<AppendPromise> DoAppendData(already_AddRefed<MediaByteBuffer> aData,
const SourceBufferAttributes& aAttributes); const SourceBufferAttributes& aAttributes);
void ScheduleSegmentParserLoop() REQUIRES(mTaskQueueCapability); void ScheduleSegmentParserLoop() MOZ_REQUIRES(mTaskQueueCapability);
void SegmentParserLoop() REQUIRES(mTaskQueueCapability); void SegmentParserLoop() MOZ_REQUIRES(mTaskQueueCapability);
void InitializationSegmentReceived() REQUIRES(mTaskQueueCapability); void InitializationSegmentReceived() MOZ_REQUIRES(mTaskQueueCapability);
void ShutdownDemuxers() REQUIRES(mTaskQueueCapability); void ShutdownDemuxers() MOZ_REQUIRES(mTaskQueueCapability);
void CreateDemuxerforMIMEType() REQUIRES(mTaskQueueCapability); void CreateDemuxerforMIMEType() MOZ_REQUIRES(mTaskQueueCapability);
void ResetDemuxingState() REQUIRES(mTaskQueueCapability); void ResetDemuxingState() MOZ_REQUIRES(mTaskQueueCapability);
void NeedMoreData() REQUIRES(mTaskQueueCapability); void NeedMoreData() MOZ_REQUIRES(mTaskQueueCapability);
void RejectAppend(const MediaResult& aRejectValue, const char* aName) void RejectAppend(const MediaResult& aRejectValue, const char* aName)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
// Will return a promise that will be resolved once all frames of the current // Will return a promise that will be resolved once all frames of the current
// media segment have been processed. // media segment have been processed.
RefPtr<CodedFrameProcessingPromise> CodedFrameProcessing() RefPtr<CodedFrameProcessingPromise> CodedFrameProcessing()
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
void CompleteCodedFrameProcessing() REQUIRES(mTaskQueueCapability); void CompleteCodedFrameProcessing() MOZ_REQUIRES(mTaskQueueCapability);
// Called by ResetParserState. // Called by ResetParserState.
void CompleteResetParserState() REQUIRES(mTaskQueueCapability); void CompleteResetParserState() MOZ_REQUIRES(mTaskQueueCapability);
RefPtr<RangeRemovalPromise> CodedFrameRemovalWithPromise( RefPtr<RangeRemovalPromise> CodedFrameRemovalWithPromise(
media::TimeInterval aInterval) REQUIRES(mTaskQueueCapability); media::TimeInterval aInterval) MOZ_REQUIRES(mTaskQueueCapability);
bool CodedFrameRemoval(media::TimeInterval aInterval) bool CodedFrameRemoval(media::TimeInterval aInterval)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
// Removes all coded frames -- this is not to spec and should be used as a // Removes all coded frames -- this is not to spec and should be used as a
// last resort to clear buffers only if other methods cannot. // last resort to clear buffers only if other methods cannot.
void RemoveAllCodedFrames() REQUIRES(mTaskQueueCapability); void RemoveAllCodedFrames() MOZ_REQUIRES(mTaskQueueCapability);
void SetAppendState(SourceBufferAttributes::AppendState aAppendState) void SetAppendState(SourceBufferAttributes::AppendState aAppendState)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
bool HasVideo() const { return mVideoTracks.mNumTracks > 0; } bool HasVideo() const { return mVideoTracks.mNumTracks > 0; }
bool HasAudio() const { return mAudioTracks.mNumTracks > 0; } bool HasAudio() const { return mAudioTracks.mNumTracks > 0; }
// The input buffer as per // The input buffer as per
// http://w3c.github.io/media-source/index.html#sourcebuffer-input-buffer // http://w3c.github.io/media-source/index.html#sourcebuffer-input-buffer
Maybe<MediaSpan> mInputBuffer GUARDED_BY(mTaskQueueCapability); Maybe<MediaSpan> mInputBuffer MOZ_GUARDED_BY(mTaskQueueCapability);
// Buffer full flag as per // Buffer full flag as per
// https://w3c.github.io/media-source/#sourcebuffer-buffer-full-flag. Accessed // https://w3c.github.io/media-source/#sourcebuffer-buffer-full-flag. Accessed
// on both the main thread and the task queue. // on both the main thread and the task queue.
Atomic<bool> mBufferFull; Atomic<bool> mBufferFull;
bool mFirstInitializationSegmentReceived GUARDED_BY(mTaskQueueCapability); bool mFirstInitializationSegmentReceived MOZ_GUARDED_BY(mTaskQueueCapability);
bool mChangeTypeReceived GUARDED_BY(mTaskQueueCapability); bool mChangeTypeReceived MOZ_GUARDED_BY(mTaskQueueCapability);
// Set to true once a new segment is started. // Set to true once a new segment is started.
bool mNewMediaSegmentStarted GUARDED_BY(mTaskQueueCapability); bool mNewMediaSegmentStarted MOZ_GUARDED_BY(mTaskQueueCapability);
bool mActiveTrack GUARDED_BY(mTaskQueueCapability); bool mActiveTrack MOZ_GUARDED_BY(mTaskQueueCapability);
MediaContainerType mType GUARDED_BY(mTaskQueueCapability); MediaContainerType mType MOZ_GUARDED_BY(mTaskQueueCapability);
// ContainerParser objects and methods. // ContainerParser objects and methods.
// Those are used to parse the incoming input buffer. // Those are used to parse the incoming input buffer.
// Recreate the ContainerParser and if aReuseInitData is true then // Recreate the ContainerParser and if aReuseInitData is true then
// feed it with the previous init segment found. // feed it with the previous init segment found.
void RecreateParser(bool aReuseInitData) REQUIRES(mTaskQueueCapability); void RecreateParser(bool aReuseInitData) MOZ_REQUIRES(mTaskQueueCapability);
UniquePtr<ContainerParser> mParser; UniquePtr<ContainerParser> mParser;
// Demuxer objects and methods. // Demuxer objects and methods.
void AppendDataToCurrentInputBuffer(const MediaSpan& aData) void AppendDataToCurrentInputBuffer(const MediaSpan& aData)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
RefPtr<MediaByteBuffer> mInitData GUARDED_BY(mTaskQueueCapability); RefPtr<MediaByteBuffer> mInitData MOZ_GUARDED_BY(mTaskQueueCapability);
// Checks if a new set of init data is a repeat of the last set of init data // Checks if a new set of init data is a repeat of the last set of init data
// received. Because streams may retransmit the same init data (or // received. Because streams may retransmit the same init data (or
@@ -246,36 +246,37 @@ class TrackBuffersManager final
// operations each time we receive init data, only when it's actually // operations each time we receive init data, only when it's actually
// different data. // different data.
bool IsRepeatInitData(const MediaInfo& aNewMediaInfo) const bool IsRepeatInitData(const MediaInfo& aNewMediaInfo) const
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
// Temporary input buffer to handle partial media segment header. // Temporary input buffer to handle partial media segment header.
// We store the current input buffer content into it should we need to // We store the current input buffer content into it should we need to
// reinitialize the demuxer once we have some samples and a discontinuity is // reinitialize the demuxer once we have some samples and a discontinuity is
// detected. // detected.
Maybe<MediaSpan> mPendingInputBuffer GUARDED_BY(mTaskQueueCapability); Maybe<MediaSpan> mPendingInputBuffer MOZ_GUARDED_BY(mTaskQueueCapability);
RefPtr<SourceBufferResource> mCurrentInputBuffer RefPtr<SourceBufferResource> mCurrentInputBuffer
GUARDED_BY(mTaskQueueCapability); MOZ_GUARDED_BY(mTaskQueueCapability);
RefPtr<MediaDataDemuxer> mInputDemuxer GUARDED_BY(mTaskQueueCapability); RefPtr<MediaDataDemuxer> mInputDemuxer MOZ_GUARDED_BY(mTaskQueueCapability);
// Length already processed in current media segment. // Length already processed in current media segment.
uint64_t mProcessedInput GUARDED_BY(mTaskQueueCapability); uint64_t mProcessedInput MOZ_GUARDED_BY(mTaskQueueCapability);
Maybe<media::TimeUnit> mLastParsedEndTime GUARDED_BY(mTaskQueueCapability); Maybe<media::TimeUnit> mLastParsedEndTime
MOZ_GUARDED_BY(mTaskQueueCapability);
void OnDemuxerInitDone(const MediaResult& aResult); void OnDemuxerInitDone(const MediaResult& aResult);
void OnDemuxerInitFailed(const MediaResult& aFailure); void OnDemuxerInitFailed(const MediaResult& aFailure);
void OnDemuxerResetDone(const MediaResult& aResult) void OnDemuxerResetDone(const MediaResult& aResult)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest; MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
void OnDemuxFailed(TrackType aTrack, const MediaResult& aError) void OnDemuxFailed(TrackType aTrack, const MediaResult& aError)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
void DoDemuxVideo() REQUIRES(mTaskQueueCapability); void DoDemuxVideo() MOZ_REQUIRES(mTaskQueueCapability);
void OnVideoDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples); void OnVideoDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples);
void OnVideoDemuxFailed(const MediaResult& aError) { void OnVideoDemuxFailed(const MediaResult& aError) {
mVideoTracks.mDemuxRequest.Complete(); mVideoTracks.mDemuxRequest.Complete();
mTaskQueueCapability->AssertOnCurrentThread(); mTaskQueueCapability->AssertOnCurrentThread();
OnDemuxFailed(TrackType::kVideoTrack, aError); OnDemuxFailed(TrackType::kVideoTrack, aError);
} }
void DoDemuxAudio() REQUIRES(mTaskQueueCapability); void DoDemuxAudio() MOZ_REQUIRES(mTaskQueueCapability);
void OnAudioDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples); void OnAudioDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples);
void OnAudioDemuxFailed(const MediaResult& aError) { void OnAudioDemuxFailed(const MediaResult& aError) {
mAudioTracks.mDemuxRequest.Complete(); mAudioTracks.mDemuxRequest.Complete();
@@ -289,10 +290,10 @@ class TrackBuffersManager final
const nsTArray<RefPtr<MediaRawData>>& aSamples); const nsTArray<RefPtr<MediaRawData>>& aSamples);
void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aSizeToEvict) void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aSizeToEvict)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
void GetDebugInfo(dom::TrackBuffersManagerDebugInfo& aInfo) const void GetDebugInfo(dom::TrackBuffersManagerDebugInfo& aInfo) const
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
struct TrackData { struct TrackData {
TrackData() : mNumTracks(0), mNeedRandomAccessPoint(true), mSizeBuffer(0) {} TrackData() : mNumTracks(0), mNeedRandomAccessPoint(true), mSizeBuffer(0) {}
@@ -416,20 +417,20 @@ class TrackBuffersManager final
}; };
void CheckSequenceDiscontinuity(const media::TimeUnit& aPresentationTime) void CheckSequenceDiscontinuity(const media::TimeUnit& aPresentationTime)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData) void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
media::TimeInterval PresentationInterval(const TrackBuffer& aSamples) const media::TimeInterval PresentationInterval(const TrackBuffer& aSamples) const
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
bool CheckNextInsertionIndex(TrackData& aTrackData, bool CheckNextInsertionIndex(TrackData& aTrackData,
const media::TimeUnit& aSampleTime) const media::TimeUnit& aSampleTime)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
void InsertFrames(TrackBuffer& aSamples, void InsertFrames(TrackBuffer& aSamples,
const media::TimeIntervals& aIntervals, const media::TimeIntervals& aIntervals,
TrackData& aTrackData) REQUIRES(mTaskQueueCapability); TrackData& aTrackData) MOZ_REQUIRES(mTaskQueueCapability);
void UpdateHighestTimestamp(TrackData& aTrackData, void UpdateHighestTimestamp(TrackData& aTrackData,
const media::TimeUnit& aHighestTime) const media::TimeUnit& aHighestTime)
REQUIRES(mTaskQueueCapability); MOZ_REQUIRES(mTaskQueueCapability);
// Remove all frames and their dependencies contained in aIntervals. // Remove all frames and their dependencies contained in aIntervals.
// Return the index at which frames were first removed or 0 if no frames // Return the index at which frames were first removed or 0 if no frames
// removed. // removed.
@@ -507,15 +508,15 @@ class TrackBuffersManager final
void ProcessTasks(); void ProcessTasks();
// Set if the TrackBuffersManager is currently processing a task. // Set if the TrackBuffersManager is currently processing a task.
// At this stage, this task is always a AppendBufferTask. // At this stage, this task is always a AppendBufferTask.
RefPtr<SourceBufferTask> mCurrentTask GUARDED_BY(mTaskQueueCapability); RefPtr<SourceBufferTask> mCurrentTask MOZ_GUARDED_BY(mTaskQueueCapability);
// Current SourceBuffer state for ongoing task. // Current SourceBuffer state for ongoing task.
// Its content is returned to the SourceBuffer once the AppendBufferTask has // Its content is returned to the SourceBuffer once the AppendBufferTask has
// completed. // completed.
UniquePtr<SourceBufferAttributes> mSourceBufferAttributes UniquePtr<SourceBufferAttributes> mSourceBufferAttributes
GUARDED_BY(mTaskQueueCapability); MOZ_GUARDED_BY(mTaskQueueCapability);
// The current sourcebuffer append window. It's content is equivalent to // The current sourcebuffer append window. It's content is equivalent to
// mSourceBufferAttributes.mAppendWindowStart/End // mSourceBufferAttributes.mAppendWindowStart/End
media::TimeInterval mAppendWindow GUARDED_BY(mTaskQueueCapability); media::TimeInterval mAppendWindow MOZ_GUARDED_BY(mTaskQueueCapability);
// Strong references to external objects. // Strong references to external objects.
nsMainThreadPtrHandle<MediaSourceDecoder> mParentDecoder; nsMainThreadPtrHandle<MediaSourceDecoder> mParentDecoder;

View File

@@ -29,7 +29,7 @@ class FFmpegAudioDecoder<LIBAV_VER>
virtual ~FFmpegAudioDecoder(); virtual ~FFmpegAudioDecoder();
RefPtr<InitPromise> Init() override; RefPtr<InitPromise> Init() override;
void InitCodecContext() REQUIRES(sMutex) override; void InitCodecContext() MOZ_REQUIRES(sMutex) override;
static AVCodecID GetCodecId(const nsACString& aMimeType); static AVCodecID GetCodecId(const nsACString& aMimeType);
nsCString GetDescriptionName() const override { nsCString GetDescriptionName() const override {
return "ffmpeg audio decoder"_ns; return "ffmpeg audio decoder"_ns;

View File

@@ -48,7 +48,7 @@ class FFmpegDataDecoder<LIBAV_VER>
// Flush and Drain operation, always run // Flush and Drain operation, always run
virtual RefPtr<FlushPromise> ProcessFlush(); virtual RefPtr<FlushPromise> ProcessFlush();
virtual void ProcessShutdown(); virtual void ProcessShutdown();
virtual void InitCodecContext() REQUIRES(sMutex) {} virtual void InitCodecContext() MOZ_REQUIRES(sMutex) {}
AVFrame* PrepareFrame(); AVFrame* PrepareFrame();
MediaResult InitDecoder(); MediaResult InitDecoder();
MediaResult AllocateExtraData(); MediaResult AllocateExtraData();

View File

@@ -53,7 +53,7 @@ class FFmpegVideoDecoder<LIBAV_VER>
~FFmpegVideoDecoder(); ~FFmpegVideoDecoder();
RefPtr<InitPromise> Init() override; RefPtr<InitPromise> Init() override;
void InitCodecContext() REQUIRES(sMutex) override; void InitCodecContext() MOZ_REQUIRES(sMutex) override;
nsCString GetDescriptionName() const override { nsCString GetDescriptionName() const override {
#ifdef USING_MOZFFVPX #ifdef USING_MOZFFVPX
return "ffvpx video decoder"_ns; return "ffvpx video decoder"_ns;

View File

@@ -392,9 +392,9 @@ class OriginKeyStore {
} }
// Only accessed on StreamTS threads // Only accessed on StreamTS threads
OriginKeysLoader mOriginKeys GUARDED_BY(sOriginKeyStoreStsMutex); OriginKeysLoader mOriginKeys MOZ_GUARDED_BY(sOriginKeyStoreStsMutex);
OriginKeysTable mPrivateBrowsingOriginKeys OriginKeysTable mPrivateBrowsingOriginKeys
GUARDED_BY(sOriginKeyStoreStsMutex); MOZ_GUARDED_BY(sOriginKeyStoreStsMutex);
}; };
OriginKeyStore* OriginKeyStore::sOriginKeyStore = nullptr; OriginKeyStore* OriginKeyStore::sOriginKeyStore = nullptr;

View File

@@ -69,15 +69,15 @@ class PlatformUIThread : public PlatformThread {
// Initialize the UI thread that is servicing the timer events // Initialize the UI thread that is servicing the timer events
bool InternalInit(); bool InternalInit();
HWND hwnd_ GUARDED_BY(cs_) = nullptr; HWND hwnd_ MOZ_GUARDED_BY(cs_) = nullptr;
UINT_PTR timerid_ GUARDED_BY(cs_) = 0; UINT_PTR timerid_ MOZ_GUARDED_BY(cs_) = 0;
unsigned int timeout_ GUARDED_BY(cs_) = 0; unsigned int timeout_ MOZ_GUARDED_BY(cs_) = 0;
enum class State { enum class State {
UNSTARTED, UNSTARTED,
STARTED, STARTED,
STOPPED, STOPPED,
}; };
State state_ GUARDED_BY(cs_) = State::UNSTARTED; State state_ MOZ_GUARDED_BY(cs_) = State::UNSTARTED;
}; };
} // namespace rtc } // namespace rtc

View File

@@ -32,7 +32,7 @@ class SharedBuffers final {
explicit OutputQueue(const char* aName) : mMutex(aName) {} explicit OutputQueue(const char* aName) : mMutex(aName) {}
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
REQUIRES(mMutex) { MOZ_REQUIRES(mMutex) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
size_t amount = 0; size_t amount = 0;
@@ -43,18 +43,18 @@ class SharedBuffers final {
return amount; return amount;
} }
Mutex& Lock() const RETURN_CAPABILITY(mMutex) { Mutex& Lock() const MOZ_RETURN_CAPABILITY(mMutex) {
return const_cast<OutputQueue*>(this)->mMutex; return const_cast<OutputQueue*>(this)->mMutex;
} }
size_t ReadyToConsume() const REQUIRES(mMutex) { size_t ReadyToConsume() const MOZ_REQUIRES(mMutex) {
// Accessed on both main thread and media graph thread. // Accessed on both main thread and media graph thread.
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
return mBufferList.size(); return mBufferList.size();
} }
// Produce one buffer // Produce one buffer
AudioChunk& Produce() REQUIRES(mMutex) { AudioChunk& Produce() MOZ_REQUIRES(mMutex) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mBufferList.push_back(AudioChunk()); mBufferList.push_back(AudioChunk());
@@ -62,7 +62,7 @@ class SharedBuffers final {
} }
// Consumes one buffer. // Consumes one buffer.
AudioChunk Consume() REQUIRES(mMutex) { AudioChunk Consume() MOZ_REQUIRES(mMutex) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(ReadyToConsume() > 0); MOZ_ASSERT(ReadyToConsume() > 0);
@@ -72,7 +72,7 @@ class SharedBuffers final {
} }
// Empties the buffer queue. // Empties the buffer queue.
void Clear() REQUIRES(mMutex) { void Clear() MOZ_REQUIRES(mMutex) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
mBufferList.clear(); mBufferList.clear();
} }

View File

@@ -144,7 +144,7 @@ class HRTFDatabaseLoader {
// Holding a m_threadLock is required when accessing m_databaseLoaderThread. // Holding a m_threadLock is required when accessing m_databaseLoaderThread.
mozilla::Mutex m_threadLock; mozilla::Mutex m_threadLock;
PRThread* m_databaseLoaderThread GUARDED_BY(m_threadLock); PRThread* m_databaseLoaderThread MOZ_GUARDED_BY(m_threadLock);
float m_databaseSampleRate; float m_databaseSampleRate;
mozilla::Atomic<bool> m_databaseLoaded; mozilla::Atomic<bool> m_databaseLoaded;

View File

@@ -299,9 +299,9 @@ class WebMBufferedState final {
// Sorted (by offset) map of data offsets to timecodes. Populated // Sorted (by offset) map of data offsets to timecodes. Populated
// on the main thread as data is received and parsed by WebMBufferedParsers. // on the main thread as data is received and parsed by WebMBufferedParsers.
nsTArray<WebMTimeDataOffset> mTimeMapping GUARDED_BY(mMutex); nsTArray<WebMTimeDataOffset> mTimeMapping MOZ_GUARDED_BY(mMutex);
// The last complete block parsed. -1 if not set. // The last complete block parsed. -1 if not set.
int64_t mLastBlockOffset GUARDED_BY(mMutex); int64_t mLastBlockOffset MOZ_GUARDED_BY(mMutex);
// Sorted (by offset) live parser instances. Main thread only. // Sorted (by offset) live parser instances. Main thread only.
nsTArray<WebMBufferedParser> mRangeParsers; nsTArray<WebMBufferedParser> mRangeParsers;

View File

@@ -40,7 +40,7 @@ class PerformanceStorageWorker final : public PerformanceStorage {
// Protected by mutex. // Protected by mutex.
// Created and released on worker-thread. Used also on main-thread. // Created and released on worker-thread. Used also on main-thread.
RefPtr<WeakWorkerRef> mWorkerRef GUARDED_BY(mMutex); RefPtr<WeakWorkerRef> mWorkerRef MOZ_GUARDED_BY(mMutex);
}; };
} // namespace mozilla::dom } // namespace mozilla::dom

View File

@@ -146,7 +146,7 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// Main thread callers must hold Lock() and check CleanUp() before calling // Main thread callers must hold Lock() and check CleanUp() before calling
// this. Worker thread callers, this will assert that the proxy has not been // this. Worker thread callers, this will assert that the proxy has not been
// cleaned up. // cleaned up.
WorkerPrivate* GetWorkerPrivate() const NO_THREAD_SAFETY_ANALYSIS; WorkerPrivate* GetWorkerPrivate() const MOZ_NO_THREAD_SAFETY_ANALYSIS;
// This should only be used within WorkerRunnable::WorkerRun() running on the // This should only be used within WorkerRunnable::WorkerRun() running on the
// worker thread! Do not call this after calling CleanUp(). // worker thread! Do not call this after calling CleanUp().
@@ -158,9 +158,9 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// 2. WorkerPromise() will crash! // 2. WorkerPromise() will crash!
void CleanUp(); void CleanUp();
Mutex& Lock() RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; } Mutex& Lock() MOZ_RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; }
bool CleanedUp() const REQUIRES(mCleanUpLock) { bool CleanedUp() const MOZ_REQUIRES(mCleanUpLock) {
mCleanUpLock.AssertCurrentThreadOwns(); mCleanUpLock.AssertCurrentThreadOwns();
return mCleanedUp; return mCleanedUp;
} }
@@ -204,8 +204,8 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// Modified on the worker thread. // Modified on the worker thread.
// It is ok to *read* this without a lock on the worker. // It is ok to *read* this without a lock on the worker.
// Main thread must always acquire a lock. // Main thread must always acquire a lock.
bool mCleanedUp bool mCleanedUp MOZ_GUARDED_BY(
GUARDED_BY(mCleanUpLock); // To specify if the cleanUp() has been done. mCleanUpLock); // To specify if the cleanUp() has been done.
const PromiseWorkerProxyStructuredCloneCallbacks* mCallbacks; const PromiseWorkerProxyStructuredCloneCallbacks* mCallbacks;

View File

@@ -879,12 +879,12 @@ nsresult ServiceWorkerRegistrar::ReadData() {
// XXX NOTE: if we could be accessed multi-threaded here, we would need to // XXX NOTE: if we could be accessed multi-threaded here, we would need to
// find a way to lock around access to mData. Since we can't, suppress the // find a way to lock around access to mData. Since we can't, suppress the
// thread-safety warnings. // thread-safety warnings.
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
if (overwrite && NS_FAILED(WriteData(mData))) { if (overwrite && NS_FAILED(WriteData(mData))) {
NS_WARNING("Failed to write data for the ServiceWorker Registations."); NS_WARNING("Failed to write data for the ServiceWorker Registations.");
DeleteData(); DeleteData();
} }
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
return NS_OK; return NS_OK;
} }

View File

@@ -76,7 +76,7 @@ class ServiceWorkerRegistrar : public nsIObserver,
void DeleteData(); void DeleteData();
void RegisterServiceWorkerInternal(const ServiceWorkerRegistrationData& aData) void RegisterServiceWorkerInternal(const ServiceWorkerRegistrationData& aData)
REQUIRES(mMonitor); MOZ_REQUIRES(mMonitor);
ServiceWorkerRegistrar(); ServiceWorkerRegistrar();
virtual ~ServiceWorkerRegistrar(); virtual ~ServiceWorkerRegistrar();
@@ -100,11 +100,11 @@ class ServiceWorkerRegistrar : public nsIObserver,
mozilla::Monitor mMonitor; mozilla::Monitor mMonitor;
// protected by mMonitor. // protected by mMonitor.
nsCOMPtr<nsIFile> mProfileDir GUARDED_BY(mMonitor); nsCOMPtr<nsIFile> mProfileDir MOZ_GUARDED_BY(mMonitor);
// Read on mainthread, modified on background thread EXCEPT for // Read on mainthread, modified on background thread EXCEPT for
// ReloadDataForTest() AND for gtest, which modifies this on MainThread. // ReloadDataForTest() AND for gtest, which modifies this on MainThread.
nsTArray<ServiceWorkerRegistrationData> mData GUARDED_BY(mMonitor); nsTArray<ServiceWorkerRegistrationData> mData MOZ_GUARDED_BY(mMonitor);
bool mDataLoaded GUARDED_BY(mMonitor); bool mDataLoaded MOZ_GUARDED_BY(mMonitor);
// PBackground thread only // PBackground thread only
uint32_t mDataGeneration; uint32_t mDataGeneration;

View File

@@ -37,7 +37,7 @@ class ServiceWorkerRegistrarTest : public ServiceWorkerRegistrar {
} }
nsresult TestReadData() { return ReadData(); } nsresult TestReadData() { return ReadData(); }
nsresult TestWriteData() NO_THREAD_SAFETY_ANALYSIS { nsresult TestWriteData() MOZ_NO_THREAD_SAFETY_ANALYSIS {
return WriteData(mData); return WriteData(mData);
} }
void TestDeleteData() { DeleteData(); } void TestDeleteData() { DeleteData(); }

View File

@@ -248,7 +248,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
// This mutex protects mWorkerShuttingDown. // This mutex protects mWorkerShuttingDown.
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
bool mWorkerShuttingDown GUARDED_BY(mMutex); bool mWorkerShuttingDown MOZ_GUARDED_BY(mMutex);
RefPtr<WebSocketEventService> mService; RefPtr<WebSocketEventService> mService;
nsCOMPtr<nsIPrincipal> mLoadingPrincipal; nsCOMPtr<nsIPrincipal> mLoadingPrincipal;

View File

@@ -181,7 +181,7 @@ class WebSocket final : public DOMEventTargetHelper {
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
// This value should not be used directly but use ReadyState() instead. // This value should not be used directly but use ReadyState() instead.
uint16_t mReadyState GUARDED_BY(mMutex); uint16_t mReadyState MOZ_GUARDED_BY(mMutex);
}; };
} // namespace dom } // namespace dom

View File

@@ -104,16 +104,17 @@ class JSExecutionManager {
// Workers waiting to be given permission for execution. // Workers waiting to be given permission for execution.
// Guarded by mExecutionQueueMutex. // Guarded by mExecutionQueueMutex.
std::deque<WorkerPrivate*> mExecutionQueue GUARDED_BY(mExecutionQueueMutex); std::deque<WorkerPrivate*> mExecutionQueue
MOZ_GUARDED_BY(mExecutionQueueMutex);
// Number of threads currently executing concurrently for this manager. // Number of threads currently executing concurrently for this manager.
// Guarded by mExecutionQueueMutex. // Guarded by mExecutionQueueMutex.
int32_t mRunning GUARDED_BY(mExecutionQueueMutex) = 0; int32_t mRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 0;
// Number of threads allowed to run concurrently for environments managed // Number of threads allowed to run concurrently for environments managed
// by this manager. // by this manager.
// Guarded by mExecutionQueueMutex. // Guarded by mExecutionQueueMutex.
int32_t mMaxRunning GUARDED_BY(mExecutionQueueMutex) = 1; int32_t mMaxRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 1;
// Mutex that guards the execution queue and associated state. // Mutex that guards the execution queue and associated state.
Mutex mExecutionQueueMutex = Mutex mExecutionQueueMutex =
@@ -130,7 +131,8 @@ class JSExecutionManager {
// Whether the main thread is currently awaiting permission to execute. Main // Whether the main thread is currently awaiting permission to execute. Main
// thread execution is always prioritized. // thread execution is always prioritized.
// Guarded by mExecutionQueueMutex. // Guarded by mExecutionQueueMutex.
bool mMainThreadAwaitingExecution GUARDED_BY(mExecutionQueueMutex) = false; bool mMainThreadAwaitingExecution MOZ_GUARDED_BY(mExecutionQueueMutex) =
false;
}; };
// Helper for managing execution requests and allowing re-entrant permission // Helper for managing execution requests and allowing re-entrant permission

View File

@@ -51,26 +51,26 @@ struct StorageWithTArray {
static void Compact(StorageType& aStorage) { aStorage.Compact(); } static void Compact(StorageType& aStorage) { aStorage.Compact(); }
}; };
class CAPABILITY LockingWithMutex { class MOZ_CAPABILITY LockingWithMutex {
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
protected: protected:
LockingWithMutex() : mMutex("LockingWithMutex::mMutex") {} LockingWithMutex() : mMutex("LockingWithMutex::mMutex") {}
void Lock() CAPABILITY_ACQUIRE() { mMutex.Lock(); } void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex.Lock(); }
void Unlock() CAPABILITY_RELEASE() { mMutex.Unlock(); } void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); }
class SCOPED_CAPABILITY AutoLock { class MOZ_SCOPED_CAPABILITY AutoLock {
LockingWithMutex& mHost; LockingWithMutex& mHost;
public: public:
explicit AutoLock(LockingWithMutex& aHost) CAPABILITY_ACQUIRE(aHost) explicit AutoLock(LockingWithMutex& aHost) MOZ_CAPABILITY_ACQUIRE(aHost)
: mHost(aHost) { : mHost(aHost) {
mHost.Lock(); mHost.Lock();
} }
~AutoLock() CAPABILITY_RELEASE() { mHost.Unlock(); } ~AutoLock() MOZ_CAPABILITY_RELEASE() { mHost.Unlock(); }
}; };
friend class AutoLock; friend class AutoLock;

View File

@@ -57,7 +57,7 @@ class RuntimeService final : public nsIObserver {
// Protected by mMutex. // Protected by mMutex.
nsClassHashtable<nsCStringHashKey, WorkerDomainInfo> mDomainMap nsClassHashtable<nsCStringHashKey, WorkerDomainInfo> mDomainMap
GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
// *Not* protected by mMutex. // *Not* protected by mMutex.
nsClassHashtable<nsPtrHashKey<const nsPIDOMWindowInner>, nsClassHashtable<nsPtrHashKey<const nsPIDOMWindowInner>,
@@ -181,7 +181,7 @@ class RuntimeService final : public nsIObserver {
void Cleanup(); void Cleanup();
void AddAllTopLevelWorkersToArray(nsTArray<WorkerPrivate*>& aWorkers) void AddAllTopLevelWorkersToArray(nsTArray<WorkerPrivate*>& aWorkers)
REQUIRES(mMutex); MOZ_REQUIRES(mMutex);
nsTArray<WorkerPrivate*> GetWorkersForWindow( nsTArray<WorkerPrivate*> GetWorkersForWindow(
const nsPIDOMWindowInner& aWindow) const; const nsPIDOMWindowInner& aWindow) const;

View File

@@ -32,7 +32,7 @@ class WorkerCSPEventListener final : public nsICSPEventListener {
Mutex mMutex; Mutex mMutex;
// Protected by mutex. // Protected by mutex.
RefPtr<WeakWorkerRef> mWorkerRef GUARDED_BY(mMutex); RefPtr<WeakWorkerRef> mWorkerRef MOZ_GUARDED_BY(mMutex);
}; };
} // namespace mozilla::dom } // namespace mozilla::dom

View File

@@ -28,8 +28,8 @@ class WorkerEventTarget final : public nsISerialEventTarget {
private: private:
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate GUARDED_BY(mMutex); CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate MOZ_GUARDED_BY(mMutex);
const Behavior mBehavior GUARDED_BY(mMutex); const Behavior mBehavior MOZ_GUARDED_BY(mMutex);
~WorkerEventTarget() = default; ~WorkerEventTarget() = default;

View File

@@ -663,7 +663,7 @@ class DebuggerImmediateRunnable : public WorkerRunnable {
// GetJSContext() is safe on the worker thread // GetJSContext() is safe on the worker thread
void PeriodicGCTimerCallback(nsITimer* aTimer, void PeriodicGCTimerCallback(nsITimer* aTimer,
void* aClosure) NO_THREAD_SAFETY_ANALYSIS { void* aClosure) MOZ_NO_THREAD_SAFETY_ANALYSIS {
auto* workerPrivate = static_cast<WorkerPrivate*>(aClosure); auto* workerPrivate = static_cast<WorkerPrivate*>(aClosure);
MOZ_DIAGNOSTIC_ASSERT(workerPrivate); MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
workerPrivate->AssertIsOnWorkerThread(); workerPrivate->AssertIsOnWorkerThread();
@@ -673,7 +673,7 @@ void PeriodicGCTimerCallback(nsITimer* aTimer,
} }
void IdleGCTimerCallback(nsITimer* aTimer, void IdleGCTimerCallback(nsITimer* aTimer,
void* aClosure) NO_THREAD_SAFETY_ANALYSIS { void* aClosure) MOZ_NO_THREAD_SAFETY_ANALYSIS {
auto* workerPrivate = static_cast<WorkerPrivate*>(aClosure); auto* workerPrivate = static_cast<WorkerPrivate*>(aClosure);
MOZ_DIAGNOSTIC_ASSERT(workerPrivate); MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
workerPrivate->AssertIsOnWorkerThread(); workerPrivate->AssertIsOnWorkerThread();
@@ -943,7 +943,7 @@ class WorkerPrivate::EventTarget final : public nsISerialEventTarget {
// This mutex protects mWorkerPrivate and must be acquired *before* the // This mutex protects mWorkerPrivate and must be acquired *before* the
// WorkerPrivate's mutex whenever they must both be held. // WorkerPrivate's mutex whenever they must both be held.
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
WorkerPrivate* mWorkerPrivate GUARDED_BY(mMutex); WorkerPrivate* mWorkerPrivate MOZ_GUARDED_BY(mMutex);
nsIEventTarget* mWeakNestedEventTarget; nsIEventTarget* mWeakNestedEventTarget;
nsCOMPtr<nsIEventTarget> mNestedEventTarget; nsCOMPtr<nsIEventTarget> mNestedEventTarget;
@@ -3695,7 +3695,7 @@ void WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot) {
} }
bool WorkerPrivate::CollectRuntimeStats( bool WorkerPrivate::CollectRuntimeStats(
JS::RuntimeStats* aRtStats, bool aAnonymize) NO_THREAD_SAFETY_ANALYSIS { JS::RuntimeStats* aRtStats, bool aAnonymize) MOZ_NO_THREAD_SAFETY_ANALYSIS {
// We don't have a lock to access mJSContext, but it's safe to access on this // We don't have a lock to access mJSContext, but it's safe to access on this
// thread. // thread.
AssertIsOnWorkerThread(); AssertIsOnWorkerThread();

View File

@@ -85,10 +85,10 @@ class WorkerThread;
// SharedMutex is a small wrapper around an (internal) reference-counted Mutex // SharedMutex is a small wrapper around an (internal) reference-counted Mutex
// object. It exists to avoid changing a lot of code to use Mutex* instead of // object. It exists to avoid changing a lot of code to use Mutex* instead of
// Mutex&. // Mutex&.
class CAPABILITY SharedMutex { class MOZ_CAPABILITY SharedMutex {
using Mutex = mozilla::Mutex; using Mutex = mozilla::Mutex;
class CAPABILITY RefCountedMutex final : public Mutex { class MOZ_CAPABILITY RefCountedMutex final : public Mutex {
public: public:
explicit RefCountedMutex(const char* aName) : Mutex(aName) {} explicit RefCountedMutex(const char* aName) : Mutex(aName) {}
@@ -106,17 +106,17 @@ class CAPABILITY SharedMutex {
SharedMutex(const SharedMutex& aOther) = default; SharedMutex(const SharedMutex& aOther) = default;
operator Mutex&() RETURN_CAPABILITY(this) { return *mMutex; } operator Mutex&() MOZ_RETURN_CAPABILITY(this) { return *mMutex; }
operator const Mutex&() const RETURN_CAPABILITY(this) { return *mMutex; } operator const Mutex&() const MOZ_RETURN_CAPABILITY(this) { return *mMutex; }
// We need these to make thread-safety analysis work // We need these to make thread-safety analysis work
void Lock() CAPABILITY_ACQUIRE() { mMutex->Lock(); } void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex->Lock(); }
void Unlock() CAPABILITY_RELEASE() { mMutex->Unlock(); } void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex->Unlock(); }
// We can assert we own 'this', but we can't assert we hold mMutex // We can assert we own 'this', but we can't assert we hold mMutex
void AssertCurrentThreadOwns() const void AssertCurrentThreadOwns() const
ASSERT_CAPABILITY(this) NO_THREAD_SAFETY_ANALYSIS { MOZ_ASSERT_CAPABILITY(this) MOZ_NO_THREAD_SAFETY_ANALYSIS {
mMutex->AssertCurrentThreadOwns(); mMutex->AssertCurrentThreadOwns();
} }
}; };
@@ -173,14 +173,14 @@ class WorkerPrivate final
bool Cancel() { return Notify(Canceling); } bool Cancel() { return Notify(Canceling); }
bool Close() REQUIRES(mMutex); bool Close() MOZ_REQUIRES(mMutex);
// The passed principal must be the Worker principal in case of a // The passed principal must be the Worker principal in case of a
// ServiceWorker and the loading principal for any other type. // ServiceWorker and the loading principal for any other type.
static void OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo, static void OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo,
nsIPrincipal* aPrincipal); nsIPrincipal* aPrincipal);
bool IsDebuggerRegistered() NO_THREAD_SAFETY_ANALYSIS { bool IsDebuggerRegistered() MOZ_NO_THREAD_SAFETY_ANALYSIS {
AssertIsOnMainThread(); AssertIsOnMainThread();
// No need to lock here since this is only ever modified by the same thread. // No need to lock here since this is only ever modified by the same thread.
@@ -369,7 +369,7 @@ class WorkerPrivate final
return mFetchHandlerWasAdded; return mFetchHandlerWasAdded;
} }
JSContext* GetJSContext() const NO_THREAD_SAFETY_ANALYSIS { JSContext* GetJSContext() const MOZ_NO_THREAD_SAFETY_ANALYSIS {
// mJSContext is only modified on the worker thread, so workerthread code // mJSContext is only modified on the worker thread, so workerthread code
// can safely read it without a lock // can safely read it without a lock
AssertIsOnWorkerThread(); AssertIsOnWorkerThread();
@@ -547,7 +547,7 @@ class WorkerPrivate final
return mParentStatus; return mParentStatus;
} }
WorkerStatus ParentStatus() const REQUIRES(mMutex) { WorkerStatus ParentStatus() const MOZ_REQUIRES(mMutex) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
return mParentStatus; return mParentStatus;
} }
@@ -1115,13 +1115,13 @@ class WorkerPrivate final
} }
ProcessAllControlRunnablesResult ProcessAllControlRunnablesLocked() ProcessAllControlRunnablesResult ProcessAllControlRunnablesLocked()
REQUIRES(mMutex); MOZ_REQUIRES(mMutex);
void EnableMemoryReporter(); void EnableMemoryReporter();
void DisableMemoryReporter(); void DisableMemoryReporter();
void WaitForWorkerEvents() REQUIRES(mMutex); void WaitForWorkerEvents() MOZ_REQUIRES(mMutex);
// If the worker shutdown status is equal or greater then aFailStatus, this // If the worker shutdown status is equal or greater then aFailStatus, this
// operation will fail and nullptr will be returned. See WorkerStatus.h for // operation will fail and nullptr will be returned. See WorkerStatus.h for
@@ -1158,7 +1158,8 @@ class WorkerPrivate final
// to allow runnables to be atomically dispatched in bulk. // to allow runnables to be atomically dispatched in bulk.
nsresult DispatchLockHeld(already_AddRefed<WorkerRunnable> aRunnable, nsresult DispatchLockHeld(already_AddRefed<WorkerRunnable> aRunnable,
nsIEventTarget* aSyncLoopTarget, nsIEventTarget* aSyncLoopTarget,
const MutexAutoLock& aProofOfLock) REQUIRES(mMutex); const MutexAutoLock& aProofOfLock)
MOZ_REQUIRES(mMutex);
// This method dispatches a simple runnable that starts the shutdown procedure // This method dispatches a simple runnable that starts the shutdown procedure
// after a self.close(). This method is called after a ClearMainEventQueue() // after a self.close(). This method is called after a ClearMainEventQueue()
@@ -1197,7 +1198,7 @@ class WorkerPrivate final
friend class mozilla::dom::WorkerThread; friend class mozilla::dom::WorkerThread;
SharedMutex mMutex; SharedMutex mMutex;
mozilla::CondVar mCondVar GUARDED_BY(mMutex); mozilla::CondVar mCondVar MOZ_GUARDED_BY(mMutex);
// We cannot make this CheckedUnsafePtr<WorkerPrivate> as this would violate // We cannot make this CheckedUnsafePtr<WorkerPrivate> as this would violate
// our static assert // our static assert
@@ -1231,7 +1232,7 @@ class WorkerPrivate final
LocationInfo mLocationInfo; LocationInfo mLocationInfo;
// Protected by mMutex. // Protected by mMutex.
workerinternals::JSSettings mJSSettings GUARDED_BY(mMutex); workerinternals::JSSettings mJSSettings MOZ_GUARDED_BY(mMutex);
WorkerDebugger* mDebugger; WorkerDebugger* mDebugger;
@@ -1240,9 +1241,9 @@ class WorkerPrivate final
// Touched on multiple threads, protected with mMutex. Only modified on the // Touched on multiple threads, protected with mMutex. Only modified on the
// worker thread // worker thread
JSContext* mJSContext GUARDED_BY(mMutex); JSContext* mJSContext MOZ_GUARDED_BY(mMutex);
// mThread is only modified on the Worker thread, before calling DoRunLoop // mThread is only modified on the Worker thread, before calling DoRunLoop
RefPtr<WorkerThread> mThread GUARDED_BY(mMutex); RefPtr<WorkerThread> mThread MOZ_GUARDED_BY(mMutex);
// mPRThread is only modified on another thread in ScheduleWorker(), and is // mPRThread is only modified on another thread in ScheduleWorker(), and is
// constant for the duration of DoRunLoop. Static mutex analysis doesn't help // constant for the duration of DoRunLoop. Static mutex analysis doesn't help
// here // here
@@ -1286,7 +1287,7 @@ class WorkerPrivate final
RefPtr<WorkerCSPEventListener> mCSPEventListener; RefPtr<WorkerCSPEventListener> mCSPEventListener;
// Protected by mMutex. // Protected by mMutex.
nsTArray<RefPtr<WorkerRunnable>> mPreStartRunnables GUARDED_BY(mMutex); nsTArray<RefPtr<WorkerRunnable>> mPreStartRunnables MOZ_GUARDED_BY(mMutex);
// Only touched on the parent thread. This is set only if IsSharedWorker(). // Only touched on the parent thread. This is set only if IsSharedWorker().
RefPtr<RemoteWorkerChild> mRemoteWorkerController; RefPtr<RemoteWorkerChild> mRemoteWorkerController;
@@ -1296,8 +1297,8 @@ class WorkerPrivate final
JS::UniqueChars mDefaultLocale; // nulled during worker JSContext init JS::UniqueChars mDefaultLocale; // nulled during worker JSContext init
TimeStamp mKillTime; TimeStamp mKillTime;
WorkerStatus mParentStatus GUARDED_BY(mMutex); WorkerStatus mParentStatus MOZ_GUARDED_BY(mMutex);
WorkerStatus mStatus GUARDED_BY(mMutex); WorkerStatus mStatus MOZ_GUARDED_BY(mMutex);
// This is touched on parent thread only, but it can be read on a different // This is touched on parent thread only, but it can be read on a different
// thread before crashing because hanging. // thread before crashing because hanging.
@@ -1430,7 +1431,7 @@ class WorkerPrivate final
// use our global object's secure state there. // use our global object's secure state there.
const bool mIsSecureContext; const bool mIsSecureContext;
bool mDebuggerRegistered GUARDED_BY(mMutex); bool mDebuggerRegistered MOZ_GUARDED_BY(mMutex);
// During registration, this worker may be marked as not being ready to // During registration, this worker may be marked as not being ready to
// execute debuggee runnables or content. // execute debuggee runnables or content.

View File

@@ -117,7 +117,7 @@ class ArrayBufferBuilder {
ArrayBufferBuilder& operator=(const ArrayBufferBuilder&&) = delete; ArrayBufferBuilder& operator=(const ArrayBufferBuilder&&) = delete;
bool SetCapacityInternal(uint32_t aNewCap, const MutexAutoLock& aProofOfLock) bool SetCapacityInternal(uint32_t aNewCap, const MutexAutoLock& aProofOfLock)
REQUIRES(mMutex); MOZ_REQUIRES(mMutex);
static bool AreOverlappingRegions(const uint8_t* aStart1, uint32_t aLength1, static bool AreOverlappingRegions(const uint8_t* aStart1, uint32_t aLength1,
const uint8_t* aStart2, uint32_t aLength2); const uint8_t* aStart2, uint32_t aLength2);
@@ -125,10 +125,10 @@ class ArrayBufferBuilder {
Mutex mMutex; Mutex mMutex;
// All of these are protected by mMutex. // All of these are protected by mMutex.
uint8_t* mDataPtr GUARDED_BY(mMutex); uint8_t* mDataPtr MOZ_GUARDED_BY(mMutex);
uint32_t mCapacity GUARDED_BY(mMutex); uint32_t mCapacity MOZ_GUARDED_BY(mMutex);
uint32_t mLength GUARDED_BY(mMutex); uint32_t mLength MOZ_GUARDED_BY(mMutex);
void* mMapPtr GUARDED_BY(mMutex); void* mMapPtr MOZ_GUARDED_BY(mMutex);
// This is used in assertions only. // This is used in assertions only.
bool mNeutered; bool mNeutered;

View File

@@ -25,12 +25,12 @@ class XMLHttpRequestStringBuffer final {
return mData.Length(); return mData.Length();
} }
uint32_t UnsafeLength() const NO_THREAD_SAFETY_ANALYSIS { uint32_t UnsafeLength() const MOZ_NO_THREAD_SAFETY_ANALYSIS {
return mData.Length(); return mData.Length();
} }
mozilla::Result<mozilla::BulkWriteHandle<char16_t>, nsresult> UnsafeBulkWrite( mozilla::Result<mozilla::BulkWriteHandle<char16_t>, nsresult> UnsafeBulkWrite(
uint32_t aCapacity) NO_THREAD_SAFETY_ANALYSIS { uint32_t aCapacity) MOZ_NO_THREAD_SAFETY_ANALYSIS {
return mData.BulkWrite(aCapacity, UnsafeLength(), false); return mData.BulkWrite(aCapacity, UnsafeLength(), false);
} }
@@ -86,7 +86,7 @@ class XMLHttpRequestStringBuffer final {
Mutex mMutex; Mutex mMutex;
// The following member variable is protected by mutex. // The following member variable is protected by mutex.
nsString mData GUARDED_BY(mMutex); nsString mData MOZ_GUARDED_BY(mMutex);
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -1092,11 +1092,11 @@ class SharedFTFace : public external::AtomicRefCounted<SharedFTFace> {
* If no owner is given, then the user should avoid modifying any state on * If no owner is given, then the user should avoid modifying any state on
* the face so as not to invalidate the prior owner's modification. * the face so as not to invalidate the prior owner's modification.
*/ */
bool Lock(const void* aOwner = nullptr) CAPABILITY_ACQUIRE(mLock) { bool Lock(const void* aOwner = nullptr) MOZ_CAPABILITY_ACQUIRE(mLock) {
mLock.Lock(); mLock.Lock();
return !aOwner || mLastLockOwner.exchange(aOwner) == aOwner; return !aOwner || mLastLockOwner.exchange(aOwner) == aOwner;
} }
void Unlock() CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } void Unlock() MOZ_CAPABILITY_RELEASE(mLock) { mLock.Unlock(); }
/** Should be called when a lock owner is destroyed so that we don't have /** Should be called when a lock owner is destroyed so that we don't have
* a dangling pointer to a destroyed owner. * a dangling pointer to a destroyed owner.

View File

@@ -172,11 +172,11 @@ void mozilla_ForgetSharedFTFaceLockOwner(void* aContext, void* aOwner) {
} }
int mozilla_LockSharedFTFace(void* aContext, int mozilla_LockSharedFTFace(void* aContext,
void* aOwner) NO_THREAD_SAFETY_ANALYSIS { void* aOwner) MOZ_NO_THREAD_SAFETY_ANALYSIS {
return int(static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Lock(aOwner)); return int(static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Lock(aOwner));
} }
void mozilla_UnlockSharedFTFace(void* aContext) NO_THREAD_SAFETY_ANALYSIS { void mozilla_UnlockSharedFTFace(void* aContext) MOZ_NO_THREAD_SAFETY_ANALYSIS {
static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Unlock(); static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Unlock();
} }
@@ -624,12 +624,12 @@ void Factory::ReleaseFTLibrary(FT_Library aFTLibrary) {
} }
void Factory::LockFTLibrary(FT_Library aFTLibrary) void Factory::LockFTLibrary(FT_Library aFTLibrary)
CAPABILITY_ACQUIRE(mFTLock) NO_THREAD_SAFETY_ANALYSIS { MOZ_CAPABILITY_ACQUIRE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS {
mFTLock.Lock(); mFTLock.Lock();
} }
void Factory::UnlockFTLibrary(FT_Library aFTLibrary) void Factory::UnlockFTLibrary(FT_Library aFTLibrary)
CAPABILITY_RELEASE(mFTLock) NO_THREAD_SAFETY_ANALYSIS { MOZ_CAPABILITY_RELEASE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS {
mFTLock.Unlock(); mFTLock.Unlock();
} }

View File

@@ -159,7 +159,7 @@ uint8_t* SourceSurfaceSkia::GetData() {
} }
bool SourceSurfaceSkia::Map(MapType, MappedSurface* aMappedSurface) bool SourceSurfaceSkia::Map(MapType, MappedSurface* aMappedSurface)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
mChangeMutex.Lock(); mChangeMutex.Lock();
aMappedSurface->mData = GetData(); aMappedSurface->mData = GetData();
aMappedSurface->mStride = Stride(); aMappedSurface->mStride = Stride();
@@ -169,12 +169,12 @@ bool SourceSurfaceSkia::Map(MapType, MappedSurface* aMappedSurface)
mChangeMutex.Unlock(); mChangeMutex.Unlock();
} }
// Static analysis will warn due to a conditional Unlock // Static analysis will warn due to a conditional Unlock
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
return isMapped; return isMapped;
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
} }
void SourceSurfaceSkia::Unmap() NO_THREAD_SAFETY_ANALYSIS { void SourceSurfaceSkia::Unmap() MOZ_NO_THREAD_SAFETY_ANALYSIS {
mChangeMutex.AssertCurrentThreadOwns(); mChangeMutex.AssertCurrentThreadOwns();
MOZ_ASSERT(mIsMapped); MOZ_ASSERT(mIsMapped);
mIsMapped = false; mIsMapped = false;

View File

@@ -140,7 +140,7 @@ class GLLibraryEGL final {
~GLLibraryEGL() = default; ~GLLibraryEGL() = default;
static StaticMutex sMutex; static StaticMutex sMutex;
static StaticRefPtr<GLLibraryEGL> sInstance GUARDED_BY(sMutex); static StaticRefPtr<GLLibraryEGL> sInstance MOZ_GUARDED_BY(sMutex);
bool Init(nsACString* const out_failureId); bool Init(nsACString* const out_failureId);
void InitLibExtensions(); void InitLibExtensions();

View File

@@ -3665,7 +3665,7 @@ void APZCTreeManager::AssertOnUpdaterThread() {
GetUpdater()->AssertOnUpdaterThread(); GetUpdater()->AssertOnUpdaterThread();
} }
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
void APZCTreeManager::LockTree() { void APZCTreeManager::LockTree() {
AssertOnUpdaterThread(); AssertOnUpdaterThread();
mTreeLock.Lock(); mTreeLock.Lock();
@@ -3675,7 +3675,7 @@ void APZCTreeManager::UnlockTree() {
AssertOnUpdaterThread(); AssertOnUpdaterThread();
mTreeLock.Unlock(); mTreeLock.Unlock();
} }
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
void APZCTreeManager::SetDPI(float aDpiValue) { void APZCTreeManager::SetDPI(float aDpiValue) {
if (!APZThreadUtils::IsControllerThread()) { if (!APZThreadUtils::IsControllerThread()) {

View File

@@ -507,8 +507,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
// functions to the world. // functions to the world.
private: private:
friend class APZUpdater; friend class APZUpdater;
void LockTree() CAPABILITY_ACQUIRE(mTreeLock); void LockTree() MOZ_CAPABILITY_ACQUIRE(mTreeLock);
void UnlockTree() CAPABILITY_RELEASE(mTreeLock); void UnlockTree() MOZ_CAPABILITY_RELEASE(mTreeLock);
// Protected hooks for gtests subclass // Protected hooks for gtests subclass
virtual AsyncPanZoomController* NewAPZCInstance( virtual AsyncPanZoomController* NewAPZCInstance(
@@ -591,7 +591,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
/* Helpers */ /* Helpers */
void AttachNodeToTree(HitTestingTreeNode* aNode, HitTestingTreeNode* aParent, void AttachNodeToTree(HitTestingTreeNode* aNode, HitTestingTreeNode* aParent,
HitTestingTreeNode* aNextSibling) REQUIRES(mTreeLock); HitTestingTreeNode* aNextSibling)
MOZ_REQUIRES(mTreeLock);
already_AddRefed<AsyncPanZoomController> GetTargetAPZC( already_AddRefed<AsyncPanZoomController> GetTargetAPZC(
const ScrollableLayerGuid& aGuid); const ScrollableLayerGuid& aGuid);
already_AddRefed<HitTestingTreeNode> GetTargetNode( already_AddRefed<HitTestingTreeNode> GetTargetNode(
@@ -730,7 +731,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
// the coordinates of |aNode|'s parent in the hit-testing tree. // the coordinates of |aNode|'s parent in the hit-testing tree.
// Requires the caller to hold mTreeLock. // Requires the caller to hold mTreeLock.
LayerToParentLayerMatrix4x4 ComputeTransformForNode( LayerToParentLayerMatrix4x4 ComputeTransformForNode(
const HitTestingTreeNode* aNode) const REQUIRES(mTreeLock); const HitTestingTreeNode* aNode) const MOZ_REQUIRES(mTreeLock);
// Look up the GeckoContentController for the given layers id. // Look up the GeckoContentController for the given layers id.
static already_AddRefed<GeckoContentController> GetContentController( static already_AddRefed<GeckoContentController> GetContentController(
@@ -787,7 +788,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
* management state. * management state.
* IMPORTANT: See the note about lock ordering at the top of this file. */ * IMPORTANT: See the note about lock ordering at the top of this file. */
mutable mozilla::RecursiveMutex mTreeLock; mutable mozilla::RecursiveMutex mTreeLock;
RefPtr<HitTestingTreeNode> mRootNode GUARDED_BY(mTreeLock); RefPtr<HitTestingTreeNode> mRootNode MOZ_GUARDED_BY(mTreeLock);
/* /*
* A set of LayersIds for which APZCTM should only send empty * A set of LayersIds for which APZCTM should only send empty
@@ -799,7 +800,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
* Acquire mTreeLock before accessing this. * Acquire mTreeLock before accessing this.
*/ */
std::unordered_set<LayersId, LayersId::HashFn> mDetachedLayersIds std::unordered_set<LayersId, LayersId::HashFn> mDetachedLayersIds
GUARDED_BY(mTreeLock); MOZ_GUARDED_BY(mTreeLock);
/* If the current hit-testing tree contains an async zoom container /* If the current hit-testing tree contains an async zoom container
* node, this is set to the layers id of subtree that has the node. * node, this is set to the layers id of subtree that has the node.

View File

@@ -73,7 +73,7 @@ void APZUpdater::SetUpdaterThread(const wr::WrWindowId& aWindowId) {
// Takes a conditional lock! // Takes a conditional lock!
/*static*/ /*static*/
void APZUpdater::PrepareForSceneSwap(const wr::WrWindowId& aWindowId) void APZUpdater::PrepareForSceneSwap(const wr::WrWindowId& aWindowId)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
if (RefPtr<APZUpdater> updater = GetUpdater(aWindowId)) { if (RefPtr<APZUpdater> updater = GetUpdater(aWindowId)) {
updater->mApz->LockTree(); updater->mApz->LockTree();
} }

View File

@@ -272,7 +272,7 @@ class CanvasTranslator final : public gfx::InlineTranslator,
UniquePtr<gfx::DataSourceSurface::ScopedMap> mPreparedMap; UniquePtr<gfx::DataSourceSurface::ScopedMap> mPreparedMap;
typedef std::unordered_map<int64_t, UniquePtr<SurfaceDescriptor>> typedef std::unordered_map<int64_t, UniquePtr<SurfaceDescriptor>>
DescriptorMap; DescriptorMap;
DescriptorMap mSurfaceDescriptors GUARDED_BY(mSurfaceDescriptorsMonitor); DescriptorMap mSurfaceDescriptors MOZ_GUARDED_BY(mSurfaceDescriptorsMonitor);
Monitor mSurfaceDescriptorsMonitor{ Monitor mSurfaceDescriptorsMonitor{
"CanvasTranslator::mSurfaceDescriptorsMonitor"}; "CanvasTranslator::mSurfaceDescriptorsMonitor"};
Atomic<bool> mDeactivated{false}; Atomic<bool> mDeactivated{false};

View File

@@ -64,7 +64,7 @@ class gfxDWriteFontFamily final : public gfxFontFamily {
virtual ~gfxDWriteFontFamily(); virtual ~gfxDWriteFontFamily();
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
REQUIRES(mLock) final; MOZ_REQUIRES(mLock) final;
void LocalizedName(nsACString& aLocalizedName) final; void LocalizedName(nsACString& aLocalizedName) final;
@@ -376,8 +376,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
} }
// initialize font lists // initialize font lists
nsresult InitFontListForPlatform() REQUIRES(mLock) override; nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
void InitSharedFontListForPlatform() REQUIRES(mLock) override; void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
FontVisibility GetVisibilityForFamily(const nsACString& aName) const; FontVisibility GetVisibilityForFamily(const nsACString& aName) const;
@@ -390,7 +390,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily,
bool aNeedFullnamePostscriptNames) bool aNeedFullnamePostscriptNames)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
bool ReadFaceNames(mozilla::fontlist::Family* aFamily, bool ReadFaceNames(mozilla::fontlist::Family* aFamily,
mozilla::fontlist::Face* aFace, nsCString& aPSName, mozilla::fontlist::Face* aFace, nsCString& aPSName,
@@ -422,7 +422,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput, const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
gfxFloat GetForceGDIClassicMaxFontSize() { gfxFloat GetForceGDIClassicMaxFontSize() {
return mForceGDIClassicMaxFontSize; return mForceGDIClassicMaxFontSize;
@@ -437,7 +437,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
// attempt to use platform-specific fallback for the given character, // attempt to use platform-specific fallback for the given character,
// return null if no usable result found // return null if no usable result found
@@ -446,24 +446,25 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
Script aRunScript, Script aRunScript,
const gfxFontStyle* aMatchStyle, const gfxFontStyle* aMatchStyle,
FontFamily& aMatchedFamily) FontFamily& aMatchedFamily)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
private: private:
friend class gfxDWriteFontFamily; friend class gfxDWriteFontFamily;
nsresult GetFontSubstitutes() REQUIRES(mLock); nsresult GetFontSubstitutes() MOZ_REQUIRES(mLock);
void GetDirectWriteSubstitutes() REQUIRES(mLock); void GetDirectWriteSubstitutes() MOZ_REQUIRES(mLock);
virtual bool UsesSystemFallback() { return true; } virtual bool UsesSystemFallback() { return true; }
void GetFontsFromCollection(IDWriteFontCollection* aCollection) void GetFontsFromCollection(IDWriteFontCollection* aCollection)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
void AppendFamiliesFromCollection( void AppendFamiliesFromCollection(
IDWriteFontCollection* aCollection, IDWriteFontCollection* aCollection,
nsTArray<mozilla::fontlist::Family::InitData>& aFamilies, nsTArray<mozilla::fontlist::Family::InitData>& aFamilies,
const nsTArray<nsCString>* aForceClassicFams = nullptr) REQUIRES(mLock); const nsTArray<nsCString>* aForceClassicFams = nullptr)
MOZ_REQUIRES(mLock);
#ifdef MOZ_BUNDLED_FONTS #ifdef MOZ_BUNDLED_FONTS
already_AddRefed<IDWriteFontCollection> CreateBundledFontsCollection( already_AddRefed<IDWriteFontCollection> CreateBundledFontsCollection(

View File

@@ -43,7 +43,7 @@ gfxFT2FontBase::gfxFT2FontBase(
gfxFT2FontBase::~gfxFT2FontBase() { mFTFace->ForgetLockOwner(this); } gfxFT2FontBase::~gfxFT2FontBase() { mFTFace->ForgetLockOwner(this); }
FT_Face gfxFT2FontBase::LockFTFace() const FT_Face gfxFT2FontBase::LockFTFace() const
CAPABILITY_ACQUIRE(mFTFace) NO_THREAD_SAFETY_ANALYSIS { MOZ_CAPABILITY_ACQUIRE(mFTFace) MOZ_NO_THREAD_SAFETY_ANALYSIS {
if (!mFTFace->Lock(this)) { if (!mFTFace->Lock(this)) {
FT_Set_Transform(mFTFace->GetFace(), nullptr, nullptr); FT_Set_Transform(mFTFace->GetFace(), nullptr, nullptr);
@@ -54,7 +54,7 @@ FT_Face gfxFT2FontBase::LockFTFace() const
} }
void gfxFT2FontBase::UnlockFTFace() const void gfxFT2FontBase::UnlockFTFace() const
CAPABILITY_RELEASE(mFTFace) NO_THREAD_SAFETY_ANALYSIS { MOZ_CAPABILITY_RELEASE(mFTFace) MOZ_NO_THREAD_SAFETY_ANALYSIS {
mFTFace->Unlock(); mFTFace->Unlock();
} }

View File

@@ -36,7 +36,7 @@ class gfxFT2FontEntryBase : public gfxFontEntry {
uint32_t mGlyphIndex; uint32_t mGlyphIndex;
}; };
mozilla::UniquePtr<CmapCacheSlot[]> mCmapCache GUARDED_BY(mLock); mozilla::UniquePtr<CmapCacheSlot[]> mCmapCache MOZ_GUARDED_BY(mLock);
}; };
class gfxFT2FontBase : public gfxFont { class gfxFT2FontBase : public gfxFont {
@@ -147,7 +147,7 @@ class gfxFT2FontBase : public gfxFont {
uint16_t aGID, mozilla::gfx::IntRect* aBounds = nullptr) const; uint16_t aGID, mozilla::gfx::IntRect* aBounds = nullptr) const;
mutable mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, GlyphMetrics>> mutable mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, GlyphMetrics>>
mGlyphMetrics GUARDED_BY(mLock); mGlyphMetrics MOZ_GUARDED_BY(mLock);
}; };
// Helper classes used for clearing out user font data when FT font // Helper classes used for clearing out user font data when FT font

View File

@@ -174,26 +174,26 @@ class gfxFT2FontList final : public gfxPlatformFontList {
typedef enum { kUnknown, kStandard } StandardFile; typedef enum { kUnknown, kStandard } StandardFile;
// initialize font lists // initialize font lists
nsresult InitFontListForPlatform() REQUIRES(mLock) override; nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
void AppendFaceFromFontListEntry(const FontListEntry& aFLE, void AppendFaceFromFontListEntry(const FontListEntry& aFLE,
StandardFile aStdFile) REQUIRES(mLock); StandardFile aStdFile) MOZ_REQUIRES(mLock);
void AppendFacesFromBlob(const nsCString& aFileName, StandardFile aStdFile, void AppendFacesFromBlob(const nsCString& aFileName, StandardFile aStdFile,
hb_blob_t* aBlob, FontNameCache* aCache, hb_blob_t* aBlob, FontNameCache* aCache,
uint32_t aTimestamp, uint32_t aFilesize) uint32_t aTimestamp, uint32_t aFilesize)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
void AppendFacesFromFontFile(const nsCString& aFileName, void AppendFacesFromFontFile(const nsCString& aFileName,
FontNameCache* aCache, StandardFile aStdFile) FontNameCache* aCache, StandardFile aStdFile)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
void AppendFacesFromOmnijarEntry(nsZipArchive* aReader, void AppendFacesFromOmnijarEntry(nsZipArchive* aReader,
const nsCString& aEntryName, const nsCString& aEntryName,
FontNameCache* aCache, bool aJarChanged) FontNameCache* aCache, bool aJarChanged)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
void InitSharedFontListForPlatform() REQUIRES(mLock) override; void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
void CollectInitData(const FontListEntry& aFLE, const nsCString& aPSName, void CollectInitData(const FontListEntry& aFLE, const nsCString& aPSName,
const nsCString& aFullName, StandardFile aStdFile); const nsCString& aFullName, StandardFile aStdFile);
@@ -217,23 +217,23 @@ class gfxFT2FontList final : public gfxPlatformFontList {
bool AppendFacesFromCachedFaceList(CollectFunc aCollectFace, bool AppendFacesFromCachedFaceList(CollectFunc aCollectFace,
const nsCString& aFileName, const nsCString& aFileName,
const nsCString& aFaceList, const nsCString& aFaceList,
StandardFile aStdFile) REQUIRES(mLock); StandardFile aStdFile) MOZ_REQUIRES(mLock);
void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex,
StandardFile aStdFile, hb_face_t* aFace, StandardFile aStdFile, hb_face_t* aFace,
nsCString& aFaceList) REQUIRES(mLock); nsCString& aFaceList) MOZ_REQUIRES(mLock);
void FindFonts() REQUIRES(mLock); void FindFonts() MOZ_REQUIRES(mLock);
void FindFontsInOmnijar(FontNameCache* aCache) REQUIRES(mLock); void FindFontsInOmnijar(FontNameCache* aCache) MOZ_REQUIRES(mLock);
void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC) void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
nsTHashSet<nsCString> mSkipSpaceLookupCheckFamilies; nsTHashSet<nsCString> mSkipSpaceLookupCheckFamilies;

View File

@@ -176,7 +176,7 @@ class gfxFontconfigFontFamily final : public gfxFontFamily {
void AddFacesToFontList(Func aAddPatternFunc); void AddFacesToFontList(Func aAddPatternFunc);
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
// Families are constructed initially with just references to patterns. // Families are constructed initially with just references to patterns.
// When necessary, these are enumerated within FindStyleVariations. // When necessary, these are enumerated within FindStyleVariations.
@@ -245,8 +245,8 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
} }
// initialize font lists // initialize font lists
nsresult InitFontListForPlatform() REQUIRES(mLock) override; nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
void InitSharedFontListForPlatform() REQUIRES(mLock) override; void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
void GetFontList(nsAtom* aLangGroup, const nsACString& aGenericFamily, void GetFontList(nsAtom* aLangGroup, const nsACString& aGenericFamily,
nsTArray<nsString>& aListOfFonts) override; nsTArray<nsString>& aListOfFonts) override;
@@ -275,7 +275,7 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput, const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
bool GetStandardFamilyName(const nsCString& aFontName, bool GetStandardFamilyName(const nsCString& aFontName,
nsACString& aFamilyName) override; nsACString& aFamilyName) override;
@@ -287,14 +287,14 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
mozilla::StyleGenericFontFamily, nsAtom* aLanguage, mozilla::StyleGenericFontFamily, nsAtom* aLanguage,
nsTArray<FamilyAndGeneric>& aFamilyList) override; nsTArray<FamilyAndGeneric>& aFamilyList) override;
void ClearLangGroupPrefFontsLocked() REQUIRES(mLock) override; void ClearLangGroupPrefFontsLocked() MOZ_REQUIRES(mLock) override;
// clear out cached generic-lang ==> family-list mappings // clear out cached generic-lang ==> family-list mappings
void ClearGenericMappings() { void ClearGenericMappings() {
AutoLock lock(mLock); AutoLock lock(mLock);
ClearGenericMappingsLocked(); ClearGenericMappingsLocked();
} }
void ClearGenericMappingsLocked() REQUIRES(mLock) { void ClearGenericMappingsLocked() MOZ_REQUIRES(mLock) {
mGenericMappings.Clear(); mGenericMappings.Clear();
} }
@@ -318,29 +318,29 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
// Add all the font families found in a font set. // Add all the font families found in a font set.
// aAppFonts indicates whether this is the system or application fontset. // aAppFonts indicates whether this is the system or application fontset.
void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy, void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy,
bool aAppFonts) REQUIRES(mLock); bool aAppFonts) MOZ_REQUIRES(mLock);
// Helper for above, to add a single font pattern. // Helper for above, to add a single font pattern.
void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName, void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName,
nsACString& aFamilyName, nsACString& aFamilyName,
RefPtr<gfxFontconfigFontFamily>& aFontFamily, RefPtr<gfxFontconfigFontFamily>& aFontFamily,
bool aAppFonts) REQUIRES(mLock); bool aAppFonts) MOZ_REQUIRES(mLock);
// figure out which families fontconfig maps a generic to // figure out which families fontconfig maps a generic to
// (aGeneric assumed already lowercase) // (aGeneric assumed already lowercase)
PrefFontList* FindGenericFamilies(nsPresContext* aPresContext, PrefFontList* FindGenericFamilies(nsPresContext* aPresContext,
const nsCString& aGeneric, const nsCString& aGeneric,
nsAtom* aLanguage) REQUIRES(mLock); nsAtom* aLanguage) MOZ_REQUIRES(mLock);
// are all pref font settings set to use fontconfig generics? // are all pref font settings set to use fontconfig generics?
bool PrefFontListsUseOnlyGenerics() REQUIRES(mLock); bool PrefFontListsUseOnlyGenerics() MOZ_REQUIRES(mLock);
static void CheckFontUpdates(nsITimer* aTimer, void* aThis); static void CheckFontUpdates(nsITimer* aTimer, void* aThis);
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
enum class DistroID : int8_t { enum class DistroID : int8_t {
Unknown = 0, Unknown = 0,

View File

@@ -392,7 +392,7 @@ class gfxFontCache final
// This gets called when the timeout has expired on a single-refcount // This gets called when the timeout has expired on a single-refcount
// font; we just delete it. // font; we just delete it.
void NotifyExpiredLocked(gfxFont* aFont, const AutoLock&) void NotifyExpiredLocked(gfxFont* aFont, const AutoLock&)
REQUIRES(mMutex) override; MOZ_REQUIRES(mMutex) override;
void NotifyHandlerEnd() override; void NotifyHandlerEnd() override;
void DestroyDiscard(nsTArray<RefPtr<gfxFont>>& aDiscard); void DestroyDiscard(nsTArray<RefPtr<gfxFont>>& aDiscard);
@@ -440,13 +440,13 @@ class gfxFontCache final
RefPtr<gfxFont> mFont; RefPtr<gfxFont> mFont;
}; };
nsTHashtable<HashEntry> mFonts GUARDED_BY(mMutex); nsTHashtable<HashEntry> mFonts MOZ_GUARDED_BY(mMutex);
nsTArray<RefPtr<gfxFont>> mTrackerDiscard GUARDED_BY(mMutex); nsTArray<RefPtr<gfxFont>> mTrackerDiscard MOZ_GUARDED_BY(mMutex);
static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache); static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
nsCOMPtr<nsITimer> mWordCacheExpirationTimer GUARDED_BY(mMutex); nsCOMPtr<nsITimer> mWordCacheExpirationTimer MOZ_GUARDED_BY(mMutex);
std::atomic<bool> mTimerRunning = false; std::atomic<bool> mTimerRunning = false;
}; };
@@ -1826,7 +1826,7 @@ class gfxFont {
ClearCachedWordsLocked(); ClearCachedWordsLocked();
} }
} }
void ClearCachedWordsLocked() REQUIRES(mLock) { void ClearCachedWordsLocked() MOZ_REQUIRES(mLock) {
MOZ_ASSERT(mWordCache); MOZ_ASSERT(mWordCache);
mWordCache->Clear(); mWordCache->Clear();
} }
@@ -2145,14 +2145,15 @@ class gfxFont {
mozilla::UniquePtr<gfxShapedWord> mShapedWord; mozilla::UniquePtr<gfxShapedWord> mShapedWord;
}; };
mozilla::UniquePtr<nsTHashtable<CacheHashEntry>> mWordCache GUARDED_BY(mLock); mozilla::UniquePtr<nsTHashtable<CacheHashEntry>> mWordCache
MOZ_GUARDED_BY(mLock);
static const uint32_t kShapedWordCacheMaxAge = 3; static const uint32_t kShapedWordCacheMaxAge = 3;
nsTArray<mozilla::UniquePtr<gfxGlyphExtents>> mGlyphExtentsArray nsTArray<mozilla::UniquePtr<gfxGlyphExtents>> mGlyphExtentsArray
GUARDED_BY(mLock); MOZ_GUARDED_BY(mLock);
mozilla::UniquePtr<nsTHashSet<GlyphChangeObserver*>> mGlyphChangeObservers mozilla::UniquePtr<nsTHashSet<GlyphChangeObserver*>> mGlyphChangeObservers
GUARDED_BY(mLock); MOZ_GUARDED_BY(mLock);
// a copy of the font without antialiasing, if needed for separate // a copy of the font without antialiasing, if needed for separate
// measurement by mathml code // measurement by mathml code

View File

@@ -520,7 +520,7 @@ hb_blob_t* gfxFontEntry::FontTableHashEntry::GetBlob() const {
bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) { bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) {
// Accessing the mFontTableCache pointer is atomic, so we don't need to take // Accessing the mFontTableCache pointer is atomic, so we don't need to take
// a write lock even if we're initializing it here... // a write lock even if we're initializing it here...
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
if (MOZ_UNLIKELY(!mFontTableCache)) { if (MOZ_UNLIKELY(!mFontTableCache)) {
// We do this here rather than on fontEntry construction // We do this here rather than on fontEntry construction
// because not all shapers will access the table cache at all. // because not all shapers will access the table cache at all.
@@ -533,7 +533,7 @@ bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) {
} }
} }
FontTableCache* cache = GetFontTableCache(); FontTableCache* cache = GetFontTableCache();
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
// ...but we do need a lock to read the actual hashtable contents. // ...but we do need a lock to read the actual hashtable contents.
AutoReadLock lock(mLock); AutoReadLock lock(mLock);
@@ -548,7 +548,7 @@ bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) {
hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag, hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
nsTArray<uint8_t>* aBuffer) { nsTArray<uint8_t>* aBuffer) {
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
if (MOZ_UNLIKELY(!mFontTableCache)) { if (MOZ_UNLIKELY(!mFontTableCache)) {
auto* newCache = new FontTableCache(8); auto* newCache = new FontTableCache(8);
if (MOZ_UNLIKELY(!mFontTableCache.compareExchange(nullptr, newCache))) { if (MOZ_UNLIKELY(!mFontTableCache.compareExchange(nullptr, newCache))) {
@@ -556,7 +556,7 @@ hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
} }
} }
FontTableCache* cache = GetFontTableCache(); FontTableCache* cache = GetFontTableCache();
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
AutoWriteLock lock(mLock); AutoWriteLock lock(mLock);
FontTableHashEntry* entry = cache->PutEntry(aTag); FontTableHashEntry* entry = cache->PutEntry(aTag);

View File

@@ -492,14 +492,14 @@ class gfxFontEntry {
gfxSVGGlyphs* GetSVGGlyphs() const { return mSVGGlyphs; } gfxSVGGlyphs* GetSVGGlyphs() const { return mSVGGlyphs; }
// list of gfxFonts that are using SVG glyphs // list of gfxFonts that are using SVG glyphs
nsTArray<const gfxFont*> mFontsUsingSVGGlyphs GUARDED_BY(mLock); nsTArray<const gfxFont*> mFontsUsingSVGGlyphs MOZ_GUARDED_BY(mLock);
nsTArray<gfxFontFeature> mFeatureSettings; nsTArray<gfxFontFeature> mFeatureSettings;
nsTArray<gfxFontVariation> mVariationSettings; nsTArray<gfxFontVariation> mVariationSettings;
mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, bool>> mSupportedFeatures mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, bool>> mSupportedFeatures
GUARDED_BY(mFeatureInfoLock); MOZ_GUARDED_BY(mFeatureInfoLock);
mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, hb_set_t*>> mFeatureInputs mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, hb_set_t*>> mFeatureInputs
GUARDED_BY(mFeatureInfoLock); MOZ_GUARDED_BY(mFeatureInfoLock);
// Color Layer font support. These tables are inert once loaded, so we don't // Color Layer font support. These tables are inert once loaded, so we don't
// need to hold a lock when reading them. // need to hold a lock when reading them.
@@ -615,7 +615,7 @@ class gfxFontEntry {
// Helper for HasTrackingTable; check/parse the table and cache pointers // Helper for HasTrackingTable; check/parse the table and cache pointers
// to the subtables we need. Returns false on failure, in which case the // to the subtables we need. Returns false on failure, in which case the
// table is unusable. // table is unusable.
bool ParseTrakTable() REQUIRES(mLock); bool ParseTrakTable() MOZ_REQUIRES(mLock);
// lookup the cmap in cached font data // lookup the cmap in cached font data
virtual already_AddRefed<gfxCharacterMap> GetCMAPFromFontInfo( virtual already_AddRefed<gfxCharacterMap> GetCMAPFromFontInfo(
@@ -862,11 +862,12 @@ class gfxFontFamily {
bool CheckForLegacyFamilyNames(gfxPlatformFontList* aFontList); bool CheckForLegacyFamilyNames(gfxPlatformFontList* aFontList);
// Callers must hold a read-lock for as long as they're using the list. // Callers must hold a read-lock for as long as they're using the list.
const nsTArray<RefPtr<gfxFontEntry>>& GetFontList() REQUIRES_SHARED(mLock) { const nsTArray<RefPtr<gfxFontEntry>>& GetFontList()
MOZ_REQUIRES_SHARED(mLock) {
return mAvailableFonts; return mAvailableFonts;
} }
void ReadLock() ACQUIRE_SHARED(mLock) { mLock.ReadLock(); } void ReadLock() MOZ_ACQUIRE_SHARED(mLock) { mLock.ReadLock(); }
void ReadUnlock() RELEASE_SHARED(mLock) { mLock.ReadUnlock(); } void ReadUnlock() MOZ_RELEASE_SHARED(mLock) { mLock.ReadUnlock(); }
uint32_t FontListLength() const { uint32_t FontListLength() const {
mozilla::AutoReadLock lock(mLock); mozilla::AutoReadLock lock(mLock);
@@ -878,7 +879,7 @@ class gfxFontFamily {
AddFontEntryLocked(aFontEntry); AddFontEntryLocked(aFontEntry);
} }
void AddFontEntryLocked(RefPtr<gfxFontEntry> aFontEntry) REQUIRES(mLock) { void AddFontEntryLocked(RefPtr<gfxFontEntry> aFontEntry) MOZ_REQUIRES(mLock) {
// Avoid potentially duplicating entries. // Avoid potentially duplicating entries.
if (mAvailableFonts.Contains(aFontEntry)) { if (mAvailableFonts.Contains(aFontEntry)) {
return; return;
@@ -951,7 +952,7 @@ class gfxFontFamily {
// This is a no-op in cases where the family is explicitly populated by other // This is a no-op in cases where the family is explicitly populated by other
// means, rather than being asked to find its faces via system API. // means, rather than being asked to find its faces via system API.
virtual void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) virtual void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
REQUIRES(mLock){}; MOZ_REQUIRES(mLock){};
void FindStyleVariations(FontInfoData* aFontInfoData = nullptr) { void FindStyleVariations(FontInfoData* aFontInfoData = nullptr) {
if (mHasStyles) { if (mHasStyles) {
return; return;
@@ -977,7 +978,7 @@ class gfxFontFamily {
return mFamilyCharacterMap.test(aCh); return mFamilyCharacterMap.test(aCh);
} }
void ResetCharacterMap() REQUIRES(mLock) { void ResetCharacterMap() MOZ_REQUIRES(mLock) {
mFamilyCharacterMap.reset(); mFamilyCharacterMap.reset();
mFamilyCharacterMapInitialized = false; mFamilyCharacterMapInitialized = false;
} }
@@ -997,12 +998,12 @@ class gfxFontFamily {
bool CheckForFallbackFaces() const { return mCheckForFallbackFaces; } bool CheckForFallbackFaces() const { return mCheckForFallbackFaces; }
// sort available fonts to put preferred (standard) faces towards the end // sort available fonts to put preferred (standard) faces towards the end
void SortAvailableFonts() REQUIRES(mLock); void SortAvailableFonts() MOZ_REQUIRES(mLock);
// check whether the family fits into the simple 4-face model, // check whether the family fits into the simple 4-face model,
// so we can use simplified style-matching; // so we can use simplified style-matching;
// if so set the mIsSimpleFamily flag (defaults to False before we've checked) // if so set the mIsSimpleFamily flag (defaults to False before we've checked)
void CheckForSimpleFamily() REQUIRES(mLock); void CheckForSimpleFamily() MOZ_REQUIRES(mLock);
// For memory reporter // For memory reporter
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
@@ -1045,7 +1046,7 @@ class gfxFontFamily {
bool useFullName = false); bool useFullName = false);
// set whether this font family is in "bad" underline offset blocklist. // set whether this font family is in "bad" underline offset blocklist.
void SetBadUnderlineFonts() REQUIRES(mLock) { void SetBadUnderlineFonts() MOZ_REQUIRES(mLock) {
for (auto& f : mAvailableFonts) { for (auto& f : mAvailableFonts) {
if (f) { if (f) {
f->mIsBadUnderlineFont = true; f->mIsBadUnderlineFont = true;
@@ -1054,8 +1055,8 @@ class gfxFontFamily {
} }
nsCString mName; nsCString mName;
nsTArray<RefPtr<gfxFontEntry>> mAvailableFonts GUARDED_BY(mLock); nsTArray<RefPtr<gfxFontEntry>> mAvailableFonts MOZ_GUARDED_BY(mLock);
gfxSparseBitSet mFamilyCharacterMap GUARDED_BY(mLock); gfxSparseBitSet mFamilyCharacterMap MOZ_GUARDED_BY(mLock);
mutable mozilla::RWLock mLock; mutable mozilla::RWLock mLock;
@@ -1068,7 +1069,7 @@ class gfxFontFamily {
mozilla::Atomic<bool> mCheckedForLegacyFamilyNames; mozilla::Atomic<bool> mCheckedForLegacyFamilyNames;
mozilla::Atomic<bool> mHasOtherFamilyNames; mozilla::Atomic<bool> mHasOtherFamilyNames;
bool mIsSimpleFamily : 1 GUARDED_BY(mLock); bool mIsSimpleFamily : 1 MOZ_GUARDED_BY(mLock);
bool mIsBadUnderlineFamily : 1; bool mIsBadUnderlineFamily : 1;
bool mSkipDefaultFeatureSpaceCheck : 1; bool mSkipDefaultFeatureSpaceCheck : 1;
bool mCheckForFallbackFaces : 1; // check other faces for character bool mCheckForFallbackFaces : 1; // check other faces for character

View File

@@ -400,7 +400,7 @@ static bool ShouldIgnoreItalicStyle(const nsACString& aName) {
int CALLBACK GDIFontFamily::FamilyAddStylesProc( int CALLBACK GDIFontFamily::FamilyAddStylesProc(
const ENUMLOGFONTEXW* lpelfe, const NEWTEXTMETRICEXW* nmetrics, const ENUMLOGFONTEXW* lpelfe, const NEWTEXTMETRICEXW* nmetrics,
DWORD fontType, LPARAM data) NO_THREAD_SAFETY_ANALYSIS { DWORD fontType, LPARAM data) MOZ_NO_THREAD_SAFETY_ANALYSIS {
const NEWTEXTMETRICW& metrics = nmetrics->ntmTm; const NEWTEXTMETRICW& metrics = nmetrics->ntmTm;
LOGFONTW logFont = lpelfe->elfLogFont; LOGFONTW logFont = lpelfe->elfLogFont;
GDIFontFamily* ff = reinterpret_cast<GDIFontFamily*>(data); GDIFontFamily* ff = reinterpret_cast<GDIFontFamily*>(data);

View File

@@ -188,7 +188,7 @@ class GDIFontFamily final : public gfxFontFamily {
mCharset() {} mCharset() {}
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
bool FilterForFontList(nsAtom* aLangGroup, bool FilterForFontList(nsAtom* aLangGroup,
const nsACString& aGeneric) const final { const nsACString& aGeneric) const final {
@@ -296,7 +296,7 @@ class gfxGDIFontList final : public gfxPlatformFontList {
virtual ~gfxGDIFontList() { AutoLock lock(mLock); } virtual ~gfxGDIFontList() { AutoLock lock(mLock); }
// initialize font lists // initialize font lists
nsresult InitFontListForPlatform() REQUIRES(mLock) override; nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
gfxFontFamily* CreateFontFamily(const nsACString& aName, gfxFontFamily* CreateFontFamily(const nsACString& aName,
FontVisibility aVisibility) const override; FontVisibility aVisibility) const override;
@@ -306,7 +306,7 @@ class gfxGDIFontList final : public gfxPlatformFontList {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput, const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
gfxFontEntry* LookupLocalFont(nsPresContext* aPresContext, gfxFontEntry* LookupLocalFont(nsPresContext* aPresContext,
const nsACString& aFontName, const nsACString& aFontName,
@@ -330,14 +330,14 @@ class gfxGDIFontList final : public gfxPlatformFontList {
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
private: private:
friend class gfxWindowsPlatform; friend class gfxWindowsPlatform;
gfxGDIFontList(); gfxGDIFontList();
nsresult GetFontSubstitutes() REQUIRES(mLock); nsresult GetFontSubstitutes() MOZ_REQUIRES(mLock);
static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe, static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe,
NEWTEXTMETRICEXW* lpntme, NEWTEXTMETRICEXW* lpntme,

View File

@@ -149,8 +149,8 @@ class gfxGlyphExtents {
nsTArray<uintptr_t> mBlocks; nsTArray<uintptr_t> mBlocks;
}; };
GlyphWidths mContainedGlyphWidths GUARDED_BY(mLock); GlyphWidths mContainedGlyphWidths MOZ_GUARDED_BY(mLock);
nsTHashtable<HashEntry> mTightGlyphExtents GUARDED_BY(mLock); nsTHashtable<HashEntry> mTightGlyphExtents MOZ_GUARDED_BY(mLock);
const int32_t mAppUnitsPerDevUnit; const int32_t mAppUnitsPerDevUnit;
mutable mozilla::RWLock mLock; mutable mozilla::RWLock mLock;

View File

@@ -145,7 +145,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput, const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
// lookup the system font for a particular system font type and set // lookup the system font for a particular system font type and set
// the name and style characteristics // the name and style characteristics
@@ -165,7 +165,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
private: private:
friend class gfxPlatformMac; friend class gfxPlatformMac;
@@ -174,23 +174,23 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
virtual ~gfxMacPlatformFontList(); virtual ~gfxMacPlatformFontList();
// initialize font lists // initialize font lists
nsresult InitFontListForPlatform() REQUIRES(mLock) override; nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
void InitSharedFontListForPlatform() REQUIRES(mLock) override; void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
// handle commonly used fonts for which the name table should be loaded at // handle commonly used fonts for which the name table should be loaded at
// startup // startup
void PreloadNamesList() REQUIRES(mLock); void PreloadNamesList() MOZ_REQUIRES(mLock);
// special case font faces treated as font families (set via prefs) // special case font faces treated as font families (set via prefs)
void InitSingleFaceList() REQUIRES(mLock); void InitSingleFaceList() MOZ_REQUIRES(mLock);
void InitAliasesForSingleFaceList() REQUIRES(mLock); void InitAliasesForSingleFaceList() MOZ_REQUIRES(mLock);
// initialize system fonts // initialize system fonts
void InitSystemFontNames() REQUIRES(mLock); void InitSystemFontNames() MOZ_REQUIRES(mLock);
// helper function to lookup in both hidden system fonts and normal fonts // helper function to lookup in both hidden system fonts and normal fonts
gfxFontFamily* FindSystemFontFamily(const nsACString& aFamily) gfxFontFamily* FindSystemFontFamily(const nsACString& aFamily)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
FontVisibility GetVisibilityForFamily(const nsACString& aName) const; FontVisibility GetVisibilityForFamily(const nsACString& aName) const;
@@ -205,7 +205,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
Script aRunScript, Script aRunScript,
const gfxFontStyle* aMatchStyle, const gfxFontStyle* aMatchStyle,
FontFamily& aMatchedFamily) FontFamily& aMatchedFamily)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
bool UsesSystemFallback() override { return true; } bool UsesSystemFallback() override { return true; }
@@ -216,10 +216,10 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
// file is included in .cpp files, so we can't use objective C classes here. // file is included in .cpp files, so we can't use objective C classes here.
// But CFStringRef and NSString* are the same thing anyway (they're // But CFStringRef and NSString* are the same thing anyway (they're
// toll-free bridged). // toll-free bridged).
void AddFamily(CFStringRef aFamily) REQUIRES(mLock); void AddFamily(CFStringRef aFamily) MOZ_REQUIRES(mLock);
void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility) void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
static void ActivateFontsFromDir( static void ActivateFontsFromDir(
const nsACString& aDir, const nsACString& aDir,
@@ -236,7 +236,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily,
bool aNeedFullnamePostscriptNames) bool aNeedFullnamePostscriptNames)
REQUIRES(mLock) override; MOZ_REQUIRES(mLock) override;
#ifdef MOZ_BUNDLED_FONTS #ifdef MOZ_BUNDLED_FONTS
void ActivateBundledFonts(); void ActivateBundledFonts();

View File

@@ -759,7 +759,8 @@ class gfxMacFontFamily final : public gfxFontFamily {
void LocalizedName(nsACString& aLocalizedName) override; void LocalizedName(nsACString& aLocalizedName) override;
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) REQUIRES(mLock) override; void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
MOZ_REQUIRES(mLock) override;
protected: protected:
double mSizeHint; double mSizeHint;
@@ -929,7 +930,8 @@ class gfxSingleFaceMacFontFamily final : public gfxFontFamily {
virtual ~gfxSingleFaceMacFontFamily() = default; virtual ~gfxSingleFaceMacFontFamily() = default;
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) REQUIRES(mLock) override{}; void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
MOZ_REQUIRES(mLock) override{};
void LocalizedName(nsACString& aLocalizedName) override; void LocalizedName(nsACString& aLocalizedName) override;
@@ -1131,7 +1133,7 @@ void gfxMacPlatformFontList::ActivateFontsFromDir(const nsACString& aDir,
} }
void gfxMacPlatformFontList::ReadSystemFontList(dom::SystemFontList* aList) void gfxMacPlatformFontList::ReadSystemFontList(dom::SystemFontList* aList)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
// Note: We rely on the records for mSystemTextFontFamilyName and // Note: We rely on the records for mSystemTextFontFamilyName and
// mSystemDisplayFontFamilyName (if present) being *before* the main // mSystemDisplayFontFamilyName (if present) being *before* the main
// font list, so that those names are known in the content process // font list, so that those names are known in the content process

View File

@@ -271,7 +271,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
AutoLock lock(mLock); AutoLock lock(mLock);
ClearLangGroupPrefFontsLocked(); ClearLangGroupPrefFontsLocked();
} }
virtual void ClearLangGroupPrefFontsLocked() REQUIRES(mLock); virtual void ClearLangGroupPrefFontsLocked() MOZ_REQUIRES(mLock);
void GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily>>& aFamilyArray); void GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily>>& aFamilyArray);
@@ -326,7 +326,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput, const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
gfxFontEntry* FindFontForFamily(nsPresContext* aPresContext, gfxFontEntry* FindFontForFamily(nsPresContext* aPresContext,
const nsACString& aFamily, const nsACString& aFamily,
@@ -394,7 +394,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
AddFullnameLocked(aFontEntry, aFullname); AddFullnameLocked(aFontEntry, aFullname);
} }
void AddFullnameLocked(gfxFontEntry* aFontEntry, const nsCString& aFullname) void AddFullnameLocked(gfxFontEntry* aFontEntry, const nsCString& aFullname)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
void AddPostscriptName(gfxFontEntry* aFontEntry, void AddPostscriptName(gfxFontEntry* aFontEntry,
const nsCString& aPostscriptName) { const nsCString& aPostscriptName) {
@@ -403,7 +403,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
} }
void AddPostscriptNameLocked(gfxFontEntry* aFontEntry, void AddPostscriptNameLocked(gfxFontEntry* aFontEntry,
const nsCString& aPostscriptName) const nsCString& aPostscriptName)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; } bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; }
@@ -427,7 +427,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
FontFamily GetDefaultFont(nsPresContext* aPresContext, FontFamily GetDefaultFont(nsPresContext* aPresContext,
const gfxFontStyle* aStyle); const gfxFontStyle* aStyle);
FontFamily GetDefaultFontLocked(nsPresContext* aPresContext, FontFamily GetDefaultFontLocked(nsPresContext* aPresContext,
const gfxFontStyle* aStyle) REQUIRES(mLock); const gfxFontStyle* aStyle)
MOZ_REQUIRES(mLock);
// get the "ultimate" default font, for use if the font list is otherwise // get the "ultimate" default font, for use if the font list is otherwise
// unusable (e.g. in the middle of being updated) // unusable (e.g. in the middle of being updated)
@@ -492,7 +493,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
return GetShmemCharMapLocked(aCmap); return GetShmemCharMapLocked(aCmap);
} }
mozilla::fontlist::Pointer GetShmemCharMapLocked(const gfxSparseBitSet* aCmap) mozilla::fontlist::Pointer GetShmemCharMapLocked(const gfxSparseBitSet* aCmap)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// Search for existing cmap that matches the input; return the input if no // Search for existing cmap that matches the input; return the input if no
// match is found. // match is found.
@@ -537,9 +538,9 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
} }
gfxFontEntry* GetOrCreateFontEntryLocked( gfxFontEntry* GetOrCreateFontEntryLocked(
mozilla::fontlist::Face* aFace, const mozilla::fontlist::Family* aFamily) mozilla::fontlist::Face* aFace, const mozilla::fontlist::Family* aFamily)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
const FontPrefs* GetFontPrefs() const REQUIRES(mLock) { const FontPrefs* GetFontPrefs() const MOZ_REQUIRES(mLock) {
return mFontPrefs.get(); return mFontPrefs.get();
} }
@@ -556,7 +557,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
} }
PrefFontList* GetPrefFontsLangGroupLocked( PrefFontList* GetPrefFontsLangGroupLocked(
nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType, nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType,
eFontPrefLang aPrefLang) REQUIRES(mLock); eFontPrefLang aPrefLang) MOZ_REQUIRES(mLock);
// in some situations, need to make decisions about ambiguous characters, may // in some situations, need to make decisions about ambiguous characters, may
// need to look at multiple pref langs // need to look at multiple pref langs
@@ -619,7 +620,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
FontVisibility aVisibility) const; FontVisibility aVisibility) const;
// (Re-)initialize the set of codepoints that we know cannot be rendered. // (Re-)initialize the set of codepoints that we know cannot be rendered.
void InitializeCodepointsWithNoFonts() REQUIRES(mLock); void InitializeCodepointsWithNoFonts() MOZ_REQUIRES(mLock);
// If using the shared font list, returns a generation count that is // If using the shared font list, returns a generation count that is
// incremented if/when the platform list is reinitialized (e.g. because // incremented if/when the platform list is reinitialized (e.g. because
@@ -634,8 +635,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
return PR_GetCurrentThread() == sInitFontListThread; return PR_GetCurrentThread() == sInitFontListThread;
} }
void Lock() CAPABILITY_ACQUIRE(mLock) { mLock.Lock(); } void Lock() MOZ_CAPABILITY_ACQUIRE(mLock) { mLock.Lock(); }
void Unlock() CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } void Unlock() MOZ_CAPABILITY_RELEASE(mLock) { mLock.Unlock(); }
// This is only public because some external callers want to be able to // This is only public because some external callers want to be able to
// assert about the locked status. // assert about the locked status.
@@ -740,13 +741,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
nsPresContext* aPresContext, const nsACString& aFamily, nsPresContext* aPresContext, const nsACString& aFamily,
FindFamiliesFlags aFlags = FindFamiliesFlags(0), FindFamiliesFlags aFlags = FindFamiliesFlags(0),
gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr,
gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock); gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock);
gfxFontFamily* FindUnsharedFamily( gfxFontFamily* FindUnsharedFamily(
nsPresContext* aPresContext, const nsACString& aFamily, nsPresContext* aPresContext, const nsACString& aFamily,
FindFamiliesFlags aFlags = FindFamiliesFlags(0), FindFamiliesFlags aFlags = FindFamiliesFlags(0),
gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr,
gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock) { gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock) {
if (SharedFontList()) { if (SharedFontList()) {
return nullptr; return nullptr;
} }
@@ -763,7 +764,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
FindFamiliesFlags aFlags = FindFamiliesFlags(0), FindFamiliesFlags aFlags = FindFamiliesFlags(0),
gfxFontStyle* aStyle = nullptr, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, nsAtom* aLanguage = nullptr,
gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock) { gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock) {
if (SharedFontList()) { if (SharedFontList()) {
return FontFamily(FindSharedFamily(aPresContext, aFamily, aFlags, aStyle, return FontFamily(FindSharedFamily(aPresContext, aFamily, aFlags, aStyle,
aLanguage, aDevToCssSize)); aLanguage, aDevToCssSize));
@@ -775,7 +776,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
// Lookup family name in global family list without substitutions or // Lookup family name in global family list without substitutions or
// localized family name lookup. Used for common font fallback families. // localized family name lookup. Used for common font fallback families.
gfxFontFamily* FindFamilyByCanonicalName(const nsACString& aFamily) gfxFontFamily* FindFamilyByCanonicalName(const nsACString& aFamily)
REQUIRES(mLock) { MOZ_REQUIRES(mLock) {
nsAutoCString key; nsAutoCString key;
gfxFontFamily* familyEntry; gfxFontFamily* familyEntry;
GenerateFontListKey(aFamily, key); GenerateFontListKey(aFamily, key);
@@ -792,14 +793,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
eFontPresentation aPresentation, eFontPresentation aPresentation,
const gfxFontStyle* aMatchStyle, const gfxFontStyle* aMatchStyle,
FontFamily& aMatchedFamily) FontFamily& aMatchedFamily)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// Search fonts system-wide for a given character, null if not found. // Search fonts system-wide for a given character, null if not found.
already_AddRefed<gfxFont> GlobalFontFallback( already_AddRefed<gfxFont> GlobalFontFallback(
nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh, nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh,
Script aRunScript, eFontPresentation aPresentation, Script aRunScript, eFontPresentation aPresentation,
const gfxFontStyle* aMatchStyle, uint32_t& aCmapCount, const gfxFontStyle* aMatchStyle, uint32_t& aCmapCount,
FontFamily& aMatchedFamily) REQUIRES(mLock); FontFamily& aMatchedFamily) MOZ_REQUIRES(mLock);
// Platform-specific implementation of global font fallback, if any; // Platform-specific implementation of global font fallback, if any;
// this may return nullptr in which case the default cmap-based fallback // this may return nullptr in which case the default cmap-based fallback
@@ -816,37 +817,37 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t& aLen, void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t& aLen,
eFontPrefLang aCharLang, eFontPrefLang aPageLang) eFontPrefLang aCharLang, eFontPrefLang aPageLang)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// verifies that a family contains a non-zero font count // verifies that a family contains a non-zero font count
gfxFontFamily* CheckFamily(gfxFontFamily* aFamily) REQUIRES(mLock); gfxFontFamily* CheckFamily(gfxFontFamily* aFamily) MOZ_REQUIRES(mLock);
// initialize localized family names // initialize localized family names
void InitOtherFamilyNamesInternal(bool aDeferOtherFamilyNamesLoading); void InitOtherFamilyNamesInternal(bool aDeferOtherFamilyNamesLoading);
void CancelInitOtherFamilyNamesTask(); void CancelInitOtherFamilyNamesTask();
void AddToMissedNames(const nsCString& aKey) REQUIRES(mLock); void AddToMissedNames(const nsCString& aKey) MOZ_REQUIRES(mLock);
// search through font families, looking for a given name, initializing // search through font families, looking for a given name, initializing
// facename lists along the way. first checks all families with names // facename lists along the way. first checks all families with names
// close to face name, then searchs all families if not found. // close to face name, then searchs all families if not found.
gfxFontEntry* SearchFamiliesForFaceName(const nsACString& aFaceName) gfxFontEntry* SearchFamiliesForFaceName(const nsACString& aFaceName)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// helper method for finding fullname/postscript names in facename lists // helper method for finding fullname/postscript names in facename lists
gfxFontEntry* FindFaceName(const nsACString& aFaceName) REQUIRES(mLock); gfxFontEntry* FindFaceName(const nsACString& aFaceName) MOZ_REQUIRES(mLock);
// look up a font by name, for cases where platform font list // look up a font by name, for cases where platform font list
// maintains explicit mappings of fullname/psname ==> font // maintains explicit mappings of fullname/psname ==> font
virtual gfxFontEntry* LookupInFaceNameLists(const nsACString& aFaceName) virtual gfxFontEntry* LookupInFaceNameLists(const nsACString& aFaceName)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
gfxFontEntry* LookupInSharedFaceNameList(nsPresContext* aPresContext, gfxFontEntry* LookupInSharedFaceNameList(nsPresContext* aPresContext,
const nsACString& aFaceName, const nsACString& aFaceName,
WeightRange aWeightForEntry, WeightRange aWeightForEntry,
StretchRange aStretchForEntry, StretchRange aStretchForEntry,
SlantStyleRange aStyleForEntry) SlantStyleRange aStyleForEntry)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// load the bad underline blocklist from pref. // load the bad underline blocklist from pref.
void LoadBadUnderlineList(); void LoadBadUnderlineList();
@@ -854,13 +855,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
void GenerateFontListKey(const nsACString& aKeyName, nsACString& aResult); void GenerateFontListKey(const nsACString& aKeyName, nsACString& aResult);
virtual void GetFontFamilyNames(nsTArray<nsCString>& aFontFamilyNames) virtual void GetFontFamilyNames(nsTArray<nsCString>& aFontFamilyNames)
REQUIRES(mLock); MOZ_REQUIRES(mLock);
// helper function to map lang to lang group // helper function to map lang to lang group
nsAtom* GetLangGroup(nsAtom* aLanguage); nsAtom* GetLangGroup(nsAtom* aLanguage);
// gfxFontInfoLoader overrides, used to load in font cmaps // gfxFontInfoLoader overrides, used to load in font cmaps
void InitLoader() REQUIRES(mLock) override; void InitLoader() MOZ_REQUIRES(mLock) override;
bool LoadFontInfo() override; bool LoadFontInfo() override;
void CleanupLoader() override; void CleanupLoader() override;
@@ -870,23 +871,25 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
// If aForgetLocalFaces is true, all gfxFontEntries for src:local fonts must // If aForgetLocalFaces is true, all gfxFontEntries for src:local fonts must
// be discarded (not potentially reused to satisfy the rebuilt rules), // be discarded (not potentially reused to satisfy the rebuilt rules),
// because they may no longer be valid. // because they may no longer be valid.
void RebuildLocalFonts(bool aForgetLocalFaces = false) REQUIRES(mLock); void RebuildLocalFonts(bool aForgetLocalFaces = false) MOZ_REQUIRES(mLock);
void ResolveGenericFontNames(nsPresContext* aPresContext, void ResolveGenericFontNames(nsPresContext* aPresContext,
mozilla::StyleGenericFontFamily aGenericType, mozilla::StyleGenericFontFamily aGenericType,
eFontPrefLang aPrefLang, eFontPrefLang aPrefLang,
PrefFontList* aGenericFamilies) REQUIRES(mLock); PrefFontList* aGenericFamilies)
MOZ_REQUIRES(mLock);
void ResolveEmojiFontNames(nsPresContext* aPresContext, void ResolveEmojiFontNames(nsPresContext* aPresContext,
PrefFontList* aGenericFamilies) REQUIRES(mLock); PrefFontList* aGenericFamilies)
MOZ_REQUIRES(mLock);
void GetFontFamiliesFromGenericFamilies( void GetFontFamiliesFromGenericFamilies(
nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType, nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType,
nsTArray<nsCString>& aGenericNameFamilies, nsAtom* aLangGroup, nsTArray<nsCString>& aGenericNameFamilies, nsAtom* aLangGroup,
PrefFontList* aFontFamilies) REQUIRES(mLock); PrefFontList* aFontFamilies) MOZ_REQUIRES(mLock);
virtual nsresult InitFontListForPlatform() REQUIRES(mLock) = 0; virtual nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) = 0;
virtual void InitSharedFontListForPlatform() REQUIRES(mLock) {} virtual void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) {}
virtual gfxFontEntry* CreateFontEntry( virtual gfxFontEntry* CreateFontEntry(
mozilla::fontlist::Face* aFace, mozilla::fontlist::Face* aFace,
@@ -901,7 +904,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
* There are separate implementations of this for the per-process font list * There are separate implementations of this for the per-process font list
* and for the shared-memory font list. * and for the shared-memory font list.
*/ */
void ApplyWhitelist() REQUIRES(mLock); void ApplyWhitelist() MOZ_REQUIRES(mLock);
void ApplyWhitelist(nsTArray<mozilla::fontlist::Family::InitData>& aFamilies); void ApplyWhitelist(nsTArray<mozilla::fontlist::Family::InitData>& aFamilies);
// Create a new gfxFontFamily of the appropriate subclass for the platform, // Create a new gfxFontFamily of the appropriate subclass for the platform,
@@ -921,7 +924,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
*/ */
virtual void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, virtual void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily,
bool aNeedFullnamePostscriptNames) bool aNeedFullnamePostscriptNames)
REQUIRES(mLock) {} MOZ_REQUIRES(mLock) {}
typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontFamily> FontFamilyTable; typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontFamily> FontFamilyTable;
typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontEntry> FontEntryTable; typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontEntry> FontEntryTable;
@@ -936,14 +939,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
virtual FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, virtual FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle, const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr) nsAtom* aLanguage = nullptr)
REQUIRES(mLock) = 0; MOZ_REQUIRES(mLock) = 0;
// canonical family name ==> family entry (unique, one name per family entry) // canonical family name ==> family entry (unique, one name per family entry)
FontFamilyTable mFontFamilies GUARDED_BY(mLock); FontFamilyTable mFontFamilies MOZ_GUARDED_BY(mLock);
// other family name ==> family entry (not unique, can have multiple names per // other family name ==> family entry (not unique, can have multiple names per
// family entry, only names *other* than the canonical names are stored here) // family entry, only names *other* than the canonical names are stored here)
FontFamilyTable mOtherFamilyNames GUARDED_BY(mLock); FontFamilyTable mOtherFamilyNames MOZ_GUARDED_BY(mLock);
// flag set after InitOtherFamilyNames is called upon first name lookup miss // flag set after InitOtherFamilyNames is called upon first name lookup miss
mozilla::Atomic<bool> mOtherFamilyNamesInitialized; mozilla::Atomic<bool> mOtherFamilyNamesInitialized;
@@ -965,13 +968,15 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
// The lock is needed to guard access to the actual name tables, but does not // The lock is needed to guard access to the actual name tables, but does not
// need to be held to just test whether mExtraNames is non-null as it is set // need to be held to just test whether mExtraNames is non-null as it is set
// during initialization before other threads have a chance to see it. // during initialization before other threads have a chance to see it.
mozilla::UniquePtr<ExtraNames> mExtraNames PT_GUARDED_BY(mLock); mozilla::UniquePtr<ExtraNames> mExtraNames MOZ_PT_GUARDED_BY(mLock);
// face names missed when face name loading takes a long time // face names missed when face name loading takes a long time
mozilla::UniquePtr<nsTHashSet<nsCString>> mFaceNamesMissed GUARDED_BY(mLock); mozilla::UniquePtr<nsTHashSet<nsCString>> mFaceNamesMissed
MOZ_GUARDED_BY(mLock);
// localized family names missed when face name loading takes a long time // localized family names missed when face name loading takes a long time
mozilla::UniquePtr<nsTHashSet<nsCString>> mOtherNamesMissed GUARDED_BY(mLock); mozilla::UniquePtr<nsTHashSet<nsCString>> mOtherNamesMissed
MOZ_GUARDED_BY(mLock);
typedef mozilla::RangedArray<mozilla::UniquePtr<PrefFontList>, typedef mozilla::RangedArray<mozilla::UniquePtr<PrefFontList>,
size_t(mozilla::StyleGenericFontFamily::None), size_t(mozilla::StyleGenericFontFamily::None),
@@ -980,28 +985,28 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
PrefFontsForLangGroup; PrefFontsForLangGroup;
mozilla::RangedArray<PrefFontsForLangGroup, eFontPrefLang_First, mozilla::RangedArray<PrefFontsForLangGroup, eFontPrefLang_First,
eFontPrefLang_Count> eFontPrefLang_Count>
mLangGroupPrefFonts GUARDED_BY(mLock); mLangGroupPrefFonts MOZ_GUARDED_BY(mLock);
mozilla::UniquePtr<PrefFontList> mEmojiPrefFont GUARDED_BY(mLock); mozilla::UniquePtr<PrefFontList> mEmojiPrefFont MOZ_GUARDED_BY(mLock);
// When system-wide font lookup fails for a character, cache it to skip future // When system-wide font lookup fails for a character, cache it to skip future
// searches. This is an array of bitsets, one for each FontVisibility level. // searches. This is an array of bitsets, one for each FontVisibility level.
mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count, mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count,
gfxSparseBitSet> gfxSparseBitSet>
mCodepointsWithNoFonts GUARDED_BY(mLock); mCodepointsWithNoFonts MOZ_GUARDED_BY(mLock);
// the family to use for U+FFFD fallback, to avoid expensive search every time // the family to use for U+FFFD fallback, to avoid expensive search every time
// on pages with lots of problems // on pages with lots of problems
mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count, FontFamily> mozilla::EnumeratedArray<FontVisibility, FontVisibility::Count, FontFamily>
mReplacementCharFallbackFamily GUARDED_BY(mLock); mReplacementCharFallbackFamily MOZ_GUARDED_BY(mLock);
// Sorted array of lowercased family names; use ContainsSorted to test // Sorted array of lowercased family names; use ContainsSorted to test
nsTArray<nsCString> mBadUnderlineFamilyNames; nsTArray<nsCString> mBadUnderlineFamilyNames;
// character map data shared across families // character map data shared across families
// contains weak ptrs to cmaps shared by font entry objects // contains weak ptrs to cmaps shared by font entry objects
nsTHashtable<CharMapHashKey> mSharedCmaps GUARDED_BY(mLock); nsTHashtable<CharMapHashKey> mSharedCmaps MOZ_GUARDED_BY(mLock);
nsTHashtable<ShmemCharMapHashEntry> mShmemCharMaps GUARDED_BY(mLock); nsTHashtable<ShmemCharMapHashEntry> mShmemCharMaps MOZ_GUARDED_BY(mLock);
// data used as part of the font cmap loading process // data used as part of the font cmap loading process
nsTArray<RefPtr<gfxFontFamily>> mFontFamiliesToLoad; nsTArray<RefPtr<gfxFontFamily>> mFontFamiliesToLoad;
@@ -1012,13 +1017,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
// see bugs 636957, 1070983, 1189129 // see bugs 636957, 1070983, 1189129
uint32_t mFontlistInitCount = 0; // num times InitFontList called uint32_t mFontlistInitCount = 0; // num times InitFontList called
nsTHashSet<gfxUserFontSet*> mUserFontSetList GUARDED_BY(mLock); nsTHashSet<gfxUserFontSet*> mUserFontSetList MOZ_GUARDED_BY(mLock);
nsLanguageAtomService* mLangService = nullptr; nsLanguageAtomService* mLangService = nullptr;
nsTArray<uint32_t> mCJKPrefLangs GUARDED_BY(mLock); nsTArray<uint32_t> mCJKPrefLangs MOZ_GUARDED_BY(mLock);
nsTArray<mozilla::StyleGenericFontFamily> mDefaultGenericsLangGroup nsTArray<mozilla::StyleGenericFontFamily> mDefaultGenericsLangGroup
GUARDED_BY(mLock); MOZ_GUARDED_BY(mLock);
nsTArray<nsCString> mEnabledFontsList; nsTArray<nsCString> mEnabledFontsList;
@@ -1029,11 +1034,11 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
mLocalNameTable; mLocalNameTable;
nsRefPtrHashtable<nsPtrHashKey<mozilla::fontlist::Face>, gfxFontEntry> nsRefPtrHashtable<nsPtrHashKey<mozilla::fontlist::Face>, gfxFontEntry>
mFontEntries GUARDED_BY(mLock); mFontEntries MOZ_GUARDED_BY(mLock);
mozilla::UniquePtr<FontPrefs> mFontPrefs; mozilla::UniquePtr<FontPrefs> mFontPrefs;
RefPtr<gfxFontEntry> mDefaultFontEntry GUARDED_BY(mLock); RefPtr<gfxFontEntry> mDefaultFontEntry MOZ_GUARDED_BY(mLock);
RefPtr<mozilla::CancelableRunnable> mLoadCmapsRunnable; RefPtr<mozilla::CancelableRunnable> mLoadCmapsRunnable;
uint32_t mStartedLoadingCmapsFrom = 0xffffffffu; uint32_t mStartedLoadingCmapsFrom = 0xffffffffu;

View File

@@ -99,7 +99,7 @@ class DecodePool final : public nsIObserver {
// mMutex protects mIOThread. // mMutex protects mIOThread.
Mutex mMutex; Mutex mMutex;
nsCOMPtr<nsIThread> mIOThread GUARDED_BY(mMutex); nsCOMPtr<nsIThread> mIOThread MOZ_GUARDED_BY(mMutex);
}; };
} // namespace image } // namespace image

View File

@@ -438,19 +438,19 @@ class SourceBuffer final {
char* mData; char* mData;
}; };
nsresult AppendChunk(Maybe<Chunk>&& aChunk) REQUIRES(mMutex); nsresult AppendChunk(Maybe<Chunk>&& aChunk) MOZ_REQUIRES(mMutex);
Maybe<Chunk> CreateChunk(size_t aCapacity, size_t aExistingCapacity = 0, Maybe<Chunk> CreateChunk(size_t aCapacity, size_t aExistingCapacity = 0,
bool aRoundUp = true); bool aRoundUp = true);
nsresult Compact() REQUIRES(mMutex); nsresult Compact() MOZ_REQUIRES(mMutex);
static size_t RoundedUpCapacity(size_t aCapacity); static size_t RoundedUpCapacity(size_t aCapacity);
size_t FibonacciCapacityWithMinimum(size_t aMinCapacity) REQUIRES(mMutex); size_t FibonacciCapacityWithMinimum(size_t aMinCapacity) MOZ_REQUIRES(mMutex);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Iterator / consumer methods. // Iterator / consumer methods.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void AddWaitingConsumer(IResumable* aConsumer) REQUIRES(mMutex); void AddWaitingConsumer(IResumable* aConsumer) MOZ_REQUIRES(mMutex);
void ResumeWaitingConsumers() REQUIRES(mMutex); void ResumeWaitingConsumers() MOZ_REQUIRES(mMutex);
typedef SourceBufferIterator::State State; typedef SourceBufferIterator::State State;
@@ -466,9 +466,9 @@ class SourceBuffer final {
// Helper methods. // Helper methods.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
nsresult HandleError(nsresult aError) REQUIRES(mMutex); nsresult HandleError(nsresult aError) MOZ_REQUIRES(mMutex);
bool IsEmpty() REQUIRES(mMutex); bool IsEmpty() MOZ_REQUIRES(mMutex);
bool IsLastChunk(uint32_t aChunk) REQUIRES(mMutex); bool IsLastChunk(uint32_t aChunk) MOZ_REQUIRES(mMutex);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Member variables. // Member variables.
@@ -478,19 +478,19 @@ class SourceBuffer final {
mutable Mutex mMutex; mutable Mutex mMutex;
/// The data in this SourceBuffer, stored as a series of Chunks. /// The data in this SourceBuffer, stored as a series of Chunks.
AutoTArray<Chunk, 1> mChunks GUARDED_BY(mMutex); AutoTArray<Chunk, 1> mChunks MOZ_GUARDED_BY(mMutex);
/// Consumers which are waiting to be notified when new data is available. /// Consumers which are waiting to be notified when new data is available.
nsTArray<RefPtr<IResumable>> mWaitingConsumers GUARDED_BY(mMutex); nsTArray<RefPtr<IResumable>> mWaitingConsumers MOZ_GUARDED_BY(mMutex);
/// If present, marks this SourceBuffer complete with the given final status. /// If present, marks this SourceBuffer complete with the given final status.
Maybe<nsresult> mStatus GUARDED_BY(mMutex); Maybe<nsresult> mStatus MOZ_GUARDED_BY(mMutex);
/// Count of active consumers. /// Count of active consumers.
uint32_t mConsumerCount GUARDED_BY(mMutex); uint32_t mConsumerCount MOZ_GUARDED_BY(mMutex);
/// True if compacting has been performed. /// True if compacting has been performed.
bool mCompacted GUARDED_BY(mMutex); bool mCompacted MOZ_GUARDED_BY(mMutex);
}; };
} // namespace image } // namespace image

View File

@@ -185,7 +185,7 @@ class imgFrame {
private: // methods private: // methods
~imgFrame(); ~imgFrame();
bool AreAllPixelsWritten() const REQUIRES(mMonitor); bool AreAllPixelsWritten() const MOZ_REQUIRES(mMonitor);
nsresult ImageUpdatedInternal(const nsIntRect& aUpdateRect); nsresult ImageUpdatedInternal(const nsIntRect& aUpdateRect);
void GetImageDataInternal(uint8_t** aData, uint32_t* length) const; void GetImageDataInternal(uint8_t** aData, uint32_t* length) const;
uint32_t GetImageBytesPerRow() const; uint32_t GetImageBytesPerRow() const;
@@ -229,20 +229,20 @@ class imgFrame {
/** /**
* Used for rasterized images, this contains the raw pixel data. * Used for rasterized images, this contains the raw pixel data.
*/ */
RefPtr<SourceSurfaceSharedData> mRawSurface GUARDED_BY(mMonitor); RefPtr<SourceSurfaceSharedData> mRawSurface MOZ_GUARDED_BY(mMonitor);
RefPtr<SourceSurfaceSharedData> mBlankRawSurface GUARDED_BY(mMonitor); RefPtr<SourceSurfaceSharedData> mBlankRawSurface MOZ_GUARDED_BY(mMonitor);
/** /**
* Used for vector images that were not rasterized directly. This might be a * Used for vector images that were not rasterized directly. This might be a
* blob recording or native surface. * blob recording or native surface.
*/ */
RefPtr<SourceSurface> mOptSurface GUARDED_BY(mMonitor); RefPtr<SourceSurface> mOptSurface MOZ_GUARDED_BY(mMonitor);
nsIntRect mDecoded GUARDED_BY(mMonitor); nsIntRect mDecoded MOZ_GUARDED_BY(mMonitor);
bool mAborted GUARDED_BY(mMonitor); bool mAborted MOZ_GUARDED_BY(mMonitor);
bool mFinished GUARDED_BY(mMonitor); bool mFinished MOZ_GUARDED_BY(mMonitor);
bool mShouldRecycle GUARDED_BY(mMonitor); bool mShouldRecycle MOZ_GUARDED_BY(mMonitor);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Effectively const data, only mutated in the Init methods. // Effectively const data, only mutated in the Init methods.

View File

@@ -413,7 +413,7 @@ class imgLoader final : public imgILoader,
// mChromeCache. The union over all imgLoader's of mCache, mChromeCache, and // mChromeCache. The union over all imgLoader's of mCache, mChromeCache, and
// mUncachedImages should be every imgRequest that is alive. These are weak // mUncachedImages should be every imgRequest that is alive. These are weak
// pointers so we rely on the imgRequest destructor to remove itself. // pointers so we rely on the imgRequest destructor to remove itself.
imgSet mUncachedImages GUARDED_BY(mUncachedImagesMutex); imgSet mUncachedImages MOZ_GUARDED_BY(mUncachedImagesMutex);
// The imgRequest can have refs to them held on non-main thread, so we need // The imgRequest can have refs to them held on non-main thread, so we need
// a mutex because we modify the uncached images set from the imgRequest // a mutex because we modify the uncached images set from the imgRequest
// destructor. // destructor.

View File

@@ -90,7 +90,7 @@ nsresult imgRequest::Init(
nsIRequest* aRequest, nsIChannel* aChannel, imgCacheEntry* aCacheEntry, nsIRequest* aRequest, nsIChannel* aChannel, imgCacheEntry* aCacheEntry,
mozilla::dom::Document* aLoadingDocument, mozilla::dom::Document* aLoadingDocument,
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode, nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode,
nsIReferrerInfo* aReferrerInfo) NO_THREAD_SAFETY_ANALYSIS { nsIReferrerInfo* aReferrerInfo) MOZ_NO_THREAD_SAFETY_ANALYSIS {
MOZ_ASSERT(NS_IsMainThread(), "Cannot use nsIURI off main thread!"); MOZ_ASSERT(NS_IsMainThread(), "Cannot use nsIURI off main thread!");
// Init() can only be called once, and that's before it can be used off // Init() can only be called once, and that's before it can be used off
// mainthread // mainthread

View File

@@ -285,15 +285,15 @@ class imgRequest final : public nsIStreamListener,
// Member variables protected by mMutex. Note that *all* flags in our bitfield // Member variables protected by mMutex. Note that *all* flags in our bitfield
// are protected by mMutex; if you're adding a new flag that isn'protected, it // are protected by mMutex; if you're adding a new flag that isn'protected, it
// must not be a part of this bitfield. // must not be a part of this bitfield.
RefPtr<ProgressTracker> mProgressTracker GUARDED_BY(mMutex); RefPtr<ProgressTracker> mProgressTracker MOZ_GUARDED_BY(mMutex);
RefPtr<Image> mImage GUARDED_BY(mMutex); RefPtr<Image> mImage MOZ_GUARDED_BY(mMutex);
bool mIsMultiPartChannel : 1 GUARDED_BY(mMutex); bool mIsMultiPartChannel : 1 MOZ_GUARDED_BY(mMutex);
bool mIsInCache : 1 GUARDED_BY(mMutex); bool mIsInCache : 1 MOZ_GUARDED_BY(mMutex);
bool mDecodeRequested : 1 GUARDED_BY(mMutex); bool mDecodeRequested : 1 MOZ_GUARDED_BY(mMutex);
bool mNewPartPending : 1 GUARDED_BY(mMutex); bool mNewPartPending : 1 MOZ_GUARDED_BY(mMutex);
bool mHadInsecureRedirect : 1 GUARDED_BY(mMutex); bool mHadInsecureRedirect : 1 MOZ_GUARDED_BY(mMutex);
// The ID of the inner window origin, used for error reporting. // The ID of the inner window origin, used for error reporting.
uint64_t mInnerWindowId GUARDED_BY(mMutex); uint64_t mInnerWindowId MOZ_GUARDED_BY(mMutex);
}; };
#endif // mozilla_image_imgRequest_h #endif // mozilla_image_imgRequest_h

View File

@@ -65,7 +65,7 @@ class AtExitManager {
}; };
mozilla::Mutex lock_; mozilla::Mutex lock_;
std::stack<CallbackAndParam> stack_ GUARDED_BY(lock_); std::stack<CallbackAndParam> stack_ MOZ_GUARDED_BY(lock_);
AtExitManager* next_manager_; // Stack of managers to allow shadowing. AtExitManager* next_manager_; // Stack of managers to allow shadowing.
DISALLOW_COPY_AND_ASSIGN(AtExitManager); DISALLOW_COPY_AND_ASSIGN(AtExitManager);

View File

@@ -137,9 +137,10 @@ class MessageLoop::EventTarget : public nsISerialEventTarget,
} }
mozilla::Mutex mMutex; mozilla::Mutex mMutex;
bool mShutdownTasksRun GUARDED_BY(mMutex) = false; bool mShutdownTasksRun MOZ_GUARDED_BY(mMutex) = false;
nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks GUARDED_BY(mMutex); nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks
MessageLoop* mLoop GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
MessageLoop* mLoop MOZ_GUARDED_BY(mMutex);
}; };
NS_IMPL_ISUPPORTS(MessageLoop::EventTarget, nsIEventTarget, NS_IMPL_ISUPPORTS(MessageLoop::EventTarget, nsIEventTarget,

View File

@@ -420,7 +420,7 @@ class MessageLoop : public base::MessagePump::Delegate {
// aquired under a mutex for processing on this instance's thread. These tasks // aquired under a mutex for processing on this instance's thread. These tasks
// have not yet been sorted out into items for our work_queue_ vs items that // have not yet been sorted out into items for our work_queue_ vs items that
// will be handled by the TimerManager. // will be handled by the TimerManager.
TaskQueue incoming_queue_ GUARDED_BY(incoming_queue_lock_); TaskQueue incoming_queue_ MOZ_GUARDED_BY(incoming_queue_lock_);
// Protect access to incoming_queue_. // Protect access to incoming_queue_.
mozilla::Mutex incoming_queue_lock_; mozilla::Mutex incoming_queue_lock_;

View File

@@ -246,11 +246,11 @@ class NowSingleton {
: rollover_(TimeDelta::FromMilliseconds(0)), last_seen_(0) {} : rollover_(TimeDelta::FromMilliseconds(0)), last_seen_(0) {}
~NowSingleton() = default; ~NowSingleton() = default;
TimeDelta rollover_ GUARDED_BY( TimeDelta rollover_ MOZ_GUARDED_BY(
sNowSingletonLock); // Accumulation of time lost due to rollover. sNowSingletonLock); // Accumulation of time lost due to rollover.
DWORD last_seen_ DWORD last_seen_
GUARDED_BY(sNowSingletonLock); // The last timeGetTime value we saw, to MOZ_GUARDED_BY(sNowSingletonLock); // The last timeGetTime value we saw,
// detect rollover. // to detect rollover.
DISALLOW_COPY_AND_ASSIGN(NowSingleton); DISALLOW_COPY_AND_ASSIGN(NowSingleton);
}; };

View File

@@ -226,7 +226,7 @@ class Node {
void ConvertToProxy(Port* port, const NodeName& to_node_name, void ConvertToProxy(Port* port, const NodeName& to_node_name,
PortName* port_name, PortName* port_name,
Event::PortDescriptor* port_descriptor) Event::PortDescriptor* port_descriptor)
REQUIRES(ports_lock_); MOZ_REQUIRES(ports_lock_);
int AcceptPort(const PortName& port_name, int AcceptPort(const PortName& port_name,
const Event::PortDescriptor& port_descriptor); const Event::PortDescriptor& port_descriptor);
@@ -249,19 +249,19 @@ class Node {
void UpdatePortPeerAddress(const PortName& local_port_name, Port* local_port, void UpdatePortPeerAddress(const PortName& local_port_name, Port* local_port,
const NodeName& new_peer_node, const NodeName& new_peer_node,
const PortName& new_peer_port) const PortName& new_peer_port)
REQUIRES(ports_lock_); MOZ_REQUIRES(ports_lock_);
// Removes an entry from |peer_port_map_| corresponding to |local_port|'s peer // Removes an entry from |peer_port_map_| corresponding to |local_port|'s peer
// address, if valid. // address, if valid.
void RemoveFromPeerPortMap(const PortName& local_port_name, Port* local_port) void RemoveFromPeerPortMap(const PortName& local_port_name, Port* local_port)
REQUIRES(ports_lock_); MOZ_REQUIRES(ports_lock_);
// Swaps the peer information for two local ports. Used during port merges. // Swaps the peer information for two local ports. Used during port merges.
// Note that |ports_lock_| must be held along with each of the two port's own // Note that |ports_lock_| must be held along with each of the two port's own
// locks, through the extent of this method. // locks, through the extent of this method.
void SwapPortPeers(const PortName& port0_name, Port* port0, void SwapPortPeers(const PortName& port0_name, Port* port0,
const PortName& port1_name, Port* port1) const PortName& port1_name, Port* port1)
REQUIRES(ports_lock_); MOZ_REQUIRES(ports_lock_);
// Sends an acknowledge request to the peer if the port has a non-zero // Sends an acknowledge request to the peer if the port has a non-zero
// |sequence_num_acknowledge_interval|. This needs to be done when the port's // |sequence_num_acknowledge_interval|. This needs to be done when the port's
@@ -296,7 +296,7 @@ class Node {
// destroyed while this (or any individual Port) lock is held. // destroyed while this (or any individual Port) lock is held.
mozilla::Mutex ports_lock_{"Ports Lock"}; mozilla::Mutex ports_lock_{"Ports Lock"};
std::unordered_map<LocalPortName, RefPtr<Port>> ports_ std::unordered_map<LocalPortName, RefPtr<Port>> ports_
GUARDED_BY(ports_lock_); MOZ_GUARDED_BY(ports_lock_);
// Maps a peer port name to a list of PortRefs for all local ports which have // Maps a peer port name to a list of PortRefs for all local ports which have
// the port name key designated as their peer port. The set of local ports // the port name key designated as their peer port. The set of local ports
@@ -316,7 +316,7 @@ class Node {
// port on a peer node. The key to this map is the corresponding peer node // port on a peer node. The key to this map is the corresponding peer node
// name. // name.
std::unordered_map<NodeName, PeerPortMap> peer_port_maps_ std::unordered_map<NodeName, PeerPortMap> peer_port_maps_
GUARDED_BY(ports_lock_); MOZ_GUARDED_BY(ports_lock_);
}; };
} // namespace ports } // namespace ports

View File

@@ -28,9 +28,9 @@ namespace detail {
// Ports cannot use mozilla::Mutex, as the acquires-before relationships handled // Ports cannot use mozilla::Mutex, as the acquires-before relationships handled
// by PortLocker can overload the debug-only deadlock detector. // by PortLocker can overload the debug-only deadlock detector.
class CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl { class MOZ_CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl {
public: public:
void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this) { void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this) {
#ifdef DEBUG #ifdef DEBUG
MOZ_ASSERT(mOwningThread == PR_GetCurrentThread()); MOZ_ASSERT(mOwningThread == PR_GetCurrentThread());
#endif #endif
@@ -40,13 +40,13 @@ class CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl {
// PortMutex should only be locked/unlocked via PortLocker // PortMutex should only be locked/unlocked via PortLocker
friend class ::mojo::core::ports::PortLocker; friend class ::mojo::core::ports::PortLocker;
void Lock() CAPABILITY_ACQUIRE() { void Lock() MOZ_CAPABILITY_ACQUIRE() {
::mozilla::detail::MutexImpl::lock(); ::mozilla::detail::MutexImpl::lock();
#ifdef DEBUG #ifdef DEBUG
mOwningThread = PR_GetCurrentThread(); mOwningThread = PR_GetCurrentThread();
#endif #endif
} }
void Unlock() CAPABILITY_RELEASE() { void Unlock() MOZ_CAPABILITY_RELEASE() {
#ifdef DEBUG #ifdef DEBUG
MOZ_ASSERT(mOwningThread == PR_GetCurrentThread()); MOZ_ASSERT(mOwningThread == PR_GetCurrentThread());
mOwningThread = nullptr; mOwningThread = nullptr;

View File

@@ -78,7 +78,7 @@ class AsyncBlockers {
} }
private: private:
void MaybeResolve() REQUIRES(mLock) { void MaybeResolve() MOZ_REQUIRES(mLock) {
mLock.AssertCurrentThreadOwns(); mLock.AssertCurrentThreadOwns();
if (mResolved) { if (mResolved) {
return; return;
@@ -90,8 +90,8 @@ class AsyncBlockers {
mResolved = true; mResolved = true;
} }
Mutex mLock; Mutex mLock;
nsTArray<void*> mBlockers GUARDED_BY(mLock); nsTArray<void*> mBlockers MOZ_GUARDED_BY(mLock);
bool mResolved GUARDED_BY(mLock) = false; bool mResolved MOZ_GUARDED_BY(mLock) = false;
const RefPtr<GenericPromise::Private> mPromise; const RefPtr<GenericPromise::Private> mPromise;
}; };

View File

@@ -51,7 +51,8 @@ class BrowserProcessSubThread : public base::Thread {
// The threads are not owned by this array. Typically, the threads are owned // The threads are not owned by this array. Typically, the threads are owned
// on the UI thread by the g_browser_process object. ChromeThreads remove // on the UI thread by the g_browser_process object. ChromeThreads remove
// themselves from this array upon destruction. // themselves from this array upon destruction.
static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] GUARDED_BY(sLock); static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] MOZ_GUARDED_BY(
sLock);
}; };
inline void AssertIOThread() { inline void AssertIOThread() {

View File

@@ -41,7 +41,8 @@ class CrashReporterClient {
private: private:
static StaticMutex sLock; static StaticMutex sLock;
static StaticRefPtr<CrashReporterClient> sClientSingleton GUARDED_BY(sLock); static StaticRefPtr<CrashReporterClient> sClientSingleton
MOZ_GUARDED_BY(sLock);
}; };
} // namespace ipc } // namespace ipc

View File

@@ -25,9 +25,9 @@ namespace data_pipe_detail {
// Helper for queueing up actions to be run once the mutex has been unlocked. // Helper for queueing up actions to be run once the mutex has been unlocked.
// Actions will be run in-order. // Actions will be run in-order.
class SCOPED_CAPABILITY DataPipeAutoLock { class MOZ_SCOPED_CAPABILITY DataPipeAutoLock {
public: public:
explicit DataPipeAutoLock(Mutex& aMutex) CAPABILITY_ACQUIRE(aMutex) explicit DataPipeAutoLock(Mutex& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex)
: mMutex(aMutex) { : mMutex(aMutex) {
mMutex.Lock(); mMutex.Lock();
} }
@@ -39,7 +39,7 @@ class SCOPED_CAPABILITY DataPipeAutoLock {
mActions.AppendElement(std::move(aAction)); mActions.AppendElement(std::move(aAction));
} }
~DataPipeAutoLock() CAPABILITY_RELEASE() { ~DataPipeAutoLock() MOZ_CAPABILITY_RELEASE() {
mMutex.Unlock(); mMutex.Unlock();
for (auto& action : mActions) { for (auto& action : mActions) {
action(); action();
@@ -82,7 +82,7 @@ class DataPipeLink : public NodeController::PortObserver {
mOffset(aOffset), mOffset(aOffset),
mAvailable(aAvailable) {} mAvailable(aAvailable) {}
void Init() EXCLUDES(*mMutex) { void Init() MOZ_EXCLUDES(*mMutex) {
{ {
DataPipeAutoLock lock(*mMutex); DataPipeAutoLock lock(*mMutex);
if (NS_FAILED(mPeerStatus)) { if (NS_FAILED(mPeerStatus)) {
@@ -94,18 +94,18 @@ class DataPipeLink : public NodeController::PortObserver {
OnPortStatusChanged(); OnPortStatusChanged();
} }
void OnPortStatusChanged() final EXCLUDES(*mMutex); void OnPortStatusChanged() final MOZ_EXCLUDES(*mMutex);
// Add a task to notify the callback after `aLock` is unlocked. // Add a task to notify the callback after `aLock` is unlocked.
// //
// This method is safe to call multiple times, as after the first time it is // This method is safe to call multiple times, as after the first time it is
// called, `mCallback` will be cleared. // called, `mCallback` will be cleared.
void NotifyOnUnlock(DataPipeAutoLock& aLock) REQUIRES(*mMutex) { void NotifyOnUnlock(DataPipeAutoLock& aLock) MOZ_REQUIRES(*mMutex) {
DoNotifyOnUnlock(aLock, mCallback.forget(), mCallbackTarget.forget()); DoNotifyOnUnlock(aLock, mCallback.forget(), mCallbackTarget.forget());
} }
void SendBytesConsumedOnUnlock(DataPipeAutoLock& aLock, uint32_t aBytes) void SendBytesConsumedOnUnlock(DataPipeAutoLock& aLock, uint32_t aBytes)
REQUIRES(*mMutex) { MOZ_REQUIRES(*mMutex) {
MOZ_LOG(gDataPipeLog, LogLevel::Verbose, MOZ_LOG(gDataPipeLog, LogLevel::Verbose,
("SendOnUnlock CONSUMED(%u) %s", aBytes, Describe(aLock).get())); ("SendOnUnlock CONSUMED(%u) %s", aBytes, Describe(aLock).get()));
if (NS_FAILED(mPeerStatus)) { if (NS_FAILED(mPeerStatus)) {
@@ -128,7 +128,7 @@ class DataPipeLink : public NodeController::PortObserver {
} }
void SetPeerError(DataPipeAutoLock& aLock, nsresult aStatus, void SetPeerError(DataPipeAutoLock& aLock, nsresult aStatus,
bool aSendClosed = false) REQUIRES(*mMutex) { bool aSendClosed = false) MOZ_REQUIRES(*mMutex) {
MOZ_LOG(gDataPipeLog, LogLevel::Debug, MOZ_LOG(gDataPipeLog, LogLevel::Debug,
("SetPeerError(%s%s) %s", GetStaticErrorName(aStatus), ("SetPeerError(%s%s) %s", GetStaticErrorName(aStatus),
aSendClosed ? ", send" : "", Describe(aLock).get())); aSendClosed ? ", send" : "", Describe(aLock).get()));
@@ -150,7 +150,7 @@ class DataPipeLink : public NodeController::PortObserver {
NotifyOnUnlock(aLock); NotifyOnUnlock(aLock);
} }
nsCString Describe(DataPipeAutoLock& aLock) const REQUIRES(*mMutex) { nsCString Describe(DataPipeAutoLock& aLock) const MOZ_REQUIRES(*mMutex) {
return nsPrintfCString( return nsPrintfCString(
"[%s(%p) c=%u e=%s o=%u a=%u, cb=%s]", "[%s(%p) c=%u e=%s o=%u a=%u, cb=%s]",
mReceiverSide ? "Receiver" : "Sender", this, mCapacity, mReceiverSide ? "Receiver" : "Sender", this, mCapacity,
@@ -162,20 +162,20 @@ class DataPipeLink : public NodeController::PortObserver {
// `DataPipeLink`. // `DataPipeLink`.
std::shared_ptr<Mutex> mMutex; std::shared_ptr<Mutex> mMutex;
ScopedPort mPort GUARDED_BY(*mMutex); ScopedPort mPort MOZ_GUARDED_BY(*mMutex);
const RefPtr<SharedMemory> mShmem; const RefPtr<SharedMemory> mShmem;
const uint32_t mCapacity; const uint32_t mCapacity;
const bool mReceiverSide; const bool mReceiverSide;
bool mProcessingSegment GUARDED_BY(*mMutex) = false; bool mProcessingSegment MOZ_GUARDED_BY(*mMutex) = false;
nsresult mPeerStatus GUARDED_BY(*mMutex) = NS_OK; nsresult mPeerStatus MOZ_GUARDED_BY(*mMutex) = NS_OK;
uint32_t mOffset GUARDED_BY(*mMutex) = 0; uint32_t mOffset MOZ_GUARDED_BY(*mMutex) = 0;
uint32_t mAvailable GUARDED_BY(*mMutex) = 0; uint32_t mAvailable MOZ_GUARDED_BY(*mMutex) = 0;
bool mCallbackClosureOnly GUARDED_BY(*mMutex) = false; bool mCallbackClosureOnly MOZ_GUARDED_BY(*mMutex) = false;
nsCOMPtr<nsIRunnable> mCallback GUARDED_BY(*mMutex); nsCOMPtr<nsIRunnable> mCallback MOZ_GUARDED_BY(*mMutex);
nsCOMPtr<nsIEventTarget> mCallbackTarget GUARDED_BY(*mMutex); nsCOMPtr<nsIEventTarget> mCallbackTarget MOZ_GUARDED_BY(*mMutex);
}; };
void DataPipeLink::OnPortStatusChanged() { void DataPipeLink::OnPortStatusChanged() {

View File

@@ -33,11 +33,11 @@ class DataPipeBase {
uint32_t aCapacity, nsresult aPeerStatus, uint32_t aOffset, uint32_t aCapacity, nsresult aPeerStatus, uint32_t aOffset,
uint32_t aAvailable); uint32_t aAvailable);
void CloseInternal(DataPipeAutoLock&, nsresult aStatus) REQUIRES(*mMutex); void CloseInternal(DataPipeAutoLock&, nsresult aStatus) MOZ_REQUIRES(*mMutex);
void AsyncWaitInternal(already_AddRefed<nsIRunnable> aCallback, void AsyncWaitInternal(already_AddRefed<nsIRunnable> aCallback,
already_AddRefed<nsIEventTarget> aTarget, already_AddRefed<nsIEventTarget> aTarget,
bool aClosureOnly) EXCLUDES(*mMutex); bool aClosureOnly) MOZ_EXCLUDES(*mMutex);
// Like `nsWriteSegmentFun` or `nsReadSegmentFun`. // Like `nsWriteSegmentFun` or `nsReadSegmentFun`.
using ProcessSegmentFun = using ProcessSegmentFun =
@@ -45,24 +45,25 @@ class DataPipeBase {
uint32_t* aProcessedCount)>; uint32_t* aProcessedCount)>;
nsresult ProcessSegmentsInternal(uint32_t aCount, nsresult ProcessSegmentsInternal(uint32_t aCount,
ProcessSegmentFun aProcessSegment, ProcessSegmentFun aProcessSegment,
uint32_t* aProcessedCount) EXCLUDES(*mMutex); uint32_t* aProcessedCount)
MOZ_EXCLUDES(*mMutex);
nsresult CheckStatus(DataPipeAutoLock&) REQUIRES(*mMutex); nsresult CheckStatus(DataPipeAutoLock&) MOZ_REQUIRES(*mMutex);
nsCString Describe(DataPipeAutoLock&) REQUIRES(*mMutex); nsCString Describe(DataPipeAutoLock&) MOZ_REQUIRES(*mMutex);
// Thread safety helper to tell the analysis that `mLink->mMutex` is held when // Thread safety helper to tell the analysis that `mLink->mMutex` is held when
// `mMutex` is held. // `mMutex` is held.
void AssertSameMutex(const std::shared_ptr<Mutex>& aMutex) REQUIRES(*mMutex) void AssertSameMutex(const std::shared_ptr<Mutex>& aMutex)
ASSERT_CAPABILITY(*aMutex) { MOZ_REQUIRES(*mMutex) MOZ_ASSERT_CAPABILITY(*aMutex) {
MOZ_ASSERT(mMutex == aMutex); MOZ_ASSERT(mMutex == aMutex);
} }
virtual ~DataPipeBase(); virtual ~DataPipeBase();
const std::shared_ptr<Mutex> mMutex; const std::shared_ptr<Mutex> mMutex;
nsresult mStatus GUARDED_BY(*mMutex) = NS_OK; nsresult mStatus MOZ_GUARDED_BY(*mMutex) = NS_OK;
RefPtr<DataPipeLink> mLink GUARDED_BY(*mMutex); RefPtr<DataPipeLink> mLink MOZ_GUARDED_BY(*mMutex);
}; };
template <typename T> template <typename T>

View File

@@ -898,7 +898,7 @@ void BaseProcessLauncher::GetChildLogName(const char* origLogName,
static mozilla::StaticMutex gIPCLaunchThreadMutex; static mozilla::StaticMutex gIPCLaunchThreadMutex;
static mozilla::StaticRefPtr<nsIThread> gIPCLaunchThread static mozilla::StaticRefPtr<nsIThread> gIPCLaunchThread
GUARDED_BY(gIPCLaunchThreadMutex); MOZ_GUARDED_BY(gIPCLaunchThreadMutex);
class IPCLaunchThreadObserver final : public nsIObserver { class IPCLaunchThreadObserver final : public nsIObserver {
public: public:

View File

@@ -216,7 +216,7 @@ class GeckoChildProcessHost : public ChildProcessHost,
// is well. // is well.
PROCESS_CONNECTED, PROCESS_CONNECTED,
PROCESS_ERROR PROCESS_ERROR
} mProcessState GUARDED_BY(mMonitor); } mProcessState MOZ_GUARDED_BY(mMonitor);
void PrepareLaunch(); void PrepareLaunch();
@@ -287,7 +287,7 @@ class GeckoChildProcessHost : public ChildProcessHost,
static uint32_t sNextUniqueID; static uint32_t sNextUniqueID;
static StaticAutoPtr<LinkedList<GeckoChildProcessHost>> static StaticAutoPtr<LinkedList<GeckoChildProcessHost>>
sGeckoChildProcessHosts GUARDED_BY(sMutex); sGeckoChildProcessHosts MOZ_GUARDED_BY(sMutex);
static StaticMutex sMutex; static StaticMutex sMutex;
}; };

View File

@@ -140,7 +140,7 @@ class AutoEnterTransaction {
public: public:
explicit AutoEnterTransaction(MessageChannel* aChan, int32_t aMsgSeqno, explicit AutoEnterTransaction(MessageChannel* aChan, int32_t aMsgSeqno,
int32_t aTransactionID, int aNestedLevel) int32_t aTransactionID, int aNestedLevel)
REQUIRES(*aChan->mMonitor) MOZ_REQUIRES(*aChan->mMonitor)
: mChan(aChan), : mChan(aChan),
mActive(true), mActive(true),
mOutgoing(true), mOutgoing(true),
@@ -154,7 +154,7 @@ class AutoEnterTransaction {
explicit AutoEnterTransaction(MessageChannel* aChan, explicit AutoEnterTransaction(MessageChannel* aChan,
const IPC::Message& aMessage) const IPC::Message& aMessage)
REQUIRES(*aChan->mMonitor) MOZ_REQUIRES(*aChan->mMonitor)
: mChan(aChan), : mChan(aChan),
mActive(true), mActive(true),
mOutgoing(false), mOutgoing(false),
@@ -356,7 +356,7 @@ class ChannelCountReporter final : public nsIMemoryReporter {
using CountTable = nsTHashMap<nsDepCharHashKey, ChannelCounts>; using CountTable = nsTHashMap<nsDepCharHashKey, ChannelCounts>;
static StaticMutex sChannelCountMutex; static StaticMutex sChannelCountMutex;
static CountTable* sChannelCounts GUARDED_BY(sChannelCountMutex); static CountTable* sChannelCounts MOZ_GUARDED_BY(sChannelCountMutex);
public: public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS

View File

@@ -48,8 +48,8 @@ class RefCountedMonitor : public Monitor {
public: public:
RefCountedMonitor() : Monitor("mozilla.ipc.MessageChannel.mMonitor") {} RefCountedMonitor() : Monitor("mozilla.ipc.MessageChannel.mMonitor") {}
void AssertSameMonitor(const RefCountedMonitor& aOther) const REQUIRES(*this) void AssertSameMonitor(const RefCountedMonitor& aOther) const
ASSERT_CAPABILITY(aOther) { MOZ_REQUIRES(*this) MOZ_ASSERT_CAPABILITY(aOther) {
MOZ_ASSERT(this == &aOther); MOZ_ASSERT(this == &aOther);
} }
@@ -196,18 +196,18 @@ class MessageChannel : HasResultCodes {
* This sends a special message that is processed on the IO thread, so that * This sends a special message that is processed on the IO thread, so that
* other actors can know that the process will soon shutdown. * other actors can know that the process will soon shutdown.
*/ */
void NotifyImpendingShutdown() EXCLUDES(*mMonitor); void NotifyImpendingShutdown() MOZ_EXCLUDES(*mMonitor);
// Close the underlying transport channel. // Close the underlying transport channel.
void Close() EXCLUDES(*mMonitor); void Close() MOZ_EXCLUDES(*mMonitor);
// Force the channel to behave as if a channel error occurred. Valid // Force the channel to behave as if a channel error occurred. Valid
// for process links only, not thread links. // for process links only, not thread links.
void CloseWithError() EXCLUDES(*mMonitor); void CloseWithError() MOZ_EXCLUDES(*mMonitor);
void CloseWithTimeout() EXCLUDES(*mMonitor); void CloseWithTimeout() MOZ_EXCLUDES(*mMonitor);
void SetAbortOnError(bool abort) EXCLUDES(*mMonitor) { void SetAbortOnError(bool abort) MOZ_EXCLUDES(*mMonitor) {
MonitorAutoLock lock(*mMonitor); MonitorAutoLock lock(*mMonitor);
mAbortOnError = abort; mAbortOnError = abort;
} }
@@ -216,7 +216,7 @@ class MessageChannel : HasResultCodes {
// XXX: You must get permission from an IPC peer to use this function // XXX: You must get permission from an IPC peer to use this function
// since it requires custom deserialization and re-orders events. // since it requires custom deserialization and re-orders events.
void PeekMessages(const std::function<bool(const Message& aMsg)>& aInvoke) void PeekMessages(const std::function<bool(const Message& aMsg)>& aInvoke)
EXCLUDES(*mMonitor); MOZ_EXCLUDES(*mMonitor);
// Misc. behavioral traits consumers can request for this channel // Misc. behavioral traits consumers can request for this channel
enum ChannelFlags { enum ChannelFlags {
@@ -237,14 +237,14 @@ class MessageChannel : HasResultCodes {
ChannelFlags GetChannelFlags() { return mFlags; } ChannelFlags GetChannelFlags() { return mFlags; }
// Asynchronously send a message to the other side of the channel // Asynchronously send a message to the other side of the channel
bool Send(UniquePtr<Message> aMsg) EXCLUDES(*mMonitor); bool Send(UniquePtr<Message> aMsg) MOZ_EXCLUDES(*mMonitor);
// Asynchronously send a message to the other side of the channel // Asynchronously send a message to the other side of the channel
// and wait for asynchronous reply. // and wait for asynchronous reply.
template <typename Value> template <typename Value>
void Send(UniquePtr<Message> aMsg, ActorIdType aActorId, void Send(UniquePtr<Message> aMsg, ActorIdType aActorId,
ResolveCallback<Value>&& aResolve, RejectCallback&& aReject) ResolveCallback<Value>&& aResolve, RejectCallback&& aReject)
EXCLUDES(*mMonitor) { MOZ_EXCLUDES(*mMonitor) {
int32_t seqno = NextSeqno(); int32_t seqno = NextSeqno();
aMsg->set_seqno(seqno); aMsg->set_seqno(seqno);
if (!Send(std::move(aMsg))) { if (!Send(std::move(aMsg))) {
@@ -259,17 +259,18 @@ class MessageChannel : HasResultCodes {
gUnresolvedResponses++; gUnresolvedResponses++;
} }
bool SendBuildIDsMatchMessage(const char* aParentBuildID) EXCLUDES(*mMonitor); bool SendBuildIDsMatchMessage(const char* aParentBuildID)
bool DoBuildIDsMatch() EXCLUDES(*mMonitor) { MOZ_EXCLUDES(*mMonitor);
bool DoBuildIDsMatch() MOZ_EXCLUDES(*mMonitor) {
MonitorAutoLock lock(*mMonitor); MonitorAutoLock lock(*mMonitor);
return mBuildIDsConfirmedMatch; return mBuildIDsConfirmedMatch;
} }
// Synchronously send |aMsg| (i.e., wait for |aReply|) // Synchronously send |aMsg| (i.e., wait for |aReply|)
bool Send(UniquePtr<Message> aMsg, UniquePtr<Message>* aReply) bool Send(UniquePtr<Message> aMsg, UniquePtr<Message>* aReply)
EXCLUDES(*mMonitor); MOZ_EXCLUDES(*mMonitor);
bool CanSend() const EXCLUDES(*mMonitor); bool CanSend() const MOZ_EXCLUDES(*mMonitor);
// Remove and return a callback that needs reply // Remove and return a callback that needs reply
UniquePtr<UntypedCallbackHolder> PopCallback(const Message& aMsg); UniquePtr<UntypedCallbackHolder> PopCallback(const Message& aMsg);
@@ -289,15 +290,15 @@ class MessageChannel : HasResultCodes {
bool IsOnCxxStack() const { return mOnCxxStack; } bool IsOnCxxStack() const { return mOnCxxStack; }
void CancelCurrentTransaction() EXCLUDES(*mMonitor); void CancelCurrentTransaction() MOZ_EXCLUDES(*mMonitor);
// IsClosed and NumQueuedMessages are safe to call from any thread, but // IsClosed and NumQueuedMessages are safe to call from any thread, but
// may provide an out-of-date value. // may provide an out-of-date value.
bool IsClosed() EXCLUDES(*mMonitor) { bool IsClosed() MOZ_EXCLUDES(*mMonitor) {
MonitorAutoLock lock(*mMonitor); MonitorAutoLock lock(*mMonitor);
return IsClosedLocked(); return IsClosedLocked();
} }
bool IsClosedLocked() const REQUIRES(*mMonitor) { bool IsClosedLocked() const MOZ_REQUIRES(*mMonitor) {
mMonitor->AssertCurrentThreadOwns(); mMonitor->AssertCurrentThreadOwns();
return mLink ? mLink->IsClosed() : true; return mLink ? mLink->IsClosed() : true;
} }
@@ -310,8 +311,8 @@ class MessageChannel : HasResultCodes {
/** /**
* Does this MessageChannel currently cross process boundaries? * Does this MessageChannel currently cross process boundaries?
*/ */
bool IsCrossProcess() const REQUIRES(*mMonitor); bool IsCrossProcess() const MOZ_REQUIRES(*mMonitor);
void SetIsCrossProcess(bool aIsCrossProcess) REQUIRES(*mMonitor); void SetIsCrossProcess(bool aIsCrossProcess) MOZ_REQUIRES(*mMonitor);
#ifdef FUZZING_SNAPSHOT #ifdef FUZZING_SNAPSHOT
Maybe<mojo::core::ports::PortName> GetPortName() { Maybe<mojo::core::ports::PortName> GetPortName() {
@@ -365,37 +366,39 @@ class MessageChannel : HasResultCodes {
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
private: private:
void PostErrorNotifyTask() REQUIRES(*mMonitor); void PostErrorNotifyTask() MOZ_REQUIRES(*mMonitor);
void OnNotifyMaybeChannelError() EXCLUDES(*mMonitor); void OnNotifyMaybeChannelError() MOZ_EXCLUDES(*mMonitor);
void ReportConnectionError(const char* aFunctionName, void ReportConnectionError(const char* aFunctionName,
const uint32_t aMsgTyp) const REQUIRES(*mMonitor); const uint32_t aMsgTyp) const
MOZ_REQUIRES(*mMonitor);
void ReportMessageRouteError(const char* channelName) const void ReportMessageRouteError(const char* channelName) const
EXCLUDES(*mMonitor); MOZ_EXCLUDES(*mMonitor);
bool MaybeHandleError(Result code, const Message& aMsg, bool MaybeHandleError(Result code, const Message& aMsg,
const char* channelName) EXCLUDES(*mMonitor); const char* channelName) MOZ_EXCLUDES(*mMonitor);
void Clear() REQUIRES(*mMonitor); void Clear() MOZ_REQUIRES(*mMonitor);
bool HasPendingEvents() REQUIRES(*mMonitor); bool HasPendingEvents() MOZ_REQUIRES(*mMonitor);
void ProcessPendingRequests(ActorLifecycleProxy* aProxy, void ProcessPendingRequests(ActorLifecycleProxy* aProxy,
AutoEnterTransaction& aTransaction) AutoEnterTransaction& aTransaction)
REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
bool ProcessPendingRequest(ActorLifecycleProxy* aProxy, bool ProcessPendingRequest(ActorLifecycleProxy* aProxy,
UniquePtr<Message> aUrgent) REQUIRES(*mMonitor); UniquePtr<Message> aUrgent)
MOZ_REQUIRES(*mMonitor);
void EnqueuePendingMessages() REQUIRES(*mMonitor); void EnqueuePendingMessages() MOZ_REQUIRES(*mMonitor);
// Dispatches an incoming message to its appropriate handler. // Dispatches an incoming message to its appropriate handler.
void DispatchMessage(ActorLifecycleProxy* aProxy, UniquePtr<Message> aMsg) void DispatchMessage(ActorLifecycleProxy* aProxy, UniquePtr<Message> aMsg)
REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
// DispatchMessage will route to one of these functions depending on the // DispatchMessage will route to one of these functions depending on the
// protocol type of the message. // protocol type of the message.
void DispatchSyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg, void DispatchSyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg,
UniquePtr<Message>& aReply) EXCLUDES(*mMonitor); UniquePtr<Message>& aReply) MOZ_EXCLUDES(*mMonitor);
void DispatchAsyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg) void DispatchAsyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg)
EXCLUDES(*mMonitor); MOZ_EXCLUDES(*mMonitor);
// Return true if the wait ended because a notification was received. // Return true if the wait ended because a notification was received.
// //
@@ -407,16 +410,16 @@ class MessageChannel : HasResultCodes {
// //
// So in sum: true is a meaningful return value; false isn't, // So in sum: true is a meaningful return value; false isn't,
// necessarily. // necessarily.
bool WaitForSyncNotify(bool aHandleWindowsMessages) REQUIRES(*mMonitor); bool WaitForSyncNotify(bool aHandleWindowsMessages) MOZ_REQUIRES(*mMonitor);
bool WaitResponse(bool aWaitTimedOut); bool WaitResponse(bool aWaitTimedOut);
bool ShouldContinueFromTimeout() REQUIRES(*mMonitor); bool ShouldContinueFromTimeout() MOZ_REQUIRES(*mMonitor);
void EndTimeout() REQUIRES(*mMonitor); void EndTimeout() MOZ_REQUIRES(*mMonitor);
void CancelTransaction(int transaction) REQUIRES(*mMonitor); void CancelTransaction(int transaction) MOZ_REQUIRES(*mMonitor);
void RepostAllMessages() REQUIRES(*mMonitor); void RepostAllMessages() MOZ_REQUIRES(*mMonitor);
int32_t NextSeqno() { int32_t NextSeqno() {
AssertWorkerThread(); AssertWorkerThread();
@@ -424,10 +427,10 @@ class MessageChannel : HasResultCodes {
} }
void DebugAbort(const char* file, int line, const char* cond, const char* why, void DebugAbort(const char* file, int line, const char* cond, const char* why,
bool reply = false) REQUIRES(*mMonitor); bool reply = false) MOZ_REQUIRES(*mMonitor);
void AddProfilerMarker(const IPC::Message& aMessage, void AddProfilerMarker(const IPC::Message& aMessage,
MessageDirection aDirection) REQUIRES(*mMonitor); MessageDirection aDirection) MOZ_REQUIRES(*mMonitor);
private: private:
// Returns true if we're dispatching an async message's callback. // Returns true if we're dispatching an async message's callback.
@@ -441,18 +444,19 @@ class MessageChannel : HasResultCodes {
return mDispatchingAsyncMessageNestedLevel; return mDispatchingAsyncMessageNestedLevel;
} }
bool Connected() const REQUIRES(*mMonitor); bool Connected() const MOZ_REQUIRES(*mMonitor);
private: private:
// Executed on the IO thread. // Executed on the IO thread.
void NotifyWorkerThread() REQUIRES(*mMonitor); void NotifyWorkerThread() MOZ_REQUIRES(*mMonitor);
// Return true if |aMsg| is a special message targeted at the IO // Return true if |aMsg| is a special message targeted at the IO
// thread, in which case it shouldn't be delivered to the worker. // thread, in which case it shouldn't be delivered to the worker.
bool MaybeInterceptSpecialIOMessage(const Message& aMsg) REQUIRES(*mMonitor); bool MaybeInterceptSpecialIOMessage(const Message& aMsg)
MOZ_REQUIRES(*mMonitor);
// Tell the IO thread to close the channel and wait for it to ACK. // Tell the IO thread to close the channel and wait for it to ACK.
void SynchronouslyClose() REQUIRES(*mMonitor); void SynchronouslyClose() MOZ_REQUIRES(*mMonitor);
// Returns true if ShouldDeferMessage(aMsg) is guaranteed to return true. // Returns true if ShouldDeferMessage(aMsg) is guaranteed to return true.
// Otherwise, the result of ShouldDeferMessage(aMsg) may be true or false, // Otherwise, the result of ShouldDeferMessage(aMsg) may be true or false,
@@ -461,12 +465,13 @@ class MessageChannel : HasResultCodes {
// Helper for sending a message via the link. This should only be used for // Helper for sending a message via the link. This should only be used for
// non-special messages that might have to be postponed. // non-special messages that might have to be postponed.
void SendMessageToLink(UniquePtr<Message> aMsg) REQUIRES(*mMonitor); void SendMessageToLink(UniquePtr<Message> aMsg) MOZ_REQUIRES(*mMonitor);
bool WasTransactionCanceled(int transaction); bool WasTransactionCanceled(int transaction);
bool ShouldDeferMessage(const Message& aMsg) REQUIRES(*mMonitor); bool ShouldDeferMessage(const Message& aMsg) MOZ_REQUIRES(*mMonitor);
void OnMessageReceivedFromLink(UniquePtr<Message> aMsg) REQUIRES(*mMonitor); void OnMessageReceivedFromLink(UniquePtr<Message> aMsg)
void OnChannelErrorFromLink() REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
void OnChannelErrorFromLink() MOZ_REQUIRES(*mMonitor);
private: private:
// Clear this channel, and notify the listener that the channel has either // Clear this channel, and notify the listener that the channel has either
@@ -477,9 +482,9 @@ class MessageChannel : HasResultCodes {
// listener is called, allowing for the monitor to be unlocked before the // listener is called, allowing for the monitor to be unlocked before the
// MessageChannel is potentially destroyed. // MessageChannel is potentially destroyed.
void NotifyChannelClosed(ReleasableMonitorAutoLock& aLock) void NotifyChannelClosed(ReleasableMonitorAutoLock& aLock)
REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
void NotifyMaybeChannelError(ReleasableMonitorAutoLock& aLock) void NotifyMaybeChannelError(ReleasableMonitorAutoLock& aLock)
REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
private: private:
void AssertWorkerThread() const { void AssertWorkerThread() const {
@@ -504,31 +509,31 @@ class MessageChannel : HasResultCodes {
nsresult Cancel() override; nsresult Cancel() override;
NS_IMETHOD GetPriority(uint32_t* aPriority) override; NS_IMETHOD GetPriority(uint32_t* aPriority) override;
NS_DECL_NSIRUNNABLEIPCMESSAGETYPE NS_DECL_NSIRUNNABLEIPCMESSAGETYPE
void Post() REQUIRES(*mMonitor); void Post() MOZ_REQUIRES(*mMonitor);
bool IsScheduled() const REQUIRES(*mMonitor) { bool IsScheduled() const MOZ_REQUIRES(*mMonitor) {
mMonitor->AssertCurrentThreadOwns(); mMonitor->AssertCurrentThreadOwns();
return mScheduled; return mScheduled;
} }
UniquePtr<Message>& Msg() REQUIRES(*mMonitor) { UniquePtr<Message>& Msg() MOZ_REQUIRES(*mMonitor) {
MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved"); MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved");
return mMessage; return mMessage;
} }
const UniquePtr<Message>& Msg() const REQUIRES(*mMonitor) { const UniquePtr<Message>& Msg() const MOZ_REQUIRES(*mMonitor) {
MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved"); MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved");
return mMessage; return mMessage;
} }
void AssertMonitorHeld(const RefCountedMonitor& aMonitor) REQUIRES(aMonitor) void AssertMonitorHeld(const RefCountedMonitor& aMonitor)
ASSERT_CAPABILITY(*mMonitor) { MOZ_REQUIRES(aMonitor) MOZ_ASSERT_CAPABILITY(*mMonitor) {
aMonitor.AssertSameMonitor(*mMonitor); aMonitor.AssertSameMonitor(*mMonitor);
} }
private: private:
~MessageTask(); ~MessageTask();
MessageChannel* Channel() REQUIRES(*mMonitor) { MessageChannel* Channel() MOZ_REQUIRES(*mMonitor) {
mMonitor->AssertCurrentThreadOwns(); mMonitor->AssertCurrentThreadOwns();
MOZ_RELEASE_ASSERT(isInList()); MOZ_RELEASE_ASSERT(isInList());
return mChannel; return mChannel;
@@ -540,18 +545,18 @@ class MessageChannel : HasResultCodes {
// The channel which this MessageTask is associated with. Only valid while // The channel which this MessageTask is associated with. Only valid while
// `mMonitor` is held, and this MessageTask `isInList()`. // `mMonitor` is held, and this MessageTask `isInList()`.
MessageChannel* const mChannel; MessageChannel* const mChannel;
UniquePtr<Message> mMessage GUARDED_BY(*mMonitor); UniquePtr<Message> mMessage MOZ_GUARDED_BY(*mMonitor);
uint32_t const mPriority; uint32_t const mPriority;
bool mScheduled : 1 GUARDED_BY(*mMonitor); bool mScheduled : 1 MOZ_GUARDED_BY(*mMonitor);
#ifdef FUZZING_SNAPSHOT #ifdef FUZZING_SNAPSHOT
const bool mIsFuzzMsg; const bool mIsFuzzMsg;
bool mFuzzStopped GUARDED_BY(*mMonitor); bool mFuzzStopped MOZ_GUARDED_BY(*mMonitor);
#endif #endif
}; };
bool ShouldRunMessage(const Message& aMsg) REQUIRES(*mMonitor); bool ShouldRunMessage(const Message& aMsg) MOZ_REQUIRES(*mMonitor);
void RunMessage(ActorLifecycleProxy* aProxy, MessageTask& aTask) void RunMessage(ActorLifecycleProxy* aProxy, MessageTask& aTask)
REQUIRES(*mMonitor); MOZ_REQUIRES(*mMonitor);
class WorkerTargetShutdownTask final : public nsITargetShutdownTask { class WorkerTargetShutdownTask final : public nsITargetShutdownTask {
public: public:
@@ -589,13 +594,13 @@ class MessageChannel : HasResultCodes {
// `MessageChannel`. // `MessageChannel`.
RefPtr<RefCountedMonitor> const mMonitor; RefPtr<RefCountedMonitor> const mMonitor;
ChannelState mChannelState GUARDED_BY(*mMonitor) = ChannelClosed; ChannelState mChannelState MOZ_GUARDED_BY(*mMonitor) = ChannelClosed;
Side mSide = UnknownSide; Side mSide = UnknownSide;
bool mIsCrossProcess GUARDED_BY(*mMonitor) = false; bool mIsCrossProcess MOZ_GUARDED_BY(*mMonitor) = false;
UniquePtr<MessageLink> mLink GUARDED_BY(*mMonitor); UniquePtr<MessageLink> mLink MOZ_GUARDED_BY(*mMonitor);
// NotifyMaybeChannelError runnable // NotifyMaybeChannelError runnable
RefPtr<CancelableRunnable> mChannelErrorTask GUARDED_BY(*mMonitor); RefPtr<CancelableRunnable> mChannelErrorTask MOZ_GUARDED_BY(*mMonitor);
// Thread we are allowed to send and receive on. Set in Open(); never // Thread we are allowed to send and receive on. Set in Open(); never
// changed, and we can only call Open() once. We shouldn't be accessing // changed, and we can only call Open() once. We shouldn't be accessing
@@ -603,7 +608,7 @@ class MessageChannel : HasResultCodes {
nsCOMPtr<nsISerialEventTarget> mWorkerThread; nsCOMPtr<nsISerialEventTarget> mWorkerThread;
// Shutdown task to close the channel before mWorkerThread goes away. // Shutdown task to close the channel before mWorkerThread goes away.
RefPtr<WorkerTargetShutdownTask> mShutdownTask GUARDED_BY(*mMonitor); RefPtr<WorkerTargetShutdownTask> mShutdownTask MOZ_GUARDED_BY(*mMonitor);
// Timeout periods are broken up in two to prevent system suspension from // Timeout periods are broken up in two to prevent system suspension from
// triggering an abort. This method (called by WaitForEvent with a 'did // triggering an abort. This method (called by WaitForEvent with a 'did
@@ -666,20 +671,20 @@ class MessageChannel : HasResultCodes {
// which grow in opposite directions from child to parent. // which grow in opposite directions from child to parent.
friend class AutoEnterTransaction; friend class AutoEnterTransaction;
AutoEnterTransaction* mTransactionStack GUARDED_BY(*mMonitor) = nullptr; AutoEnterTransaction* mTransactionStack MOZ_GUARDED_BY(*mMonitor) = nullptr;
int32_t CurrentNestedInsideSyncTransaction() const REQUIRES(*mMonitor); int32_t CurrentNestedInsideSyncTransaction() const MOZ_REQUIRES(*mMonitor);
bool AwaitingSyncReply() const REQUIRES(*mMonitor); bool AwaitingSyncReply() const MOZ_REQUIRES(*mMonitor);
int AwaitingSyncReplyNestedLevel() const REQUIRES(*mMonitor); int AwaitingSyncReplyNestedLevel() const MOZ_REQUIRES(*mMonitor);
bool DispatchingSyncMessage() const REQUIRES(*mMonitor); bool DispatchingSyncMessage() const MOZ_REQUIRES(*mMonitor);
int DispatchingSyncMessageNestedLevel() const REQUIRES(*mMonitor); int DispatchingSyncMessageNestedLevel() const MOZ_REQUIRES(*mMonitor);
#ifdef DEBUG #ifdef DEBUG
void AssertMaybeDeferredCountCorrect() REQUIRES(*mMonitor); void AssertMaybeDeferredCountCorrect() MOZ_REQUIRES(*mMonitor);
#else #else
void AssertMaybeDeferredCountCorrect() REQUIRES(*mMonitor) {} void AssertMaybeDeferredCountCorrect() MOZ_REQUIRES(*mMonitor) {}
#endif #endif
// If a sync message times out, we store its sequence number here. Any // If a sync message times out, we store its sequence number here. Any
@@ -695,8 +700,8 @@ class MessageChannel : HasResultCodes {
// A message is only timed out if it initiated a transaction. This avoids // A message is only timed out if it initiated a transaction. This avoids
// hitting a lot of corner cases with message nesting that we don't really // hitting a lot of corner cases with message nesting that we don't really
// care about. // care about.
int32_t mTimedOutMessageSeqno GUARDED_BY(*mMonitor) = 0; int32_t mTimedOutMessageSeqno MOZ_GUARDED_BY(*mMonitor) = 0;
int mTimedOutMessageNestedLevel GUARDED_BY(*mMonitor) = 0; int mTimedOutMessageNestedLevel MOZ_GUARDED_BY(*mMonitor) = 0;
// Queue of all incoming messages. // Queue of all incoming messages.
// //
@@ -706,12 +711,12 @@ class MessageChannel : HasResultCodes {
// blocked, and thus can't send us any more messages until we process the sync // blocked, and thus can't send us any more messages until we process the sync
// in-msg. // in-msg.
// //
MessageQueue mPending GUARDED_BY(*mMonitor); MessageQueue mPending MOZ_GUARDED_BY(*mMonitor);
// The number of messages in mPending for which IsAlwaysDeferred is false // The number of messages in mPending for which IsAlwaysDeferred is false
// (i.e., the number of messages that might not be deferred, depending on // (i.e., the number of messages that might not be deferred, depending on
// context). // context).
size_t mMaybeDeferredPendingCount GUARDED_BY(*mMonitor) = 0; size_t mMaybeDeferredPendingCount MOZ_GUARDED_BY(*mMonitor) = 0;
// Is there currently MessageChannel logic for this channel on the C++ stack? // Is there currently MessageChannel logic for this channel on the C++ stack?
// This member is only accessed on the worker thread, and so is not protected // This member is only accessed on the worker thread, and so is not protected
@@ -727,16 +732,16 @@ class MessageChannel : HasResultCodes {
// Should the channel abort the process from the I/O thread when // Should the channel abort the process from the I/O thread when
// a channel error occurs? // a channel error occurs?
bool mAbortOnError GUARDED_BY(*mMonitor) = false; bool mAbortOnError MOZ_GUARDED_BY(*mMonitor) = false;
// True if the listener has already been notified of a channel close or // True if the listener has already been notified of a channel close or
// error. // error.
bool mNotifiedChannelDone GUARDED_BY(*mMonitor) = false; bool mNotifiedChannelDone MOZ_GUARDED_BY(*mMonitor) = false;
// See SetChannelFlags // See SetChannelFlags
ChannelFlags mFlags = REQUIRE_DEFAULT; ChannelFlags mFlags = REQUIRE_DEFAULT;
bool mBuildIDsConfirmedMatch GUARDED_BY(*mMonitor) = false; bool mBuildIDsConfirmedMatch MOZ_GUARDED_BY(*mMonitor) = false;
// If this is true, both ends of this message channel have event targets // If this is true, both ends of this message channel have event targets
// on the same thread. // on the same thread.

View File

@@ -133,7 +133,7 @@ class MessagePumpForNonMainUIThreads final : public base::MessagePumpForUI,
private: private:
~MessagePumpForNonMainUIThreads() {} ~MessagePumpForNonMainUIThreads() {}
bool mInWait GUARDED_BY(mWaitLock); bool mInWait MOZ_GUARDED_BY(mWaitLock);
mozilla::Mutex mWaitLock; mozilla::Mutex mWaitLock;
}; };
#endif // defined(XP_WIN) #endif // defined(XP_WIN)

View File

@@ -38,13 +38,13 @@ namespace mozilla {
namespace mscom { namespace mscom {
namespace detail { namespace detail {
class CAPABILITY LiveSet final { class MOZ_CAPABILITY LiveSet final {
public: public:
LiveSet() : mMutex("mozilla::mscom::LiveSet::mMutex") {} LiveSet() : mMutex("mozilla::mscom::LiveSet::mMutex") {}
void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); } void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); }
void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); }
void Put(IUnknown* aKey, already_AddRefed<IWeakReference> aValue) { void Put(IUnknown* aKey, already_AddRefed<IWeakReference> aValue) {
mMutex.AssertCurrentThreadOwns(); mMutex.AssertCurrentThreadOwns();
@@ -72,20 +72,20 @@ class CAPABILITY LiveSet final {
* We don't use the normal XPCOM BaseAutoLock because we need the ability * We don't use the normal XPCOM BaseAutoLock because we need the ability
* to explicitly Unlock. * to explicitly Unlock.
*/ */
class MOZ_RAII SCOPED_CAPABILITY LiveSetAutoLock final { class MOZ_RAII MOZ_SCOPED_CAPABILITY LiveSetAutoLock final {
public: public:
explicit LiveSetAutoLock(LiveSet& aLiveSet) CAPABILITY_ACQUIRE(aLiveSet) explicit LiveSetAutoLock(LiveSet& aLiveSet) MOZ_CAPABILITY_ACQUIRE(aLiveSet)
: mLiveSet(&aLiveSet) { : mLiveSet(&aLiveSet) {
aLiveSet.Lock(); aLiveSet.Lock();
} }
~LiveSetAutoLock() CAPABILITY_RELEASE() { ~LiveSetAutoLock() MOZ_CAPABILITY_RELEASE() {
if (mLiveSet) { if (mLiveSet) {
mLiveSet->Unlock(); mLiveSet->Unlock();
} }
} }
void Unlock() CAPABILITY_RELEASE() { void Unlock() MOZ_CAPABILITY_RELEASE() {
MOZ_ASSERT(mLiveSet); MOZ_ASSERT(mLiveSet);
if (mLiveSet) { if (mLiveSet) {
mLiveSet->Unlock(); mLiveSet->Unlock();
@@ -466,7 +466,7 @@ HRESULT
Interceptor::PublishTarget(detail::LiveSetAutoLock& aLiveSetLock, Interceptor::PublishTarget(detail::LiveSetAutoLock& aLiveSetLock,
RefPtr<IUnknown> aInterceptor, REFIID aTargetIid, RefPtr<IUnknown> aInterceptor, REFIID aTargetIid,
STAUniquePtr<IUnknown> aTarget) STAUniquePtr<IUnknown> aTarget)
NO_THREAD_SAFETY_ANALYSIS { MOZ_NO_THREAD_SAFETY_ANALYSIS {
// Suppress thread safety analysis as this conditionally releases locks. // Suppress thread safety analysis as this conditionally releases locks.
RefPtr<IWeakReference> weakRef; RefPtr<IWeakReference> weakRef;
HRESULT hr = GetWeakReference(getter_AddRefs(weakRef)); HRESULT hr = GetWeakReference(getter_AddRefs(weakRef));
@@ -494,7 +494,7 @@ HRESULT
Interceptor::GetInitialInterceptorForIID( Interceptor::GetInitialInterceptorForIID(
detail::LiveSetAutoLock& aLiveSetLock, REFIID aTargetIid, detail::LiveSetAutoLock& aLiveSetLock, REFIID aTargetIid,
STAUniquePtr<IUnknown> aTarget, STAUniquePtr<IUnknown> aTarget,
void** aOutInterceptor) NO_THREAD_SAFETY_ANALYSIS { void** aOutInterceptor) MOZ_NO_THREAD_SAFETY_ANALYSIS {
// Suppress thread safety analysis as this conditionally releases locks. // Suppress thread safety analysis as this conditionally releases locks.
MOZ_ASSERT(aOutInterceptor); MOZ_ASSERT(aOutInterceptor);
MOZ_ASSERT(aTargetIid != IID_IMarshal); MOZ_ASSERT(aTargetIid != IID_IMarshal);
@@ -504,9 +504,9 @@ Interceptor::GetInitialInterceptorForIID(
auto hasFailed = [&hr]() -> bool { return FAILED(hr); }; auto hasFailed = [&hr]() -> bool { return FAILED(hr); };
PUSH_IGNORE_THREAD_SAFETY // Avoid the lambda upsetting analysis. MOZ_PUSH_IGNORE_THREAD_SAFETY // Avoid the lambda upsetting analysis.
auto cleanup = [&aLiveSetLock]() -> void { aLiveSetLock.Unlock(); }; auto cleanup = [&aLiveSetLock]() -> void { aLiveSetLock.Unlock(); };
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
ExecuteWhen<decltype(hasFailed), decltype(cleanup)> onFail(hasFailed, ExecuteWhen<decltype(hasFailed), decltype(cleanup)> onFail(hasFailed,
cleanup); cleanup);

View File

@@ -423,7 +423,7 @@ class ScriptPreloader : public nsIObserver,
Result<Ok, nsresult> OpenCache(); Result<Ok, nsresult> OpenCache();
// Writes a new cache file to disk. Must not be called on the main thread. // Writes a new cache file to disk. Must not be called on the main thread.
Result<Ok, nsresult> WriteCache() REQUIRES(mSaveMonitor); Result<Ok, nsresult> WriteCache() MOZ_REQUIRES(mSaveMonitor);
void StartCacheWrite(); void StartCacheWrite();
@@ -488,7 +488,7 @@ class ScriptPreloader : public nsIObserver,
bool mSaveComplete = false; bool mSaveComplete = false;
bool mDataPrepared = false; bool mDataPrepared = false;
// May only be changed on the main thread, while `mSaveMonitor` is held. // May only be changed on the main thread, while `mSaveMonitor` is held.
bool mCacheInvalidated GUARDED_BY(mSaveMonitor) = false; bool mCacheInvalidated MOZ_GUARDED_BY(mSaveMonitor) = false;
// The list of scripts that we read from the initial startup cache file, // The list of scripts that we read from the initial startup cache file,
// but have yet to initiate a decode task for. // but have yet to initiate a decode task for.
@@ -504,11 +504,11 @@ class ScriptPreloader : public nsIObserver,
// True if a runnable has been dispatched to the main thread to finish an // True if a runnable has been dispatched to the main thread to finish an
// off-thread decode operation. Access only while 'mMonitor' is held. // off-thread decode operation. Access only while 'mMonitor' is held.
bool mFinishDecodeRunnablePending GUARDED_BY(mMonitor) = false; bool mFinishDecodeRunnablePending MOZ_GUARDED_BY(mMonitor) = false;
// True is main-thread is blocked and we should notify with Monitor. Access // True is main-thread is blocked and we should notify with Monitor. Access
// only while `mMonitor` is held. // only while `mMonitor` is held.
bool mWaitingForDecode GUARDED_BY(mMonitor) = false; bool mWaitingForDecode MOZ_GUARDED_BY(mMonitor) = false;
// The process type of the current process. // The process type of the current process.
static ProcessType sProcessType; static ProcessType sProcessType;
@@ -534,7 +534,7 @@ class ScriptPreloader : public nsIObserver,
AutoMemMap* mCacheData; AutoMemMap* mCacheData;
Monitor mMonitor; Monitor mMonitor;
MonitorSingleWriter mSaveMonitor ACQUIRED_BEFORE(mMonitor); MonitorSingleWriter mSaveMonitor MOZ_ACQUIRED_BEFORE(mMonitor);
}; };
} // namespace mozilla } // namespace mozilla

View File

@@ -241,7 +241,7 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet {
mutable RecursiveMutex mMutex; mutable RecursiveMutex mMutex;
FontFaceSet* MOZ_NON_OWNING_REF mOwner GUARDED_BY(mMutex); FontFaceSet* MOZ_NON_OWNING_REF mOwner MOZ_GUARDED_BY(mMutex);
// The document's node principal, which is the principal font loads for // The document's node principal, which is the principal font loads for
// this FontFaceSet will generally use. (This principal is not used for // this FontFaceSet will generally use. (This principal is not used for
@@ -255,19 +255,19 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet {
// Because mDocument's principal can change over time, // Because mDocument's principal can change over time,
// its value must be updated by a call to ResetStandardFontLoadPrincipal. // its value must be updated by a call to ResetStandardFontLoadPrincipal.
mutable RefPtr<gfxFontSrcPrincipal> mStandardFontLoadPrincipal mutable RefPtr<gfxFontSrcPrincipal> mStandardFontLoadPrincipal
GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
// Set of all loaders pointing to us. These are not strong pointers, // Set of all loaders pointing to us. These are not strong pointers,
// but that's OK because nsFontFaceLoader always calls RemoveLoader on // but that's OK because nsFontFaceLoader always calls RemoveLoader on
// us before it dies (unless we die first). // us before it dies (unless we die first).
nsTHashtable<nsPtrHashKey<nsFontFaceLoader>> mLoaders GUARDED_BY(mMutex); nsTHashtable<nsPtrHashKey<nsFontFaceLoader>> mLoaders MOZ_GUARDED_BY(mMutex);
// The non rule backed FontFace objects that have been added to this // The non rule backed FontFace objects that have been added to this
// FontFaceSet. // FontFaceSet.
nsTArray<FontFaceRecord> mNonRuleFaces GUARDED_BY(mMutex); nsTArray<FontFaceRecord> mNonRuleFaces MOZ_GUARDED_BY(mMutex);
// The overall status of the loading or loaded fonts in the FontFaceSet. // The overall status of the loading or loaded fonts in the FontFaceSet.
dom::FontFaceSetLoadStatus mStatus GUARDED_BY(mMutex); dom::FontFaceSetLoadStatus mStatus MOZ_GUARDED_BY(mMutex);
// A map from gfxFontFaceSrc pointer identity to whether the load is allowed // A map from gfxFontFaceSrc pointer identity to whether the load is allowed
// by CSP or other checks. We store this here because querying CSP off the // by CSP or other checks. We store this here because querying CSP off the
@@ -276,22 +276,22 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet {
// We could use just the pointer and use this as a hash set, but then we'd // We could use just the pointer and use this as a hash set, but then we'd
// have no way to verify that we've checked all the loads we should. // have no way to verify that we've checked all the loads we should.
nsTHashMap<nsPtrHashKey<const gfxFontFaceSrc>, bool> mAllowedFontLoads nsTHashMap<nsPtrHashKey<const gfxFontFaceSrc>, bool> mAllowedFontLoads
GUARDED_BY(mMutex); MOZ_GUARDED_BY(mMutex);
// Whether mNonRuleFaces has changed since last time UpdateRules ran. // Whether mNonRuleFaces has changed since last time UpdateRules ran.
bool mNonRuleFacesDirty GUARDED_BY(mMutex); bool mNonRuleFacesDirty MOZ_GUARDED_BY(mMutex);
// Whether any FontFace objects in mRuleFaces or mNonRuleFaces are // Whether any FontFace objects in mRuleFaces or mNonRuleFaces are
// loading. Only valid when mHasLoadingFontFacesIsDirty is false. Don't use // loading. Only valid when mHasLoadingFontFacesIsDirty is false. Don't use
// this variable directly; call the HasLoadingFontFaces method instead. // this variable directly; call the HasLoadingFontFaces method instead.
bool mHasLoadingFontFaces GUARDED_BY(mMutex); bool mHasLoadingFontFaces MOZ_GUARDED_BY(mMutex);
// This variable is only valid when mLoadingDirty is false. // This variable is only valid when mLoadingDirty is false.
bool mHasLoadingFontFacesIsDirty GUARDED_BY(mMutex); bool mHasLoadingFontFacesIsDirty MOZ_GUARDED_BY(mMutex);
// Whether CheckLoadingFinished calls should be ignored. See comment in // Whether CheckLoadingFinished calls should be ignored. See comment in
// OnFontFaceStatusChanged. // OnFontFaceStatusChanged.
bool mDelayedLoadCheck GUARDED_BY(mMutex); bool mDelayedLoadCheck MOZ_GUARDED_BY(mMutex);
// Whether the docshell for our document indicated that loads should // Whether the docshell for our document indicated that loads should
// bypass the cache. // bypass the cache.

View File

@@ -52,9 +52,9 @@ class FontFaceSetWorkerImpl final : public FontFaceSetImpl {
TimeStamp GetNavigationStartTimeStamp() override; TimeStamp GetNavigationStartTimeStamp() override;
RefPtr<ThreadSafeWorkerRef> mWorkerRef GUARDED_BY(mMutex); RefPtr<ThreadSafeWorkerRef> mWorkerRef MOZ_GUARDED_BY(mMutex);
RefPtr<URLExtraData> mURLExtraData GUARDED_BY(mMutex); RefPtr<URLExtraData> mURLExtraData MOZ_GUARDED_BY(mMutex);
}; };
} // namespace mozilla::dom } // namespace mozilla::dom

View File

@@ -44,7 +44,7 @@ static_assert(sizeof(os_unfair_lock) == sizeof(OSSpinLock),
// places, because they require malloc()ed memory, which causes bootstrapping // places, because they require malloc()ed memory, which causes bootstrapping
// issues in some cases. We also can't use constructors, because for statics, // issues in some cases. We also can't use constructors, because for statics,
// they would fire after the first use of malloc, resetting the locks. // they would fire after the first use of malloc, resetting the locks.
struct CAPABILITY Mutex { struct MOZ_CAPABILITY Mutex {
#if defined(XP_WIN) #if defined(XP_WIN)
CRITICAL_SECTION mMutex; CRITICAL_SECTION mMutex;
#elif defined(XP_DARWIN) #elif defined(XP_DARWIN)
@@ -86,7 +86,7 @@ struct CAPABILITY Mutex {
return true; return true;
} }
inline void Lock() CAPABILITY_ACQUIRE() { inline void Lock() MOZ_CAPABILITY_ACQUIRE() {
#if defined(XP_WIN) #if defined(XP_WIN)
EnterCriticalSection(&mMutex); EnterCriticalSection(&mMutex);
#elif defined(XP_DARWIN) #elif defined(XP_DARWIN)
@@ -109,7 +109,7 @@ struct CAPABILITY Mutex {
#endif #endif
} }
inline void Unlock() CAPABILITY_RELEASE() { inline void Unlock() MOZ_CAPABILITY_RELEASE() {
#if defined(XP_WIN) #if defined(XP_WIN)
LeaveCriticalSection(&mMutex); LeaveCriticalSection(&mMutex);
#elif defined(XP_DARWIN) #elif defined(XP_DARWIN)
@@ -137,12 +137,14 @@ struct CAPABILITY Mutex {
// Ideally, we'd use the same type of locks everywhere, but SRWLocks // Ideally, we'd use the same type of locks everywhere, but SRWLocks
// everywhere incur a performance penalty. See bug 1418389. // everywhere incur a performance penalty. See bug 1418389.
#if defined(XP_WIN) #if defined(XP_WIN)
struct CAPABILITY StaticMutex { struct MOZ_CAPABILITY StaticMutex {
SRWLOCK mMutex; SRWLOCK mMutex;
inline void Lock() CAPABILITY_ACQUIRE() { AcquireSRWLockExclusive(&mMutex); } inline void Lock() MOZ_CAPABILITY_ACQUIRE() {
AcquireSRWLockExclusive(&mMutex);
}
inline void Unlock() CAPABILITY_RELEASE() { inline void Unlock() MOZ_CAPABILITY_RELEASE() {
ReleaseSRWLockExclusive(&mMutex); ReleaseSRWLockExclusive(&mMutex);
} }
}; };
@@ -168,12 +170,12 @@ typedef Mutex StaticMutex;
#endif #endif
template <typename T> template <typename T>
struct SCOPED_CAPABILITY MOZ_RAII AutoLock { struct MOZ_SCOPED_CAPABILITY MOZ_RAII AutoLock {
explicit AutoLock(T& aMutex) CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) { explicit AutoLock(T& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) {
mMutex.Lock(); mMutex.Lock();
} }
~AutoLock() CAPABILITY_RELEASE() { mMutex.Unlock(); } ~AutoLock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); }
AutoLock(const AutoLock&) = delete; AutoLock(const AutoLock&) = delete;
AutoLock(AutoLock&&) = delete; AutoLock(AutoLock&&) = delete;

View File

@@ -4730,7 +4730,7 @@ inline void MozJemalloc::moz_dispose_arena(arena_id_t aArenaId) {
// running in threaded mode, so there is no need to check whether the program // running in threaded mode, so there is no need to check whether the program
// is threaded here. // is threaded here.
FORK_HOOK FORK_HOOK
void _malloc_prefork(void) NO_THREAD_SAFETY_ANALYSIS { void _malloc_prefork(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
// Acquire all mutexes in a safe order. // Acquire all mutexes in a safe order.
gArenas.mLock.Lock(); gArenas.mLock.Lock();
@@ -4744,7 +4744,7 @@ void _malloc_prefork(void) NO_THREAD_SAFETY_ANALYSIS {
} }
FORK_HOOK FORK_HOOK
void _malloc_postfork_parent(void) NO_THREAD_SAFETY_ANALYSIS { void _malloc_postfork_parent(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
// Release all mutexes, now that fork() has completed. // Release all mutexes, now that fork() has completed.
huge_mtx.Unlock(); huge_mtx.Unlock();

View File

@@ -27,8 +27,8 @@ static bool sStdoutOrStderr = false;
static Mutex sMutex MOZ_UNANNOTATED; static Mutex sMutex MOZ_UNANNOTATED;
#ifndef _WIN32 #ifndef _WIN32
static void prefork() NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } static void prefork() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); }
static void postfork_parent() NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); } static void postfork_parent() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); }
static void postfork_child() { sMutex.Init(); } static void postfork_child() { sMutex.Init(); }
#endif #endif

View File

@@ -800,9 +800,9 @@ class GMut {
// first, because that self-same PHC machinery needs to re-lock it, and // first, because that self-same PHC machinery needs to re-lock it, and
// the crash causes non-local control flow so sMutex won't be unlocked // the crash causes non-local control flow so sMutex won't be unlocked
// the normal way in the caller. // the normal way in the caller.
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
sMutex.Unlock(); sMutex.Unlock();
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
*static_cast<uint8_t*>(aPtr) = 0; *static_cast<uint8_t*>(aPtr) = 0;
MOZ_CRASH("unreachable"); MOZ_CRASH("unreachable");
} }
@@ -880,8 +880,10 @@ class GMut {
} }
#ifndef XP_WIN #ifndef XP_WIN
static void prefork() NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } static void prefork() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); }
static void postfork_parent() NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); } static void postfork_parent() MOZ_NO_THREAD_SAFETY_ANALYSIS {
sMutex.Unlock();
}
static void postfork_child() { sMutex.Init(); } static void postfork_child() { sMutex.Init(); }
#endif #endif

View File

@@ -686,10 +686,10 @@
* MOZ_UNANNOTATED/MOZ_ANNOTATED: Applies to Mutexes/Monitors and variations on * MOZ_UNANNOTATED/MOZ_ANNOTATED: Applies to Mutexes/Monitors and variations on
* them. MOZ_UNANNOTATED indicates that the Mutex/Monitor/etc hasn't been * them. MOZ_UNANNOTATED indicates that the Mutex/Monitor/etc hasn't been
* examined and annotated using macros from mfbt/ThreadSafety -- * examined and annotated using macros from mfbt/ThreadSafety --
* GUARDED_BY()/REQUIRES()/etc. MOZ_ANNOTATED is used in rare cases to * MOZ_GUARDED_BY()/REQUIRES()/etc. MOZ_ANNOTATED is used in rare cases to
* indicate that is has been looked at, but it did not need any * indicate that is has been looked at, but it did not need any
* GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can ignore * MOZ_GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can
* this Mutex/Monitor/etc) * ignore this Mutex/Monitor/etc)
*/ */
// gcc emits a nuisance warning -Wignored-attributes because attributes do not // gcc emits a nuisance warning -Wignored-attributes because attributes do not

View File

@@ -641,9 +641,9 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Maybe
* Static analyzer gets confused if we have Maybe<MutexAutoLock>, * Static analyzer gets confused if we have Maybe<MutexAutoLock>,
* so we suppress thread-safety warnings here * so we suppress thread-safety warnings here
*/ */
PUSH_IGNORE_THREAD_SAFETY MOZ_PUSH_IGNORE_THREAD_SAFETY
ref().T::~T(); ref().T::~T();
POP_THREAD_SAFETY MOZ_POP_THREAD_SAFETY
poisonData(); poisonData();
} }
mIsSome = false; mIsSome = false;

View File

@@ -23,116 +23,118 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#if defined(__clang__) && (__clang_major__ >= 8) && !defined(SWIG) #if defined(__clang__) && (__clang_major__ >= 8) && !defined(SWIG)
# define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) # define MOZ_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
// Allow for localized suppression of thread-safety warnings; finer-grained // Allow for localized suppression of thread-safety warnings; finer-grained
// than NO_THREAD_SAFETY_ANALYSIS // than MOZ_NO_THREAD_SAFETY_ANALYSIS
# define PUSH_IGNORE_THREAD_SAFETY \ # define MOZ_PUSH_IGNORE_THREAD_SAFETY \
_Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wthread-safety\"") _Pragma("GCC diagnostic ignored \"-Wthread-safety\"")
# define POP_THREAD_SAFETY _Pragma("GCC diagnostic pop") # define MOZ_POP_THREAD_SAFETY _Pragma("GCC diagnostic pop")
#else #else
# define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op # define MOZ_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
# define PUSH_IGNORE_THREAD_SAFETY # define MOZ_PUSH_IGNORE_THREAD_SAFETY
# define POP_THREAD_SAFETY # define MOZ_POP_THREAD_SAFETY
#endif #endif
// Document if a shared variable/field needs to be protected by a lock. // Document if a shared variable/field needs to be protected by a lock.
// GUARDED_BY allows the user to specify a particular lock that should be // MOZ_GUARDED_BY allows the user to specify a particular lock that should be
// held when accessing the annotated variable, while GUARDED_VAR only // held when accessing the annotated variable, while MOZ_GUARDED_VAR only
// indicates a shared variable should be guarded (by any lock). GUARDED_VAR // indicates a shared variable should be guarded (by any lock). MOZ_GUARDED_VAR
// is primarily used when the client cannot express the name of the lock. // is primarily used when the client cannot express the name of the lock.
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) #define MOZ_GUARDED_BY(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
#define GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) #define MOZ_GUARDED_VAR MOZ_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var)
// Document if the memory location pointed to by a pointer should be guarded // Document if the memory location pointed to by a pointer should be guarded
// by a lock when dereferencing the pointer. Similar to GUARDED_VAR, // by a lock when dereferencing the pointer. Similar to MOZ_GUARDED_VAR,
// PT_GUARDED_VAR is primarily used when the client cannot express the name // MOZ_PT_GUARDED_VAR is primarily used when the client cannot express the
// of the lock. Note that a pointer variable to a shared memory location // name of the lock. Note that a pointer variable to a shared memory location
// could itself be a shared variable. For example, if a shared global pointer // could itself be a shared variable. For example, if a shared global pointer
// q, which is guarded by mu1, points to a shared memory location that is // q, which is guarded by mu1, points to a shared memory location that is
// guarded by mu2, q should be annotated as follows: // guarded by mu2, q should be annotated as follows:
// int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2); // int *q MOZ_GUARDED_BY(mu1) MOZ_PT_GUARDED_BY(mu2);
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) #define MOZ_PT_GUARDED_BY(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
#define PT_GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) #define MOZ_PT_GUARDED_VAR MOZ_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var)
// Document the acquisition order between locks that can be held // Document the acquisition order between locks that can be held
// simultaneously by a thread. For any two locks that need to be annotated // simultaneously by a thread. For any two locks that need to be annotated
// to establish an acquisition order, only one of them needs the annotation. // to establish an acquisition order, only one of them needs the annotation.
// (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER // (i.e. You don't have to annotate both locks with both MOZ_ACQUIRED_AFTER
// and ACQUIRED_BEFORE.) // and MOZ_ACQUIRED_BEFORE.)
#define ACQUIRED_AFTER(...) \ #define MOZ_ACQUIRED_AFTER(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
#define ACQUIRED_BEFORE(...) \ #define MOZ_ACQUIRED_BEFORE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
// The following three annotations document the lock requirements for // The following three annotations document the lock requirements for
// functions/methods. // functions/methods.
// Document if a function expects certain locks to be held before it is called // Document if a function expects certain locks to be held before it is called
#define REQUIRES(...) \ #define MOZ_REQUIRES(...) \
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__))
#define REQUIRES_SHARED(...) \ #define MOZ_REQUIRES_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))
// Document the locks acquired in the body of the function. These locks // Document the locks acquired in the body of the function. These locks
// cannot be held when calling this function (as google3's Mutex locks are // cannot be held when calling this function (as google3's Mutex locks are
// non-reentrant). // non-reentrant).
#define EXCLUDES(x) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) #define MOZ_EXCLUDES(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))
// Document the lock the annotated function returns without acquiring it. // Document the lock the annotated function returns without acquiring it.
#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) #define MOZ_RETURN_CAPABILITY(x) \
MOZ_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
// Document if a class/type is a lockable type (such as the Mutex class). // Document if a class/type is a lockable type (such as the Mutex class).
#define CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(lockable) #define MOZ_CAPABILITY MOZ_THREAD_ANNOTATION_ATTRIBUTE__(lockable)
// Document if a class is a scoped lockable type (such as the MutexLock class). // Document if a class is a scoped lockable type (such as the MutexLock class).
#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) #define MOZ_SCOPED_CAPABILITY MOZ_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
// The following annotations specify lock and unlock primitives. // The following annotations specify lock and unlock primitives.
#define CAPABILITY_ACQUIRE(...) \ #define MOZ_CAPABILITY_ACQUIRE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
#define EXCLUSIVE_RELEASE(...) \ #define MOZ_EXCLUSIVE_RELEASE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
#define ACQUIRE_SHARED(...) \ #define MOZ_ACQUIRE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))
#define TRY_ACQUIRE(...) \ #define MOZ_TRY_ACQUIRE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
#define SHARED_TRYLOCK_FUNCTION(...) \ #define MOZ_SHARED_TRYLOCK_FUNCTION(...) \
THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))
#define CAPABILITY_RELEASE(...) \ #define MOZ_CAPABILITY_RELEASE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
// An escape hatch for thread safety analysis to ignore the annotated function. // An escape hatch for thread safety analysis to ignore the annotated function.
#define NO_THREAD_SAFETY_ANALYSIS \ #define MOZ_NO_THREAD_SAFETY_ANALYSIS \
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
// Newer capabilities // Newer capabilities
#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) #define MOZ_ASSERT_CAPABILITY(x) \
MOZ_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
#define ASSERT_SHARED_CAPABILITY(x) \ #define MOZ_ASSERT_SHARED_CAPABILITY(x) \
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
// Additions from current clang assertions. // Additions from current clang assertions.
// Note: new-style definitions, since these didn't exist in the old style // Note: new-style definitions, since these didn't exist in the old style
#define RELEASE_SHARED(...) \ #define MOZ_RELEASE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
#define RELEASE_GENERIC(...) \ #define MOZ_RELEASE_GENERIC(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__)) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
// Mozilla additions: // Mozilla additions:
// AutoUnlock is supported by clang currently, but oddly you must use // AutoUnlock is supported by clang currently, but oddly you must use
// EXCLUSIVE_RELEASE() for both the RAII constructor *and* the destructor. // MOZ_EXCLUSIVE_RELEASE() for both the RAII constructor *and* the destructor.
// This hides the ugliness until they fix it upstream. // This hides the ugliness until they fix it upstream.
#define SCOPED_UNLOCK_RELEASE(...) EXCLUSIVE_RELEASE(__VA_ARGS__) #define MOZ_SCOPED_UNLOCK_RELEASE(...) MOZ_EXCLUSIVE_RELEASE(__VA_ARGS__)
#define SCOPED_UNLOCK_REACQUIRE(...) EXCLUSIVE_RELEASE(__VA_ARGS__) #define MOZ_SCOPED_UNLOCK_REACQUIRE(...) MOZ_EXCLUSIVE_RELEASE(__VA_ARGS__)
#endif /* mozilla_ThreadSafety_h */ #endif /* mozilla_ThreadSafety_h */

View File

@@ -83,13 +83,13 @@ class nsJAR final : public nsIZipReader {
//-- Private data members, protected by mLock //-- Private data members, protected by mLock
mozilla::RecursiveMutex mLock; mozilla::RecursiveMutex mLock;
// The entry in the zip this zip is reading from // The entry in the zip this zip is reading from
nsCString mOuterZipEntry GUARDED_BY(mLock); nsCString mOuterZipEntry MOZ_GUARDED_BY(mLock);
// The zip/jar file on disk // The zip/jar file on disk
nsCOMPtr<nsIFile> mZipFile GUARDED_BY(mLock); nsCOMPtr<nsIFile> mZipFile MOZ_GUARDED_BY(mLock);
// The underlying zip archive // The underlying zip archive
RefPtr<nsZipArchive> mZip GUARDED_BY(mLock); RefPtr<nsZipArchive> mZip MOZ_GUARDED_BY(mLock);
// if cached, this points to the cache it's contained in // if cached, this points to the cache it's contained in
nsZipReaderCache* mCache GUARDED_BY(mLock); nsZipReaderCache* mCache MOZ_GUARDED_BY(mLock);
}; };
/** /**
@@ -172,14 +172,14 @@ class nsZipReaderCache : public nsIZipReaderCache,
virtual ~nsZipReaderCache(); virtual ~nsZipReaderCache();
mozilla::Mutex mLock; mozilla::Mutex mLock;
uint32_t mCacheSize GUARDED_BY(mLock); uint32_t mCacheSize MOZ_GUARDED_BY(mLock);
ZipsHashtable mZips GUARDED_BY(mLock); ZipsHashtable mZips MOZ_GUARDED_BY(mLock);
#ifdef ZIP_CACHE_HIT_RATE #ifdef ZIP_CACHE_HIT_RATE
uint32_t mZipCacheLookups GUARDED_BY(mLock); uint32_t mZipCacheLookups MOZ_GUARDED_BY(mLock);
uint32_t mZipCacheHits GUARDED_BY(mLock); uint32_t mZipCacheHits MOZ_GUARDED_BY(mLock);
uint32_t mZipCacheFlushes GUARDED_BY(mLock); uint32_t mZipCacheFlushes MOZ_GUARDED_BY(mLock);
uint32_t mZipSyncMisses GUARDED_BY(mLock); uint32_t mZipSyncMisses MOZ_GUARDED_BY(mLock);
#endif #endif
private: private:

Some files were not shown because too many files have changed in this diff Show More