Bug 1760357 - Part 4: Add straightforward annotations to IPC types, r=jesup

Differential Revision: https://phabricator.services.mozilla.com/D141535
This commit is contained in:
Nika Layzell 2022-03-22 14:59:41 +00:00
Родитель 6cd1233132
Коммит 8b588479cd
9 изменённых файлов: 36 добавлений и 35 удалений

Просмотреть файл

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

Просмотреть файл

@ -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,

Просмотреть файл

@ -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_;

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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() {

Просмотреть файл

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

Просмотреть файл

@ -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<nsIThread> gIPCLaunchThread;
static mozilla::StaticMutex gIPCLaunchThreadMutex;
static mozilla::StaticRefPtr<nsIThread> gIPCLaunchThread
GUARDED_BY(gIPCLaunchThreadMutex);
class IPCLaunchThreadObserver final : public nsIObserver {
public:

Просмотреть файл

@ -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<LinkedList<GeckoChildProcessHost>>
sGeckoChildProcessHosts;
static StaticMutex sMutex MOZ_UNANNOTATED;
sGeckoChildProcessHosts GUARDED_BY(sMutex);
static StaticMutex sMutex;
};
nsCOMPtr<nsIEventTarget> GetIPCLauncher();

Просмотреть файл

@ -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)