diff --git a/ipc/chromium/src/base/at_exit.h b/ipc/chromium/src/base/at_exit.h index f0c0a6311468..25a51c1cdfb1 100644 --- a/ipc/chromium/src/base/at_exit.h +++ b/ipc/chromium/src/base/at_exit.h @@ -64,8 +64,8 @@ class AtExitManager { void* param_; }; - mozilla::Mutex lock_ MOZ_UNANNOTATED; - std::stack stack_; + mozilla::Mutex lock_; + std::stack stack_ GUARDED_BY(lock_); AtExitManager* next_manager_; // Stack of managers to allow shadowing. DISALLOW_COPY_AND_ASSIGN(AtExitManager); diff --git a/ipc/chromium/src/base/message_loop.cc b/ipc/chromium/src/base/message_loop.cc index 22f823d04eea..e5da7b61adf8 100644 --- a/ipc/chromium/src/base/message_loop.cc +++ b/ipc/chromium/src/base/message_loop.cc @@ -111,8 +111,8 @@ class MessageLoop::EventTarget : public nsISerialEventTarget, mLoop = nullptr; } - mozilla::Mutex mMutex MOZ_UNANNOTATED; - MessageLoop* mLoop; + mozilla::Mutex mMutex; + MessageLoop* mLoop GUARDED_BY(mMutex); }; NS_IMPL_ISUPPORTS(MessageLoop::EventTarget, nsIEventTarget, diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index 9c45fbfdfc6f..7d2d3d4d0e09 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -421,9 +421,9 @@ 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_; + TaskQueue incoming_queue_ GUARDED_BY(incoming_queue_lock_); // Protect access to incoming_queue_. - mozilla::Mutex incoming_queue_lock_ MOZ_UNANNOTATED; + mozilla::Mutex incoming_queue_lock_; RunState* state_; int run_depth_base_; diff --git a/ipc/chromium/src/base/time_win.cc b/ipc/chromium/src/base/time_win.cc index c3e865143012..36d3894bd04c 100644 --- a/ipc/chromium/src/base/time_win.cc +++ b/ipc/chromium/src/base/time_win.cc @@ -209,6 +209,14 @@ DWORD timeGetTimeWrapper() { return timeGetTime(); } DWORD (*tick_function)(void) = &timeGetTimeWrapper; +// This setup is a little gross: the `now` instance lives until libxul is +// unloaded, but leak checking runs prior to that, and would see a Mutex +// instance contained in NowSingleton as still live. Said instance would +// be reported as a leak...but it's not, really. To avoid that, we need +// to use StaticMutex (which is not leak-checked), but StaticMutex can't +// be a member variable. So we have to have this separate static variable. +static mozilla::StaticMutex sNowSingletonLock; + // We use timeGetTime() to implement TimeTicks::Now(). This can be problematic // because it returns the number of milliseconds since Windows has started, // which will roll over the 32-bit value every ~49 days. We try to track @@ -217,7 +225,7 @@ DWORD (*tick_function)(void) = &timeGetTimeWrapper; class NowSingleton { public: TimeDelta Now() { - mozilla::StaticMutexAutoLock locked(lock_); + mozilla::StaticMutexAutoLock locked(sNowSingletonLock); // We should hold the lock while calling tick_function to make sure that // we keep our last_seen_ stay correctly in sync. DWORD now = tick_function(); @@ -229,28 +237,20 @@ class NowSingleton { } static NowSingleton& instance() { - // This setup is a little gross: the `now` instance lives until libxul is - // unloaded, but leak checking runs prior to that, and would see a Mutex - // instance contained in NowSingleton as still live. Said instance would - // be reported as a leak...but it's not, really. To avoid that, we need - // to use StaticMutex (which is not leak-checked), but StaticMutex can't - // be a member variable. So we have to have this separate variable and - // pass it into the NowSingleton constructor. - static mozilla::StaticMutex mutex MOZ_UNANNOTATED; - static NowSingleton now(mutex); + static NowSingleton now; return now; } private: - explicit NowSingleton(mozilla::StaticMutex& aMutex) - : lock_(aMutex), - rollover_(TimeDelta::FromMilliseconds(0)), - last_seen_(0) {} + explicit NowSingleton() + : rollover_(TimeDelta::FromMilliseconds(0)), last_seen_(0) {} ~NowSingleton() = default; - mozilla::StaticMutex& lock_; // To protected last_seen_ and rollover_. - TimeDelta rollover_; // Accumulation of time lost due to rollover. - DWORD last_seen_; // The last timeGetTime value we saw, to detect rollover. + TimeDelta rollover_ GUARDED_BY( + sNowSingletonLock); // Accumulation of time lost due to rollover. + DWORD last_seen_ + GUARDED_BY(sNowSingletonLock); // The last timeGetTime value we saw, to + // detect rollover. DISALLOW_COPY_AND_ASSIGN(NowSingleton); }; diff --git a/ipc/glue/BrowserProcessSubThread.h b/ipc/glue/BrowserProcessSubThread.h index 6397f42d205e..c3f5eb573cd1 100644 --- a/ipc/glue/BrowserProcessSubThread.h +++ b/ipc/glue/BrowserProcessSubThread.h @@ -45,13 +45,13 @@ class BrowserProcessSubThread : public base::Thread { // This lock protects |browser_threads_|. Do not read or modify that array // without holding this lock. Do not block while holding this lock. - static StaticMutex sLock MOZ_UNANNOTATED; + static StaticMutex sLock; // An array of the ChromeThread objects. This array is protected by |lock_|. // 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]; + static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] GUARDED_BY(sLock); }; inline void AssertIOThread() { diff --git a/ipc/glue/CrashReporterClient.h b/ipc/glue/CrashReporterClient.h index e47ec94bd7f0..099a1e8e2e5f 100644 --- a/ipc/glue/CrashReporterClient.h +++ b/ipc/glue/CrashReporterClient.h @@ -40,8 +40,8 @@ class CrashReporterClient { ~CrashReporterClient(); private: - static StaticMutex sLock MOZ_UNANNOTATED; - static StaticRefPtr sClientSingleton; + static StaticMutex sLock; + static StaticRefPtr sClientSingleton GUARDED_BY(sLock); }; } // namespace ipc diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index fb778c85d2ff..8596f4e2a9ec 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -881,8 +881,9 @@ void BaseProcessLauncher::GetChildLogName(const char* origLogName, #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) || \ defined(MOZ_ENABLE_FORKSERVER) -static mozilla::StaticMutex gIPCLaunchThreadMutex MOZ_UNANNOTATED; -static mozilla::StaticRefPtr gIPCLaunchThread; +static mozilla::StaticMutex gIPCLaunchThreadMutex; +static mozilla::StaticRefPtr gIPCLaunchThread + GUARDED_BY(gIPCLaunchThreadMutex); class IPCLaunchThreadObserver final : public nsIObserver { public: diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index f55de551b05c..517686a35e7c 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -189,7 +189,7 @@ class GeckoChildProcessHost : public ChildProcessHost, ~GeckoChildProcessHost(); GeckoProcessType mProcessType; bool mIsFileContent; - Monitor mMonitor MOZ_UNANNOTATED; + Monitor mMonitor; FilePath mProcessPath; // GeckoChildProcessHost holds the launch options so they can be set // up on the main thread using main-thread-only APIs like prefs, and @@ -215,7 +215,7 @@ class GeckoChildProcessHost : public ChildProcessHost, // is well. PROCESS_CONNECTED, PROCESS_ERROR - } mProcessState; + } mProcessState GUARDED_BY(mMonitor); void PrepareLaunch(); @@ -286,8 +286,8 @@ class GeckoChildProcessHost : public ChildProcessHost, static uint32_t sNextUniqueID; static StaticAutoPtr> - sGeckoChildProcessHosts; - static StaticMutex sMutex MOZ_UNANNOTATED; + sGeckoChildProcessHosts GUARDED_BY(sMutex); + static StaticMutex sMutex; }; nsCOMPtr GetIPCLauncher(); diff --git a/ipc/glue/MessagePump.h b/ipc/glue/MessagePump.h index 162aba83d6c4..618f3faaf307 100644 --- a/ipc/glue/MessagePump.h +++ b/ipc/glue/MessagePump.h @@ -133,8 +133,8 @@ class MessagePumpForNonMainUIThreads final : public base::MessagePumpForUI, private: ~MessagePumpForNonMainUIThreads() {} - bool mInWait; - mozilla::Mutex mWaitLock MOZ_UNANNOTATED; + bool mInWait GUARDED_BY(mWaitLock); + mozilla::Mutex mWaitLock; }; #endif // defined(XP_WIN)