Bug 1700051: part 31.4) Move `mSoftTextValid` to `SoftText`. r=smaug
[gecko.git] / ipc / glue / BrowserProcessSubThread.cpp
blob2a7947da9e8d21b842f70dc71f50e5584c13e402
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/ipc/BrowserProcessSubThread.h"
9 #if defined(OS_WIN)
10 # include <objbase.h>
11 #endif
13 namespace mozilla {
14 namespace ipc {
17 // BrowserProcessSubThread
20 // Friendly names for the well-known threads.
21 static const char* kBrowserThreadNames[BrowserProcessSubThread::ID_COUNT] = {
22 "IPC I/O Parent", // IO
25 /* static */
26 StaticMutex BrowserProcessSubThread::sLock;
27 BrowserProcessSubThread* BrowserProcessSubThread::sBrowserThreads[ID_COUNT] = {
28 nullptr, // IO
31 BrowserProcessSubThread::BrowserProcessSubThread(ID aId)
32 : base::Thread(kBrowserThreadNames[aId]), mIdentifier(aId) {
33 StaticMutexAutoLock lock(sLock);
34 DCHECK(aId >= 0 && aId < ID_COUNT);
35 DCHECK(sBrowserThreads[aId] == nullptr);
36 sBrowserThreads[aId] = this;
39 BrowserProcessSubThread::~BrowserProcessSubThread() {
40 Stop();
42 StaticMutexAutoLock lock(sLock);
43 sBrowserThreads[mIdentifier] = nullptr;
47 void BrowserProcessSubThread::Init() {
48 #if defined(OS_WIN)
49 // Initializes the COM library on the current thread.
50 CoInitialize(nullptr);
51 #endif
54 void BrowserProcessSubThread::CleanUp() {
55 #if defined(OS_WIN)
56 // Closes the COM library on the current thread. CoInitialize must
57 // be balanced by a corresponding call to CoUninitialize.
58 CoUninitialize();
59 #endif
62 // static
63 MessageLoop* BrowserProcessSubThread::GetMessageLoop(ID aId) {
64 StaticMutexAutoLock lock(sLock);
65 DCHECK(aId >= 0 && aId < ID_COUNT);
67 if (sBrowserThreads[aId]) return sBrowserThreads[aId]->message_loop();
69 return nullptr;
72 } // namespace ipc
73 } // namespace mozilla