Skip to content

Commit c50cb52

Browse files
committed
Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
1 parent 2be8add commit c50cb52

File tree

202 files changed

+1523
-1448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+1523
-1448
lines changed

docshell/base/timeline/ObservedDocShell.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ObservedDocShell : public MarkersStorage {
3737
// Off the main thread only.
3838
Mutex mLock;
3939
nsTArray<UniquePtr<AbstractTimelineMarker>> mOffTheMainThreadTimelineMarkers
40-
GUARDED_BY(mLock);
40+
MOZ_GUARDED_BY(mLock);
4141

4242
public:
4343
explicit ObservedDocShell(nsIDocShell* aDocShell);

docshell/base/timeline/TimelineConsumers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ class TimelineConsumers {
101101
private:
102102
static StaticMutex sMutex;
103103

104-
static LinkedList<MarkersStorage>& MarkersStores() REQUIRES(sMutex);
104+
static LinkedList<MarkersStorage>& MarkersStores() MOZ_REQUIRES(sMutex);
105105

106-
static uint32_t sActiveConsumers GUARDED_BY(sMutex);
106+
static uint32_t sActiveConsumers MOZ_GUARDED_BY(sMutex);
107107
static StaticAutoPtr<LinkedList<MarkersStorage>> sMarkersStores
108-
GUARDED_BY(sMutex);
108+
MOZ_GUARDED_BY(sMutex);
109109
};
110110

111111
} // namespace mozilla

dom/base/BodyStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void BodyStream::EnqueueChunkWithSizeIntoStream(JSContext* aCx,
428428
// thread-safety doesn't handle emplace well
429429
NS_IMETHODIMP
430430
BodyStream::OnInputStreamReady(nsIAsyncInputStream* aStream)
431-
NO_THREAD_SAFETY_ANALYSIS {
431+
MOZ_NO_THREAD_SAFETY_ANALYSIS {
432432
AssertIsOnOwningThread();
433433
MOZ_DIAGNOSTIC_ASSERT(aStream);
434434
mAsyncWaitWorkerRef = nullptr;

dom/base/BodyStream.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,18 @@ class BodyStream final : public nsIInputStreamCallback,
141141

142142
void ErrorPropagation(JSContext* aCx,
143143
const MutexSingleWriterAutoLock& aProofOfLock,
144-
ReadableStream* aStream, nsresult aRv) REQUIRES(mMutex);
144+
ReadableStream* aStream, nsresult aRv)
145+
MOZ_REQUIRES(mMutex);
145146

146147
// TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605)
147148
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects(
148149
JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock,
149-
ReadableStream* aStream) REQUIRES(mMutex);
150+
ReadableStream* aStream) MOZ_REQUIRES(mMutex);
150151

151152
class WorkerShutdown;
152153

153154
void ReleaseObjects(const MutexSingleWriterAutoLock& aProofOfLock)
154-
REQUIRES(mMutex);
155+
MOZ_REQUIRES(mMutex);
155156

156157
void ReleaseObjects();
157158

@@ -186,12 +187,12 @@ class BodyStream final : public nsIInputStreamCallback,
186187
MutexSingleWriter mMutex;
187188

188189
// Protected by mutex.
189-
State mState GUARDED_BY(mMutex); // all writes are from the owning thread
190+
State mState MOZ_GUARDED_BY(mMutex); // all writes are from the owning thread
190191

191192
// mGlobal is set on creation, and isn't modified off the owning thread.
192193
// It isn't set to nullptr until ReleaseObjects() runs.
193194
nsCOMPtr<nsIGlobalObject> mGlobal;
194-
RefPtr<BodyStreamHolder> mStreamHolder GUARDED_BY(mMutex);
195+
RefPtr<BodyStreamHolder> mStreamHolder MOZ_GUARDED_BY(mMutex);
195196
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
196197

197198
// This is the original inputStream received during the CTOR. It will be

dom/canvas/WebGLContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
272272
~LruPosition() { Reset(); }
273273
};
274274

275-
mutable LruPosition mLruPosition GUARDED_BY(sLruMutex);
275+
mutable LruPosition mLruPosition MOZ_GUARDED_BY(sLruMutex);
276276

277277
void BumpLruLocked(const StaticMutexAutoLock& aProofOfLock);
278278

@@ -740,7 +740,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
740740

741741
private:
742742
static StaticMutex sLruMutex;
743-
static std::list<WebGLContext*> sLru GUARDED_BY(sLruMutex);
743+
static std::list<WebGLContext*> sLru MOZ_GUARDED_BY(sLruMutex);
744744

745745
// State tracking slots
746746
bool mDitherEnabled = true;

