Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/ipc/BrowserProcessSubThread.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef mozilla_ipc_BrowserProcessSubThread_h
8
#define mozilla_ipc_BrowserProcessSubThread_h
9
10
#include "base/thread.h"
11
#include "mozilla/StaticMutex.h"
12
13
#include "nsDebug.h"
14
15
namespace mozilla {
16
namespace ipc {
17
18
// Copied from browser_process_impl.cc, modified slightly.
19
class BrowserProcessSubThread : public base::Thread
20
{
21
public:
22
  // An enumeration of the well-known threads.
23
  enum ID {
24
      IO,
25
      //FILE,
26
      //DB,
27
      //HISTORY,
28
#if defined(OS_LINUX) || defined(OS_SOLARIS)
29
      // This thread has a second connection to the X server and is used
30
      // to process UI requests when routing the request to the UI
31
      // thread would risk deadlock.
32
      BACKGROUND_X11,
33
#endif
34
35
      // This identifier does not represent a thread.  Instead it counts
36
      // the number of well-known threads.  Insert new well-known
37
      // threads before this identifier.
38
      ID_COUNT
39
  };
40
41
  explicit BrowserProcessSubThread(ID aId);
42
  ~BrowserProcessSubThread();
43
44
  static MessageLoop* GetMessageLoop(ID identifier);
45
46
protected:
47
  virtual void Init() override;
48
  virtual void CleanUp() override;
49
50
private:
51
  // The identifier of this thread.  Only one thread can exist with a given
52
  // identifier at a given time.
53
  ID mIdentifier;
54
55
  // This lock protects |browser_threads_|.  Do not read or modify that array
56
  // without holding this lock.  Do not block while holding this lock.
57
58
  static StaticMutex sLock;
59
60
  // An array of the ChromeThread objects.  This array is protected by |lock_|.
61
  // The threads are not owned by this array.  Typically, the threads are owned
62
  // on the UI thread by the g_browser_process object.  ChromeThreads remove
63
  // themselves from this array upon destruction.
64
  static BrowserProcessSubThread* sBrowserThreads[ID_COUNT];
65
};
66
67
inline void AssertIOThread()
68
0
{
69
0
  NS_ASSERTION(MessageLoop::TYPE_IO == MessageLoop::current()->type(),
70
0
               "should be on the IO thread!");
71
0
}
72
73
} // namespace ipc
74
} // namespace mozilla
75
76
#endif // mozilla_ipc_BrowserProcessSubThread_h