Add google_apis_unittests, midi_unittests to GN swarming.
[chromium-blink-merge.git] / content / browser / browser_thread_impl.h
blobeebe5b019ff6bc3cf452f94350c79386cf5dc1eb
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
6 #define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
8 #include "base/threading/thread.h"
9 #include "content/common/content_export.h"
10 #include "content/public/browser/browser_thread.h"
12 namespace content {
14 class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread,
15 public base::Thread {
16 public:
17 // Construct a BrowserThreadImpl with the supplied identifier. It is an error
18 // to construct a BrowserThreadImpl that already exists.
19 explicit BrowserThreadImpl(BrowserThread::ID identifier);
21 // Special constructor for the main (UI) thread and unittests. If a
22 // |message_loop| is provied, we use a dummy thread here since the main
23 // thread already exists.
24 BrowserThreadImpl(BrowserThread::ID identifier,
25 base::MessageLoop* message_loop);
26 ~BrowserThreadImpl() override;
28 bool StartWithOptions(const Options& options);
30 static void ShutdownThreadPool();
32 protected:
33 void Init() override;
34 void Run(base::MessageLoop* message_loop) override;
35 void CleanUp() override;
37 private:
38 // We implement all the functionality of the public BrowserThread
39 // functions, but state is stored in the BrowserThreadImpl to keep
40 // the API cleaner. Therefore make BrowserThread a friend class.
41 friend class BrowserThread;
43 // The following are unique function names that makes it possible to tell
44 // the thread id from the callstack alone in crash dumps.
45 void UIThreadRun(base::MessageLoop* message_loop);
46 void DBThreadRun(base::MessageLoop* message_loop);
47 void FileThreadRun(base::MessageLoop* message_loop);
48 void FileUserBlockingThreadRun(base::MessageLoop* message_loop);
49 void ProcessLauncherThreadRun(base::MessageLoop* message_loop);
50 void CacheThreadRun(base::MessageLoop* message_loop);
51 void IOThreadRun(base::MessageLoop* message_loop);
53 static bool PostTaskHelper(
54 BrowserThread::ID identifier,
55 const tracked_objects::Location& from_here,
56 const base::Closure& task,
57 base::TimeDelta delay,
58 bool nestable);
60 // Common initialization code for the constructors.
61 void Initialize();
63 // For testing.
64 friend class ContentTestSuiteBaseListener;
65 friend class TestBrowserThreadBundle;
66 static void FlushThreadPoolHelperForTesting();
68 // The identifier of this thread. Only one thread can exist with a given
69 // identifier at a given time.
70 ID identifier_;
73 } // namespace content
75 #endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_