dom/console/ConsoleReportCollector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConsoleReportCollector final : public nsIConsoleReportCollector {
8181
Mutex mMutex;
8282

8383
// protected by mMutex
84-
nsTArray<PendingReport> mPendingReports GUARDED_BY(mMutex);
84+
nsTArray<PendingReport> mPendingReports MOZ_GUARDED_BY(mMutex);
8585

8686
public:
8787
NS_DECL_THREADSAFE_ISUPPORTS

dom/file/ipc/RemoteLazyInputStream.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
6666

6767
~RemoteLazyInputStream();
6868

69-
void StreamNeeded() REQUIRES(mMutex);
69+
void StreamNeeded() MOZ_REQUIRES(mMutex);
7070

7171
// Upon receiving the stream from our actor, we will not wrap it into an async
7272
// stream until needed. This allows callers to get access to the underlying
7373
// potentially-sync stream using `TakeInternalStream` before reading.
74-
nsresult EnsureAsyncRemoteStream() REQUIRES(mMutex);
74+
nsresult EnsureAsyncRemoteStream() MOZ_REQUIRES(mMutex);
7575

7676
// Note that data has been read from our input stream, and disconnect from our
7777
// remote actor.
@@ -82,7 +82,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
8282
IPC::MessageReader* aReader);
8383

8484
// Helper method to generate a description of a stream for use in loggging.
85-
nsCString Describe() REQUIRES(mMutex);
85+
nsCString Describe() MOZ_REQUIRES(mMutex);
8686

8787
// Start and length of the slice to apply on this RemoteLazyInputStream when
8888
// fetching the underlying stream with `SendStreamNeeded`.
@@ -112,7 +112,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
112112
// mInnerStream is released and any method will return
113113
// NS_BASE_STREAM_CLOSED.
114114
eClosed,
115-
} mState GUARDED_BY(mMutex) = eClosed;
115+
} mState MOZ_GUARDED_BY(mMutex) = eClosed;
116116

117117
// The actor which will be used to provide the underlying stream or length
118118
// information when needed, as well as to efficiently allow transferring the
@@ -121,22 +121,25 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,
121121
// The connection to our actor will be cleared once the stream has been closed
122122
// or has started reading, at which point this stream will be serialized and
123123
// cloned as-if it was the underlying stream.
124-
RefPtr<RemoteLazyInputStreamChild> mActor GUARDED_BY(mMutex);
124+
RefPtr<RemoteLazyInputStreamChild> mActor MOZ_GUARDED_BY(mMutex);
125125

126-
nsCOMPtr<nsIInputStream> mInnerStream GUARDED_BY(mMutex);
127-
nsCOMPtr<nsIAsyncInputStream> mAsyncInnerStream GUARDED_BY(mMutex);
126+
nsCOMPtr<nsIInputStream> mInnerStream MOZ_GUARDED_BY(mMutex);
127+
nsCOMPtr<nsIAsyncInputStream> mAsyncInnerStream MOZ_GUARDED_BY(mMutex);
128128

129129
// These 2 values are set only if mState is ePending or eRunning.
130130
// RefPtr is used instead of nsCOMPtr to avoid invoking QueryInterface when
131131
// assigning in debug builds, as `mInputStreamCallback` may not be threadsafe.
132-
RefPtr<nsIInputStreamCallback> mInputStreamCallback GUARDED_BY(mMutex);
133-
nsCOMPtr<nsIEventTarget> mInputStreamCallbackEventTarget GUARDED_BY(mMutex);
134-
uint32_t mInputStreamCallbackFlags GUARDED_BY(mMutex) = 0;
135-
uint32_t mInputStreamCallbackRequestedCount GUARDED_BY(mMutex) = 0;
132+
RefPtr<nsIInputStreamCallback> mInputStreamCallback MOZ_GUARDED_BY(mMutex);
133+
nsCOMPtr<nsIEventTarget> mInputStreamCallbackEventTarget
134+
MOZ_GUARDED_BY(mMutex);
135+
uint32_t mInputStreamCallbackFlags MOZ_GUARDED_BY(mMutex) = 0;
136+
uint32_t mInputStreamCallbackRequestedCount MOZ_GUARDED_BY(mMutex) = 0;
136137

137138
// These 2 values are set only if mState is ePending.
138-
nsCOMPtr<nsIFileMetadataCallback> mFileMetadataCallback GUARDED_BY(mMutex);
139-
nsCOMPtr<nsIEventTarget> mFileMetadataCallbackEventTarget GUARDED_BY(mMutex);
139+
nsCOMPtr<nsIFileMetadataCallback> mFileMetadataCallback
140+
MOZ_GUARDED_BY(mMutex);
141+
nsCOMPtr<nsIEventTarget> mFileMetadataCallbackEventTarget
142+
MOZ_GUARDED_BY(mMutex);
140143
};
141144

142145
} // namespace mozilla

dom/ipc/ProcessHangMonitor.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,22 @@ class HangMonitorChild : public PProcessHangMonitorChild,
156156
bool mSentReport;
157157

