Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE

This commit is contained in:
Andreea Pavel 2022-08-02 04:59:08 +03:00
parent 0f4ac7ad97
commit 89d63c91e6
202 changed files with 1443 additions and 1518 deletions

View File

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

View File

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

View File

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

View File

@ -141,18 +141,17 @@ class BodyStream final : public nsIInputStreamCallback,
void ErrorPropagation(JSContext* aCx,
const MutexSingleWriterAutoLock& aProofOfLock,
ReadableStream* aStream, nsresult aRv)
MOZ_REQUIRES(mMutex);
ReadableStream* aStream, nsresult aRv) REQUIRES(mMutex);
// TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605)
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects(
JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock,
ReadableStream* aStream) MOZ_REQUIRES(mMutex);
ReadableStream* aStream) REQUIRES(mMutex);
class WorkerShutdown;
void ReleaseObjects(const MutexSingleWriterAutoLock& aProofOfLock)
MOZ_REQUIRES(mMutex);
REQUIRES(mMutex);
void ReleaseObjects();
@ -187,12 +186,12 @@ class BodyStream final : public nsIInputStreamCallback,
MutexSingleWriter mMutex;
// Protected by mutex.
State mState MOZ_GUARDED_BY(mMutex); // all writes are from the owning thread
State mState GUARDED_BY(mMutex); // all writes are from 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.
nsCOMPtr<nsIGlobalObject> mGlobal;
RefPtr<BodyStreamHolder> mStreamHolder MOZ_GUARDED_BY(mMutex);
RefPtr<BodyStreamHolder> mStreamHolder GUARDED_BY(mMutex);
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
// 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(); }
};
mutable LruPosition mLruPosition MOZ_GUARDED_BY(sLruMutex);
mutable LruPosition mLruPosition GUARDED_BY(sLruMutex);
void BumpLruLocked(const StaticMutexAutoLock& aProofOfLock);
@ -740,7 +740,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
private:
static StaticMutex sLruMutex;
static std::list<WebGLContext*> sLru MOZ_GUARDED_BY(sLruMutex);
static std::list<WebGLContext*> sLru GUARDED_BY(sLruMutex);
// State tracking slots
bool mDitherEnabled = true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -86,9 +86,9 @@ class GraphRunner final : public Runnable {
MediaTrackGraphImpl* const mGraph;
// State being handed over to the graph through OneIteration. Protected by
// mMonitor.
Maybe<IterationState> mIterationState MOZ_GUARDED_BY(mMonitor);
Maybe<IterationState> mIterationState GUARDED_BY(mMonitor);
// Result from mGraph's OneIteration. Protected by mMonitor.
IterationResult mIterationResult MOZ_GUARDED_BY(mMonitor);
IterationResult mIterationResult GUARDED_BY(mMonitor);
enum class ThreadState {
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
// modified.
ThreadState mThreadState MOZ_GUARDED_BY(mMonitor);
ThreadState mThreadState GUARDED_BY(mMonitor);
// The thread running mGraph. Set on construction, after other members are
// initialized. Cleared at the end of Shutdown().

View File

@ -1533,9 +1533,9 @@ auto MediaTrackGraphImpl::OneIterationImpl(GraphTime aStateTime,
// > LIFECYCLE_RUNNING)
// Ignore mutex warning: static during execution of the graph
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
MOZ_DIAGNOSTIC_ASSERT(mLifecycleState <= LIFECYCLE_RUNNING);
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
MOZ_ASSERT(OnGraphThread());
@ -2725,7 +2725,7 @@ bool SourceMediaTrack::PullNewData(GraphTime aDesiredUpToTime) {
static void MoveToSegment(SourceMediaTrack* aTrack, MediaSegment* aIn,
MediaSegment* aOut, TrackTime aCurrentTime,
TrackTime aDesiredUpToTime)
MOZ_REQUIRES(aTrack->GetMutex()) {
REQUIRES(aTrack->GetMutex()) {
MOZ_ASSERT(aIn->GetType() == aOut->GetType());
MOZ_ASSERT(aOut->GetDuration() >= 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
// buffering delay in applying the change. See Bug 1443511.
void SetVolume(float aVolume);
float GetVolumeLocked() MOZ_REQUIRES(mMutex);
float GetVolumeLocked() REQUIRES(mMutex);
Mutex& GetMutex() MOZ_RETURN_CAPABILITY(mMutex) { return mMutex; }
Mutex& GetMutex() RETURN_CAPABILITY(mMutex) { return mMutex; }
friend class MediaTrackGraphImpl;
@ -706,8 +706,7 @@ class SourceMediaTrack : public MediaTrack {
bool NeedsMixing();
void ResampleAudioToGraphSampleRate(MediaSegment* aSegment)
MOZ_REQUIRES(mMutex);
void ResampleAudioToGraphSampleRate(MediaSegment* aSegment) REQUIRES(mMutex);
void AddDirectListenerImpl(
already_AddRefed<DirectMediaTrackListener> aListener) override;
@ -719,7 +718,7 @@ class SourceMediaTrack : public MediaTrack {
* from AppendData on the thread providing the data, and will call
* the Listeners on this thread.
*/
void NotifyDirectConsumers(MediaSegment* aSegment) MOZ_REQUIRES(mMutex);
void NotifyDirectConsumers(MediaSegment* aSegment) REQUIRES(mMutex);
void OnGraphThreadDone() override {
MutexAutoLock lock(mMutex);
@ -740,10 +739,10 @@ class SourceMediaTrack : public MediaTrack {
// held together.
Mutex mMutex;
// protected by mMutex
float mVolume MOZ_GUARDED_BY(mMutex) = 1.0;
UniquePtr<TrackData> mUpdateTrack MOZ_GUARDED_BY(mMutex);
float mVolume GUARDED_BY(mMutex) = 1.0;
UniquePtr<TrackData> mUpdateTrack GUARDED_BY(mMutex);
nsTArray<RefPtr<DirectMediaTrackListener>> mDirectTrackListeners
MOZ_GUARDED_BY(mMutex);
GUARDED_BY(mMutex);
};
/**

View File

@ -189,7 +189,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/**
* Called to apply a TrackUpdate to its track.
*/
void ApplyTrackUpdate(TrackUpdate* aUpdate) MOZ_REQUIRES(mMonitor);
void ApplyTrackUpdate(TrackUpdate* aUpdate) REQUIRES(mMonitor);
/**
* Append a ControlMessage to the message queue. This queue is drained
* during RunInStableState; the messages will run on the graph thread.
@ -280,13 +280,12 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* mMonitor must be held.
* See EnsureRunInStableState
*/
void EnsureStableStateEventPosted() MOZ_REQUIRES(mMonitor);
void EnsureStableStateEventPosted() REQUIRES(mMonitor);
/**
* Generate messages to the main thread to update it for all state changes.
* mMonitor must be held.
*/
void PrepareUpdatesToMainThreadState(bool aFinalUpdate)
MOZ_REQUIRES(mMonitor);
void PrepareUpdatesToMainThreadState(bool aFinalUpdate) REQUIRES(mMonitor);
/**
* 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
@ -320,7 +319,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
*/
void UpdateGraph(GraphTime aEndBlockingDecisions);
void SwapMessageQueues() MOZ_REQUIRES(mMonitor) {
void SwapMessageQueues() REQUIRES(mMonitor) {
MOZ_ASSERT(OnGraphThreadOrNotRunning());
mMonitor.AssertCurrentThreadOwns();
MOZ_ASSERT(mFrontMessageQueue.IsEmpty());
@ -554,7 +553,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/**
* Not safe to call off the MediaTrackGraph thread unless monitor is held!
*/
GraphDriver* CurrentDriver() const MOZ_NO_THREAD_SAFETY_ANALYSIS {
GraphDriver* CurrentDriver() const NO_THREAD_SAFETY_ANALYSIS {
#ifdef DEBUG
if (!OnGraphThreadOrNotRunning()) {
mMonitor.AssertCurrentThreadOwns();
@ -788,11 +787,11 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
/**
* State to copy to main thread
*/
nsTArray<TrackUpdate> mTrackUpdates MOZ_GUARDED_BY(mMonitor);
nsTArray<TrackUpdate> mTrackUpdates GUARDED_BY(mMonitor);
/**
* Runnables to run after the next update to main thread state.
*/
nsTArray<nsCOMPtr<nsIRunnable>> mUpdateRunnables MOZ_GUARDED_BY(mMonitor);
nsTArray<nsCOMPtr<nsIRunnable>> mUpdateRunnables GUARDED_BY(mMonitor);
/**
* A list of batches of messages to process. Each batch is processed
* as an atomic unit.
@ -806,10 +805,10 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* Message queue in which the main thread appends messages.
* Access guarded by mMonitor.
*/
nsTArray<MessageBlock> mBackMessageQueue MOZ_GUARDED_BY(mMonitor);
nsTArray<MessageBlock> mBackMessageQueue GUARDED_BY(mMonitor);
/* True if there will messages to process if we swap the message queues. */
bool MessagesQueued() const MOZ_REQUIRES(mMonitor) {
bool MessagesQueued() const REQUIRES(mMonitor) {
mMonitor.AssertCurrentThreadOwns();
return !mBackMessageQueue.IsEmpty();
}
@ -863,8 +862,8 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* 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.
*/
LifecycleState mLifecycleState MOZ_GUARDED_BY(mMonitor);
LifecycleState& LifecycleStateRef() MOZ_NO_THREAD_SAFETY_ANALYSIS {
LifecycleState mLifecycleState GUARDED_BY(mMonitor);
LifecycleState& LifecycleStateRef() NO_THREAD_SAFETY_ANALYSIS {
#if DEBUG
if (mGraphDriverRunning) {
mMonitor.AssertCurrentThreadOwns();
@ -874,8 +873,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
#endif
return mLifecycleState;
}
const LifecycleState& LifecycleStateRef() const
MOZ_NO_THREAD_SAFETY_ANALYSIS {
const LifecycleState& LifecycleStateRef() const NO_THREAD_SAFETY_ANALYSIS {
#if DEBUG
if (mGraphDriverRunning) {
mMonitor.AssertCurrentThreadOwns();
@ -901,7 +899,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* forced) has commenced. Set on the main thread under mMonitor and read on
* the graph thread under mMonitor.
**/
bool mInterruptJSCalled MOZ_GUARDED_BY(mMonitor) = false;
bool mInterruptJSCalled GUARDED_BY(mMonitor) = false;
/**
* Remove this blocker to unblock shutdown.
@ -914,7 +912,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* RunInStableState() and the event hasn't run yet.
* Accessed on both main and MTG thread, mMonitor must be held.
*/
bool mPostedRunInStableStateEvent MOZ_GUARDED_BY(mMonitor);
bool mPostedRunInStableStateEvent GUARDED_BY(mMonitor);
/**
* The JSContext of the graph thread. Set under mMonitor on only the graph
@ -922,7 +920,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* the thread is about to exit. Read under mMonitor on the main thread to
* interrupt running JS for forced shutdown.
**/
JSContext* mJSContext MOZ_GUARDED_BY(mMonitor) = nullptr;
JSContext* mJSContext GUARDED_BY(mMonitor) = nullptr;
// Main thread only
@ -1017,7 +1015,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
* Set based on mProcessedTime at end of iteration.
* Read by stable state runnable on main thread. Protected by mMonitor.
*/
GraphTime mNextMainThreadGraphTime MOZ_GUARDED_BY(mMonitor) = 0;
GraphTime mNextMainThreadGraphTime GUARDED_BY(mMonitor) = 0;
/**
* 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
// PopAll calls won't overlap.
class MOZ_CAPABILITY MultiWriterQueueReaderLocking_Mutex {
class CAPABILITY MultiWriterQueueReaderLocking_Mutex {
public:
MultiWriterQueueReaderLocking_Mutex()
: mMutex("MultiWriterQueueReaderLocking_Mutex") {}
void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); };
void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); };
void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); };
void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); };
private:
Mutex mMutex;
@ -33,17 +33,17 @@ class MOZ_CAPABILITY MultiWriterQueueReaderLocking_Mutex {
// Reader non-locking strategy, trusting that PopAll will never be called
// concurrently (e.g., by only calling it from a specific thread).
class MOZ_CAPABILITY MultiWriterQueueReaderLocking_None {
class CAPABILITY MultiWriterQueueReaderLocking_None {
public:
#ifndef DEBUG
void Lock() MOZ_CAPABILITY_ACQUIRE(){};
void Unlock() MOZ_CAPABILITY_RELEASE(){};
void Lock() CAPABILITY_ACQUIRE(){};
void Unlock() CAPABILITY_RELEASE(){};
#else
// DEBUG-mode checks to catch concurrent misuses.
void Lock() MOZ_CAPABILITY_ACQUIRE() {
void Lock() CAPABILITY_ACQUIRE() {
MOZ_ASSERT(mLocked.compareExchange(false, true));
};
void Unlock() MOZ_CAPABILITY_RELEASE() {
void Unlock() CAPABILITY_RELEASE() {
MOZ_ASSERT(mLocked.compareExchange(true, false));
};

View File

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

View File

@ -36,11 +36,11 @@ using namespace gfx;
// launched serially. Protects sLaunchPromise
StaticMutex sLaunchRDDMutex;
static StaticRefPtr<GenericNonExclusivePromise> sLaunchRDDPromise
MOZ_GUARDED_BY(sLaunchRDDMutex);
GUARDED_BY(sLaunchRDDMutex);
StaticMutex sLaunchUtilityMutex;
static StaticRefPtr<GenericNonExclusivePromise> sLaunchUtilityPromise
MOZ_GUARDED_BY(sLaunchUtilityMutex);
GUARDED_BY(sLaunchUtilityMutex);
// 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -146,7 +146,7 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// Main thread callers must hold Lock() and check CleanUp() before calling
// this. Worker thread callers, this will assert that the proxy has not been
// cleaned up.
WorkerPrivate* GetWorkerPrivate() const MOZ_NO_THREAD_SAFETY_ANALYSIS;
WorkerPrivate* GetWorkerPrivate() const NO_THREAD_SAFETY_ANALYSIS;
// This should only be used within WorkerRunnable::WorkerRun() running on the
// worker thread! Do not call this after calling CleanUp().
@ -158,9 +158,9 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// 2. WorkerPromise() will crash!
void CleanUp();
Mutex& Lock() MOZ_RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; }
Mutex& Lock() RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; }
bool CleanedUp() const MOZ_REQUIRES(mCleanUpLock) {
bool CleanedUp() const REQUIRES(mCleanUpLock) {
mCleanUpLock.AssertCurrentThreadOwns();
return mCleanedUp;
}
@ -204,8 +204,8 @@ class PromiseWorkerProxy : public PromiseNativeHandler,
// Modified on the worker thread.
// It is ok to *read* this without a lock on the worker.
// Main thread must always acquire a lock.
bool mCleanedUp MOZ_GUARDED_BY(
mCleanUpLock); // To specify if the cleanUp() has been done.
bool mCleanedUp
GUARDED_BY(mCleanUpLock); // To specify if the cleanUp() has been done.
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
// find a way to lock around access to mData. Since we can't, suppress the
// thread-safety warnings.
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
if (overwrite && NS_FAILED(WriteData(mData))) {
NS_WARNING("Failed to write data for the ServiceWorker Registations.");
DeleteData();
}
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
return NS_OK;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -104,17 +104,16 @@ class JSExecutionManager {
// Workers waiting to be given permission for execution.
// Guarded by mExecutionQueueMutex.
std::deque<WorkerPrivate*> mExecutionQueue
MOZ_GUARDED_BY(mExecutionQueueMutex);
std::deque<WorkerPrivate*> mExecutionQueue GUARDED_BY(mExecutionQueueMutex);
// Number of threads currently executing concurrently for this manager.
// Guarded by mExecutionQueueMutex.
int32_t mRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 0;
int32_t mRunning GUARDED_BY(mExecutionQueueMutex) = 0;
// Number of threads allowed to run concurrently for environments managed
// by this manager.
// Guarded by mExecutionQueueMutex.
int32_t mMaxRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 1;
int32_t mMaxRunning GUARDED_BY(mExecutionQueueMutex) = 1;
// Mutex that guards the execution queue and associated state.
Mutex mExecutionQueueMutex =
@ -131,8 +130,7 @@ class JSExecutionManager {
// Whether the main thread is currently awaiting permission to execute. Main
// thread execution is always prioritized.
// Guarded by mExecutionQueueMutex.
bool mMainThreadAwaitingExecution MOZ_GUARDED_BY(mExecutionQueueMutex) =
false;
bool mMainThreadAwaitingExecution GUARDED_BY(mExecutionQueueMutex) = false;
};
// 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(); }
};
class MOZ_CAPABILITY LockingWithMutex {
class CAPABILITY LockingWithMutex {
mozilla::Mutex mMutex;
protected:
LockingWithMutex() : mMutex("LockingWithMutex::mMutex") {}
void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex.Lock(); }
void Lock() CAPABILITY_ACQUIRE() { mMutex.Lock(); }
void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); }
void Unlock() CAPABILITY_RELEASE() { mMutex.Unlock(); }
class MOZ_SCOPED_CAPABILITY AutoLock {
class SCOPED_CAPABILITY AutoLock {
LockingWithMutex& mHost;
public:
explicit AutoLock(LockingWithMutex& aHost) MOZ_CAPABILITY_ACQUIRE(aHost)
explicit AutoLock(LockingWithMutex& aHost) CAPABILITY_ACQUIRE(aHost)
: mHost(aHost) {
mHost.Lock();
}
~AutoLock() MOZ_CAPABILITY_RELEASE() { mHost.Unlock(); }
~AutoLock() CAPABILITY_RELEASE() { mHost.Unlock(); }
};
friend class AutoLock;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,12 +25,12 @@ class XMLHttpRequestStringBuffer final {
return mData.Length();
}
uint32_t UnsafeLength() const MOZ_NO_THREAD_SAFETY_ANALYSIS {
uint32_t UnsafeLength() const NO_THREAD_SAFETY_ANALYSIS {
return mData.Length();
}
mozilla::Result<mozilla::BulkWriteHandle<char16_t>, nsresult> UnsafeBulkWrite(
uint32_t aCapacity) MOZ_NO_THREAD_SAFETY_ANALYSIS {
uint32_t aCapacity) NO_THREAD_SAFETY_ANALYSIS {
return mData.BulkWrite(aCapacity, UnsafeLength(), false);
}
@ -86,7 +86,7 @@ class XMLHttpRequestStringBuffer final {
Mutex mMutex;
// The following member variable is protected by mutex.
nsString mData MOZ_GUARDED_BY(mMutex);
nsString mData 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
* the face so as not to invalidate the prior owner's modification.
*/
bool Lock(const void* aOwner = nullptr) MOZ_CAPABILITY_ACQUIRE(mLock) {
bool Lock(const void* aOwner = nullptr) CAPABILITY_ACQUIRE(mLock) {
mLock.Lock();
return !aOwner || mLastLockOwner.exchange(aOwner) == aOwner;
}
void Unlock() MOZ_CAPABILITY_RELEASE(mLock) { mLock.Unlock(); }
void Unlock() CAPABILITY_RELEASE(mLock) { mLock.Unlock(); }
/** Should be called when a lock owner is destroyed so that we don't have
* 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,
void* aOwner) MOZ_NO_THREAD_SAFETY_ANALYSIS {
void* aOwner) NO_THREAD_SAFETY_ANALYSIS {
return int(static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Lock(aOwner));
}
void mozilla_UnlockSharedFTFace(void* aContext) MOZ_NO_THREAD_SAFETY_ANALYSIS {
void mozilla_UnlockSharedFTFace(void* aContext) NO_THREAD_SAFETY_ANALYSIS {
static_cast<mozilla::gfx::SharedFTFace*>(aContext)->Unlock();
}
@ -624,12 +624,12 @@ void Factory::ReleaseFTLibrary(FT_Library aFTLibrary) {
}
void Factory::LockFTLibrary(FT_Library aFTLibrary)
MOZ_CAPABILITY_ACQUIRE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS {
CAPABILITY_ACQUIRE(mFTLock) NO_THREAD_SAFETY_ANALYSIS {
mFTLock.Lock();
}
void Factory::UnlockFTLibrary(FT_Library aFTLibrary)
MOZ_CAPABILITY_RELEASE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS {
CAPABILITY_RELEASE(mFTLock) NO_THREAD_SAFETY_ANALYSIS {
mFTLock.Unlock();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ class gfxFT2FontEntryBase : public gfxFontEntry {
uint32_t mGlyphIndex;
};
mozilla::UniquePtr<CmapCacheSlot[]> mCmapCache MOZ_GUARDED_BY(mLock);
mozilla::UniquePtr<CmapCacheSlot[]> mCmapCache GUARDED_BY(mLock);
};
class gfxFT2FontBase : public gfxFont {
@ -147,7 +147,7 @@ class gfxFT2FontBase : public gfxFont {
uint16_t aGID, mozilla::gfx::IntRect* aBounds = nullptr) const;
mutable mozilla::UniquePtr<nsTHashMap<nsUint32HashKey, GlyphMetrics>>
mGlyphMetrics MOZ_GUARDED_BY(mLock);
mGlyphMetrics GUARDED_BY(mLock);
};
// 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;
// initialize font lists
nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
nsresult InitFontListForPlatform() REQUIRES(mLock) override;
void AppendFaceFromFontListEntry(const FontListEntry& aFLE,
StandardFile aStdFile) MOZ_REQUIRES(mLock);
StandardFile aStdFile) REQUIRES(mLock);
void AppendFacesFromBlob(const nsCString& aFileName, StandardFile aStdFile,
hb_blob_t* aBlob, FontNameCache* aCache,
uint32_t aTimestamp, uint32_t aFilesize)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
void AppendFacesFromFontFile(const nsCString& aFileName,
FontNameCache* aCache, StandardFile aStdFile)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
void AppendFacesFromOmnijarEntry(nsZipArchive* aReader,
const nsCString& aEntryName,
FontNameCache* aCache, bool aJarChanged)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
void InitSharedFontListForPlatform() REQUIRES(mLock) override;
void CollectInitData(const FontListEntry& aFLE, const nsCString& aPSName,
const nsCString& aFullName, StandardFile aStdFile);
@ -217,23 +217,23 @@ class gfxFT2FontList final : public gfxPlatformFontList {
bool AppendFacesFromCachedFaceList(CollectFunc aCollectFace,
const nsCString& aFileName,
const nsCString& aFaceList,
StandardFile aStdFile) MOZ_REQUIRES(mLock);
StandardFile aStdFile) REQUIRES(mLock);
void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex,
StandardFile aStdFile, hb_face_t* aFace,
nsCString& aFaceList) MOZ_REQUIRES(mLock);
nsCString& aFaceList) REQUIRES(mLock);
void FindFonts() MOZ_REQUIRES(mLock);
void FindFonts() REQUIRES(mLock);
void FindFontsInOmnijar(FontNameCache* aCache) MOZ_REQUIRES(mLock);
void FindFontsInOmnijar(FontNameCache* aCache) REQUIRES(mLock);
void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr)
MOZ_REQUIRES(mLock) override;
REQUIRES(mLock) override;
nsTHashSet<nsCString> mSkipSpaceLookupCheckFamilies;

View File

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

View File

@ -392,7 +392,7 @@ class gfxFontCache final
// This gets called when the timeout has expired on a single-refcount
// font; we just delete it.
void NotifyExpiredLocked(gfxFont* aFont, const AutoLock&)
MOZ_REQUIRES(mMutex) override;
REQUIRES(mMutex) override;
void NotifyHandlerEnd() override;
void DestroyDiscard(nsTArray<RefPtr<gfxFont>>& aDiscard);
@ -440,13 +440,13 @@ class gfxFontCache final
RefPtr<gfxFont> mFont;
};
nsTHashtable<HashEntry> mFonts MOZ_GUARDED_BY(mMutex);
nsTHashtable<HashEntry> mFonts GUARDED_BY(mMutex);
nsTArray<RefPtr<gfxFont>> mTrackerDiscard MOZ_GUARDED_BY(mMutex);
nsTArray<RefPtr<gfxFont>> mTrackerDiscard GUARDED_BY(mMutex);
static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache);
nsCOMPtr<nsITimer> mWordCacheExpirationTimer MOZ_GUARDED_BY(mMutex);
nsCOMPtr<nsITimer> mWordCacheExpirationTimer GUARDED_BY(mMutex);
std::atomic<bool> mTimerRunning = false;
};
@ -1826,7 +1826,7 @@ class gfxFont {
ClearCachedWordsLocked();
}
}
void ClearCachedWordsLocked() MOZ_REQUIRES(mLock) {
void ClearCachedWordsLocked() REQUIRES(mLock) {
MOZ_ASSERT(mWordCache);
mWordCache->Clear();
}
@ -2145,15 +2145,14 @@ class gfxFont {
mozilla::UniquePtr<gfxShapedWord> mShapedWord;
};
mozilla::UniquePtr<nsTHashtable<CacheHashEntry>> mWordCache
MOZ_GUARDED_BY(mLock);
mozilla::UniquePtr<nsTHashtable<CacheHashEntry>> mWordCache GUARDED_BY(mLock);
static const uint32_t kShapedWordCacheMaxAge = 3;
nsTArray<mozilla::UniquePtr<gfxGlyphExtents>> mGlyphExtentsArray
MOZ_GUARDED_BY(mLock);
GUARDED_BY(mLock);
mozilla::UniquePtr<nsTHashSet<GlyphChangeObserver*>> mGlyphChangeObservers
MOZ_GUARDED_BY(mLock);
GUARDED_BY(mLock);
// a copy of the font without antialiasing, if needed for separate
// 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) {
// Accessing the mFontTableCache pointer is atomic, so we don't need to take
// a write lock even if we're initializing it here...
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
if (MOZ_UNLIKELY(!mFontTableCache)) {
// We do this here rather than on fontEntry construction
// 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();
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
// ...but we do need a lock to read the actual hashtable contents.
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,
nsTArray<uint8_t>* aBuffer) {
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
if (MOZ_UNLIKELY(!mFontTableCache)) {
auto* newCache = new FontTableCache(8);
if (MOZ_UNLIKELY(!mFontTableCache.compareExchange(nullptr, newCache))) {
@ -556,7 +556,7 @@ hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
}
}
FontTableCache* cache = GetFontTableCache();
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
AutoWriteLock lock(mLock);
FontTableHashEntry* entry = cache->PutEntry(aTag);

View File

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

View File

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

View File

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

View File

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

View File

@ -145,7 +145,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
MOZ_REQUIRES(mLock) override;
REQUIRES(mLock) override;
// lookup the system font for a particular system font type and set
// the name and style characteristics
@ -165,7 +165,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
const gfxFontStyle* aStyle,
nsAtom* aLanguage = nullptr)
MOZ_REQUIRES(mLock) override;
REQUIRES(mLock) override;
private:
friend class gfxPlatformMac;
@ -174,23 +174,23 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
virtual ~gfxMacPlatformFontList();
// initialize font lists
nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override;
void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override;
nsresult InitFontListForPlatform() REQUIRES(mLock) override;
void InitSharedFontListForPlatform() REQUIRES(mLock) override;
// handle commonly used fonts for which the name table should be loaded at
// startup
void PreloadNamesList() MOZ_REQUIRES(mLock);
void PreloadNamesList() REQUIRES(mLock);
// special case font faces treated as font families (set via prefs)
void InitSingleFaceList() MOZ_REQUIRES(mLock);
void InitAliasesForSingleFaceList() MOZ_REQUIRES(mLock);
void InitSingleFaceList() REQUIRES(mLock);
void InitAliasesForSingleFaceList() REQUIRES(mLock);
// initialize system fonts
void InitSystemFontNames() MOZ_REQUIRES(mLock);
void InitSystemFontNames() REQUIRES(mLock);
// helper function to lookup in both hidden system fonts and normal fonts
gfxFontFamily* FindSystemFontFamily(const nsACString& aFamily)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
FontVisibility GetVisibilityForFamily(const nsACString& aName) const;
@ -205,7 +205,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
Script aRunScript,
const gfxFontStyle* aMatchStyle,
FontFamily& aMatchedFamily)
MOZ_REQUIRES(mLock) override;
REQUIRES(mLock) override;
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.
// But CFStringRef and NSString* are the same thing anyway (they're
// toll-free bridged).
void AddFamily(CFStringRef aFamily) MOZ_REQUIRES(mLock);
void AddFamily(CFStringRef aFamily) REQUIRES(mLock);
void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility)
MOZ_REQUIRES(mLock);
REQUIRES(mLock);
gfxFontEntry* CreateFontEntry(
mozilla::fontlist::Face* aFace,
@ -232,7 +232,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily,
bool aNeedFullnamePostscriptNames)
MOZ_REQUIRES(mLock) override;
REQUIRES(mLock) override;
enum { kATSGenerationInitial = -1 };

View File

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

View File

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

View File

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

View File

@ -185,7 +185,7 @@ class imgFrame {
private: // methods
~imgFrame();
bool AreAllPixelsWritten() const MOZ_REQUIRES(mMonitor);
bool AreAllPixelsWritten() const REQUIRES(mMonitor);
nsresult ImageUpdatedInternal(const nsIntRect& aUpdateRect);
void GetImageDataInternal(uint8_t** aData, uint32_t* length) const;
uint32_t GetImageBytesPerRow() const;
@ -229,20 +229,20 @@ class imgFrame {
/**
* Used for rasterized images, this contains the raw pixel data.
*/
RefPtr<SourceSurfaceSharedData> mRawSurface MOZ_GUARDED_BY(mMonitor);
RefPtr<SourceSurfaceSharedData> mBlankRawSurface MOZ_GUARDED_BY(mMonitor);
RefPtr<SourceSurfaceSharedData> mRawSurface GUARDED_BY(mMonitor);
RefPtr<SourceSurfaceSharedData> mBlankRawSurface GUARDED_BY(mMonitor);
/**
* Used for vector images that were not rasterized directly. This might be a
* blob recording or native surface.
*/
RefPtr<SourceSurface> mOptSurface MOZ_GUARDED_BY(mMonitor);
RefPtr<SourceSurface> mOptSurface GUARDED_BY(mMonitor);
nsIntRect mDecoded MOZ_GUARDED_BY(mMonitor);
nsIntRect mDecoded GUARDED_BY(mMonitor);
bool mAborted MOZ_GUARDED_BY(mMonitor);
bool mFinished MOZ_GUARDED_BY(mMonitor);
bool mShouldRecycle MOZ_GUARDED_BY(mMonitor);
bool mAborted GUARDED_BY(mMonitor);
bool mFinished GUARDED_BY(mMonitor);
bool mShouldRecycle GUARDED_BY(mMonitor);
//////////////////////////////////////////////////////////////////////////////
// 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
// mUncachedImages should be every imgRequest that is alive. These are weak
// pointers so we rely on the imgRequest destructor to remove itself.
imgSet mUncachedImages MOZ_GUARDED_BY(mUncachedImagesMutex);
imgSet mUncachedImages GUARDED_BY(mUncachedImagesMutex);
// 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
// destructor.

View File

@ -90,7 +90,7 @@ nsresult imgRequest::Init(
nsIRequest* aRequest, nsIChannel* aChannel, imgCacheEntry* aCacheEntry,
mozilla::dom::Document* aLoadingDocument,
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode,
nsIReferrerInfo* aReferrerInfo) MOZ_NO_THREAD_SAFETY_ANALYSIS {
nsIReferrerInfo* aReferrerInfo) NO_THREAD_SAFETY_ANALYSIS {
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
// mainthread

View File

@ -285,15 +285,15 @@ class imgRequest final : public nsIStreamListener,
// 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
// must not be a part of this bitfield.
RefPtr<ProgressTracker> mProgressTracker MOZ_GUARDED_BY(mMutex);
RefPtr<Image> mImage MOZ_GUARDED_BY(mMutex);
bool mIsMultiPartChannel : 1 MOZ_GUARDED_BY(mMutex);
bool mIsInCache : 1 MOZ_GUARDED_BY(mMutex);
bool mDecodeRequested : 1 MOZ_GUARDED_BY(mMutex);
bool mNewPartPending : 1 MOZ_GUARDED_BY(mMutex);
bool mHadInsecureRedirect : 1 MOZ_GUARDED_BY(mMutex);
RefPtr<ProgressTracker> mProgressTracker GUARDED_BY(mMutex);
RefPtr<Image> mImage GUARDED_BY(mMutex);
bool mIsMultiPartChannel : 1 GUARDED_BY(mMutex);
bool mIsInCache : 1 GUARDED_BY(mMutex);
bool mDecodeRequested : 1 GUARDED_BY(mMutex);
bool mNewPartPending : 1 GUARDED_BY(mMutex);
bool mHadInsecureRedirect : 1 GUARDED_BY(mMutex);
// The ID of the inner window origin, used for error reporting.
uint64_t mInnerWindowId MOZ_GUARDED_BY(mMutex);
uint64_t mInnerWindowId GUARDED_BY(mMutex);
};
#endif // mozilla_image_imgRequest_h

View File

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

View File

@ -137,10 +137,9 @@ class MessageLoop::EventTarget : public nsISerialEventTarget,
}
mozilla::Mutex mMutex;
bool mShutdownTasksRun MOZ_GUARDED_BY(mMutex) = false;
nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks
MOZ_GUARDED_BY(mMutex);
MessageLoop* mLoop MOZ_GUARDED_BY(mMutex);
bool mShutdownTasksRun GUARDED_BY(mMutex) = false;
nsTArray<nsCOMPtr<nsITargetShutdownTask>> mShutdownTasks GUARDED_BY(mMutex);
MessageLoop* mLoop GUARDED_BY(mMutex);
};
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
// have not yet been sorted out into items for our work_queue_ vs items that
// will be handled by the TimerManager.
TaskQueue incoming_queue_ MOZ_GUARDED_BY(incoming_queue_lock_);
TaskQueue incoming_queue_ GUARDED_BY(incoming_queue_lock_);
// Protect access to incoming_queue_.
mozilla::Mutex incoming_queue_lock_;

View File

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

View File

@ -226,7 +226,7 @@ class Node {
void ConvertToProxy(Port* port, const NodeName& to_node_name,
PortName* port_name,
Event::PortDescriptor* port_descriptor)
MOZ_REQUIRES(ports_lock_);
REQUIRES(ports_lock_);
int AcceptPort(const PortName& port_name,
const Event::PortDescriptor& port_descriptor);
@ -249,19 +249,19 @@ class Node {
void UpdatePortPeerAddress(const PortName& local_port_name, Port* local_port,
const NodeName& new_peer_node,
const PortName& new_peer_port)
MOZ_REQUIRES(ports_lock_);
REQUIRES(ports_lock_);
// Removes an entry from |peer_port_map_| corresponding to |local_port|'s peer
// address, if valid.
void RemoveFromPeerPortMap(const PortName& local_port_name, Port* local_port)
MOZ_REQUIRES(ports_lock_);
REQUIRES(ports_lock_);
// 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
// locks, through the extent of this method.
void SwapPortPeers(const PortName& port0_name, Port* port0,
const PortName& port1_name, Port* port1)
MOZ_REQUIRES(ports_lock_);
REQUIRES(ports_lock_);
// 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
@ -296,7 +296,7 @@ class Node {
// destroyed while this (or any individual Port) lock is held.
mozilla::Mutex ports_lock_{"Ports Lock"};
std::unordered_map<LocalPortName, RefPtr<Port>> ports_
MOZ_GUARDED_BY(ports_lock_);
GUARDED_BY(ports_lock_);
// 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
@ -316,7 +316,7 @@ class Node {
// port on a peer node. The key to this map is the corresponding peer node
// name.
std::unordered_map<NodeName, PeerPortMap> peer_port_maps_
MOZ_GUARDED_BY(ports_lock_);
GUARDED_BY(ports_lock_);
};
} // namespace ports

View File

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

View File

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

View File

@ -51,8 +51,7 @@ class BrowserProcessSubThread : public base::Thread {
// 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
// themselves from this array upon destruction.
static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] MOZ_GUARDED_BY(
sLock);
static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] GUARDED_BY(sLock);
};
inline void AssertIOThread() {

View File

@ -41,8 +41,7 @@ class CrashReporterClient {
private:
static StaticMutex sLock;
static StaticRefPtr<CrashReporterClient> sClientSingleton
MOZ_GUARDED_BY(sLock);
static StaticRefPtr<CrashReporterClient> sClientSingleton GUARDED_BY(sLock);
};
} // 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.
// Actions will be run in-order.
class MOZ_SCOPED_CAPABILITY DataPipeAutoLock {
class SCOPED_CAPABILITY DataPipeAutoLock {
public:
explicit DataPipeAutoLock(Mutex& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex)
explicit DataPipeAutoLock(Mutex& aMutex) CAPABILITY_ACQUIRE(aMutex)
: mMutex(aMutex) {
mMutex.Lock();
}
@ -39,7 +39,7 @@ class MOZ_SCOPED_CAPABILITY DataPipeAutoLock {
mActions.AppendElement(std::move(aAction));
}
~DataPipeAutoLock() MOZ_CAPABILITY_RELEASE() {
~DataPipeAutoLock() CAPABILITY_RELEASE() {
mMutex.Unlock();
for (auto& action : mActions) {
action();
@ -82,7 +82,7 @@ class DataPipeLink : public NodeController::PortObserver {
mOffset(aOffset),
mAvailable(aAvailable) {}
void Init() MOZ_EXCLUDES(*mMutex) {
void Init() EXCLUDES(*mMutex) {
{
DataPipeAutoLock lock(*mMutex);
if (NS_FAILED(mPeerStatus)) {
@ -94,18 +94,18 @@ class DataPipeLink : public NodeController::PortObserver {
OnPortStatusChanged();
}
void OnPortStatusChanged() final MOZ_EXCLUDES(*mMutex);
void OnPortStatusChanged() final EXCLUDES(*mMutex);
// 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
// called, `mCallback` will be cleared.
void NotifyOnUnlock(DataPipeAutoLock& aLock) MOZ_REQUIRES(*mMutex) {
void NotifyOnUnlock(DataPipeAutoLock& aLock) REQUIRES(*mMutex) {
DoNotifyOnUnlock(aLock, mCallback.forget(), mCallbackTarget.forget());
}
void SendBytesConsumedOnUnlock(DataPipeAutoLock& aLock, uint32_t aBytes)
MOZ_REQUIRES(*mMutex) {
REQUIRES(*mMutex) {
MOZ_LOG(gDataPipeLog, LogLevel::Verbose,
("SendOnUnlock CONSUMED(%u) %s", aBytes, Describe(aLock).get()));
if (NS_FAILED(mPeerStatus)) {
@ -128,7 +128,7 @@ class DataPipeLink : public NodeController::PortObserver {
}
void SetPeerError(DataPipeAutoLock& aLock, nsresult aStatus,
bool aSendClosed = false) MOZ_REQUIRES(*mMutex) {
bool aSendClosed = false) REQUIRES(*mMutex) {
MOZ_LOG(gDataPipeLog, LogLevel::Debug,
("SetPeerError(%s%s) %s", GetStaticErrorName(aStatus),
aSendClosed ? ", send" : "", Describe(aLock).get()));
@ -150,7 +150,7 @@ class DataPipeLink : public NodeController::PortObserver {
NotifyOnUnlock(aLock);
}
nsCString Describe(DataPipeAutoLock& aLock) const MOZ_REQUIRES(*mMutex) {
nsCString Describe(DataPipeAutoLock& aLock) const REQUIRES(*mMutex) {
return nsPrintfCString(
"[%s(%p) c=%u e=%s o=%u a=%u, cb=%s]",
mReceiverSide ? "Receiver" : "Sender", this, mCapacity,
@ -162,20 +162,20 @@ class DataPipeLink : public NodeController::PortObserver {
// `DataPipeLink`.
std::shared_ptr<Mutex> mMutex;
ScopedPort mPort MOZ_GUARDED_BY(*mMutex);
ScopedPort mPort GUARDED_BY(*mMutex);
const RefPtr<SharedMemory> mShmem;
const uint32_t mCapacity;
const bool mReceiverSide;
bool mProcessingSegment MOZ_GUARDED_BY(*mMutex) = false;
bool mProcessingSegment GUARDED_BY(*mMutex) = false;
nsresult mPeerStatus MOZ_GUARDED_BY(*mMutex) = NS_OK;
uint32_t mOffset MOZ_GUARDED_BY(*mMutex) = 0;
uint32_t mAvailable MOZ_GUARDED_BY(*mMutex) = 0;
nsresult mPeerStatus GUARDED_BY(*mMutex) = NS_OK;
uint32_t mOffset GUARDED_BY(*mMutex) = 0;
uint32_t mAvailable GUARDED_BY(*mMutex) = 0;
bool mCallbackClosureOnly MOZ_GUARDED_BY(*mMutex) = false;
nsCOMPtr<nsIRunnable> mCallback MOZ_GUARDED_BY(*mMutex);
nsCOMPtr<nsIEventTarget> mCallbackTarget MOZ_GUARDED_BY(*mMutex);
bool mCallbackClosureOnly GUARDED_BY(*mMutex) = false;
nsCOMPtr<nsIRunnable> mCallback GUARDED_BY(*mMutex);
nsCOMPtr<nsIEventTarget> mCallbackTarget GUARDED_BY(*mMutex);
};
void DataPipeLink::OnPortStatusChanged() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -241,7 +241,7 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet {
mutable RecursiveMutex mMutex;
FontFaceSet* MOZ_NON_OWNING_REF mOwner MOZ_GUARDED_BY(mMutex);
FontFaceSet* MOZ_NON_OWNING_REF mOwner GUARDED_BY(mMutex);
// The document's node principal, which is the principal font loads 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,
// its value must be updated by a call to ResetStandardFontLoadPrincipal.
mutable RefPtr<gfxFontSrcPrincipal> mStandardFontLoadPrincipal
MOZ_GUARDED_BY(mMutex);
GUARDED_BY(mMutex);
// Set of all loaders pointing to us. These are not strong pointers,
// but that's OK because nsFontFaceLoader always calls RemoveLoader on
// us before it dies (unless we die first).
nsTHashtable<nsPtrHashKey<nsFontFaceLoader>> mLoaders MOZ_GUARDED_BY(mMutex);
nsTHashtable<nsPtrHashKey<nsFontFaceLoader>> mLoaders GUARDED_BY(mMutex);
// The non rule backed FontFace objects that have been added to this
// FontFaceSet.
nsTArray<FontFaceRecord> mNonRuleFaces MOZ_GUARDED_BY(mMutex);
nsTArray<FontFaceRecord> mNonRuleFaces GUARDED_BY(mMutex);
// The overall status of the loading or loaded fonts in the FontFaceSet.
dom::FontFaceSetLoadStatus mStatus MOZ_GUARDED_BY(mMutex);
dom::FontFaceSetLoadStatus mStatus GUARDED_BY(mMutex);
// 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
@ -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
// have no way to verify that we've checked all the loads we should.
nsTHashMap<nsPtrHashKey<const gfxFontFaceSrc>, bool> mAllowedFontLoads
MOZ_GUARDED_BY(mMutex);
GUARDED_BY(mMutex);
// Whether mNonRuleFaces has changed since last time UpdateRules ran.
bool mNonRuleFacesDirty MOZ_GUARDED_BY(mMutex);
bool mNonRuleFacesDirty GUARDED_BY(mMutex);
// Whether any FontFace objects in mRuleFaces or mNonRuleFaces are
// loading. Only valid when mHasLoadingFontFacesIsDirty is false. Don't use
// this variable directly; call the HasLoadingFontFaces method instead.
bool mHasLoadingFontFaces MOZ_GUARDED_BY(mMutex);
bool mHasLoadingFontFaces GUARDED_BY(mMutex);
// This variable is only valid when mLoadingDirty is false.
bool mHasLoadingFontFacesIsDirty MOZ_GUARDED_BY(mMutex);
bool mHasLoadingFontFacesIsDirty GUARDED_BY(mMutex);
// Whether CheckLoadingFinished calls should be ignored. See comment in
// OnFontFaceStatusChanged.
bool mDelayedLoadCheck MOZ_GUARDED_BY(mMutex);
bool mDelayedLoadCheck GUARDED_BY(mMutex);
// Whether the docshell for our document indicated that loads should
// bypass the cache.

View File

@ -52,9 +52,9 @@ class FontFaceSetWorkerImpl final : public FontFaceSetImpl {
TimeStamp GetNavigationStartTimeStamp() override;
RefPtr<ThreadSafeWorkerRef> mWorkerRef MOZ_GUARDED_BY(mMutex);
RefPtr<ThreadSafeWorkerRef> mWorkerRef GUARDED_BY(mMutex);
RefPtr<URLExtraData> mURLExtraData MOZ_GUARDED_BY(mMutex);
RefPtr<URLExtraData> mURLExtraData GUARDED_BY(mMutex);
};
} // 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
// 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.
struct MOZ_CAPABILITY Mutex {
struct CAPABILITY Mutex {
#if defined(XP_WIN)
CRITICAL_SECTION mMutex;
#elif defined(XP_DARWIN)
@ -86,7 +86,7 @@ struct MOZ_CAPABILITY Mutex {
return true;
}
inline void Lock() MOZ_CAPABILITY_ACQUIRE() {
inline void Lock() CAPABILITY_ACQUIRE() {
#if defined(XP_WIN)
EnterCriticalSection(&mMutex);
#elif defined(XP_DARWIN)
@ -109,7 +109,7 @@ struct MOZ_CAPABILITY Mutex {
#endif
}
inline void Unlock() MOZ_CAPABILITY_RELEASE() {
inline void Unlock() CAPABILITY_RELEASE() {
#if defined(XP_WIN)
LeaveCriticalSection(&mMutex);
#elif defined(XP_DARWIN)
@ -140,11 +140,9 @@ struct MOZ_CAPABILITY Mutex {
struct CAPABILITY StaticMutex {
SRWLOCK mMutex;
inline void Lock() MOZ_CAPABILITY_ACQUIRE() {
AcquireSRWLockExclusive(&mMutex);
}
inline void Lock() CAPABILITY_ACQUIRE() { AcquireSRWLockExclusive(&mMutex); }
inline void Unlock() MOZ_CAPABILITY_RELEASE() {
inline void Unlock() CAPABILITY_RELEASE() {
ReleaseSRWLockExclusive(&mMutex);
}
};
@ -170,12 +168,12 @@ typedef Mutex StaticMutex;
#endif
template <typename T>
struct MOZ_SCOPED_CAPABILITY MOZ_RAII AutoLock {
explicit AutoLock(T& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) {
struct SCOPED_CAPABILITY MOZ_RAII AutoLock {
explicit AutoLock(T& aMutex) CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) {
mMutex.Lock();
}
~AutoLock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); }
~AutoLock() CAPABILITY_RELEASE() { mMutex.Unlock(); }
AutoLock(const 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
// is threaded here.
FORK_HOOK
void _malloc_prefork(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
void _malloc_prefork(void) NO_THREAD_SAFETY_ANALYSIS {
// Acquire all mutexes in a safe order.
gArenas.mLock.Lock();
@ -4744,7 +4744,7 @@ void _malloc_prefork(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
}
FORK_HOOK
void _malloc_postfork_parent(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
void _malloc_postfork_parent(void) NO_THREAD_SAFETY_ANALYSIS {
// Release all mutexes, now that fork() has completed.
huge_mtx.Unlock();

View File

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

View File

@ -800,9 +800,9 @@ class GMut {
// 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 normal way in the caller.
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
sMutex.Unlock();
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
*static_cast<uint8_t*>(aPtr) = 0;
MOZ_CRASH("unreachable");
}
@ -880,10 +880,8 @@ class GMut {
}
#ifndef XP_WIN
static void prefork() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); }
static void postfork_parent() MOZ_NO_THREAD_SAFETY_ANALYSIS {
sMutex.Unlock();
}
static void prefork() NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); }
static void postfork_parent() NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); }
static void postfork_child() { sMutex.Init(); }
#endif

View File

@ -686,10 +686,10 @@
* MOZ_UNANNOTATED/MOZ_ANNOTATED: Applies to Mutexes/Monitors and variations on
* them. MOZ_UNANNOTATED indicates that the Mutex/Monitor/etc hasn't been
* examined and annotated using macros from mfbt/ThreadSafety --
* MOZ_GUARDED_BY()/REQUIRES()/etc. MOZ_ANNOTATED is used in rare cases to
* 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
* MOZ_GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can
* ignore this Mutex/Monitor/etc)
* GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can ignore
* this Mutex/Monitor/etc)
*/
// 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>,
* so we suppress thread-safety warnings here
*/
MOZ_PUSH_IGNORE_THREAD_SAFETY
PUSH_IGNORE_THREAD_SAFETY
ref().T::~T();
MOZ_POP_THREAD_SAFETY
POP_THREAD_SAFETY
poisonData();
}
mIsSome = false;

View File

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

View File

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

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