158158
// These fields must be accessed with mMonitor held.
159-
bool mTerminateScript GUARDED_BY(mMonitor);
160-
bool mStartDebugger GUARDED_BY(mMonitor);
161-
bool mFinishedStartingDebugger GUARDED_BY(mMonitor);
162-
bool mPaintWhileInterruptingJS GUARDED_BY(mMonitor);
163-
TabId mPaintWhileInterruptingJSTab GUARDED_BY(mMonitor);
159+
bool mTerminateScript MOZ_GUARDED_BY(mMonitor);
160+
bool mStartDebugger MOZ_GUARDED_BY(mMonitor);
161+
bool mFinishedStartingDebugger MOZ_GUARDED_BY(mMonitor);
162+
bool mPaintWhileInterruptingJS MOZ_GUARDED_BY(mMonitor);
163+
TabId mPaintWhileInterruptingJSTab MOZ_GUARDED_BY(mMonitor);
164164
MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch
165-
GUARDED_BY(mMonitor);
166-
bool mCancelContentJS GUARDED_BY(mMonitor);
167-
TabId mCancelContentJSTab GUARDED_BY(mMonitor);
165+
MOZ_GUARDED_BY(mMonitor);
166+
bool mCancelContentJS MOZ_GUARDED_BY(mMonitor);
167+
TabId mCancelContentJSTab MOZ_GUARDED_BY(mMonitor);
168168
nsIRemoteTab::NavigationType mCancelContentJSNavigationType
169-
GUARDED_BY(mMonitor);
170-
int32_t mCancelContentJSNavigationIndex GUARDED_BY(mMonitor);
171-
mozilla::Maybe<nsCString> mCancelContentJSNavigationURI GUARDED_BY(mMonitor);
172-
int32_t mCancelContentJSEpoch GUARDED_BY(mMonitor);
173-
bool mShutdownDone GUARDED_BY(mMonitor);
169+
MOZ_GUARDED_BY(mMonitor);
170+
int32_t mCancelContentJSNavigationIndex MOZ_GUARDED_BY(mMonitor);
171+
mozilla::Maybe<nsCString> mCancelContentJSNavigationURI
172+
MOZ_GUARDED_BY(mMonitor);
173+
int32_t mCancelContentJSEpoch MOZ_GUARDED_BY(mMonitor);
174+
bool mShutdownDone MOZ_GUARDED_BY(mMonitor);
174175

175176
JSContext* mContext; // const after constructor
176177

@@ -293,14 +294,14 @@ class HangMonitorParent : public PProcessHangMonitorParent,
293294
RefPtr<HangMonitoredProcess> mProcess;
294295

295296
// Must be accessed with mMonitor held.
296-
bool mShutdownDone GUARDED_BY(mMonitor);
297+
bool mShutdownDone MOZ_GUARDED_BY(mMonitor);
297298
// Map from plugin ID to crash dump ID. Protected by
298299
// mBrowserCrashDumpHashLock.
299300
nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds
300-
GUARDED_BY(mMonitor);
301-
Mutex mBrowserCrashDumpHashLock GUARDED_BY(mMonitor);
301+
MOZ_GUARDED_BY(mMonitor);
302+
Mutex mBrowserCrashDumpHashLock MOZ_GUARDED_BY(mMonitor);
302303
mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory
303-
GUARDED_BY(mMonitor);
304+
MOZ_GUARDED_BY(mMonitor);
304305
};
305306

306307
} // namespace

dom/media/AudioStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ int AudioStream::InvokeCubeb(Function aFunction, Args&&... aArgs) {
228228
}
229229

230230
nsresult AudioStream::Init(AudioDeviceInfo* aSinkInfo)
231-
NO_THREAD_SAFETY_ANALYSIS {
231+
MOZ_NO_THREAD_SAFETY_ANALYSIS {
232232
auto startTime = TimeStamp::Now();
233233
TRACE("AudioStream::Init");
234234

dom/media/AudioStream.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class AudioClock {
112112
// protected by the AudioStream monitor on other platforms.
113113
const UniquePtr<FrameHistory> mFrameHistory
114114
# ifndef XP_MACOSX
115-
GUARDED_BY(mMutex)
115+
MOZ_GUARDED_BY(mMutex)
116116
# endif
117117
;
118118
# ifdef XP_MACOSX
@@ -335,10 +335,10 @@ class AudioStream final {
335335

336336
// Return true if audio frames are valid (correct sampling rate and valid
337337
// channel count) otherwise false.
338-
bool IsValidAudioFormat(Chunk* aChunk) REQUIRES(mMonitor);
338+
bool IsValidAudioFormat(Chunk* aChunk) MOZ_REQUIRES(mMonitor);
339339

340340
template <typename Function, typename... Args>
341-
int InvokeCubeb(Function aFunction, Args&&... aArgs) REQUIRES(mMonitor);
341+
int InvokeCubeb(Function aFunction, Args&&... aArgs) MOZ_REQUIRES(mMonitor);
342342
bool CheckThreadIdChanged();
343343
void AssertIsOnAudioThread() const;
344344

@@ -382,7 +382,8 @@ class AudioStream final {
382382
std::atomic<ProfilerThreadId> mAudioThreadId;
383383
const bool mSandboxed = false;
384384

385-
MozPromiseHolder<MediaSink::EndedPromise> mEndedPromise GUARDED_BY(mMonitor);
385+
MozPromiseHolder<MediaSink::EndedPromise> mEndedPromise
386+
MOZ_GUARDED_BY(mMonitor);
386387
std::atomic<bool> mPlaybackComplete;
387388
// Both written on the MDSM thread, read on the audio thread.
388389
std::atomic<float> mPlaybackRate;

0 commit comments

Comments
 (0)