OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_CHILD_PROCESS_H_ | 5 #ifndef CONTENT_CHILD_CHILD_PROCESS_H_ |
6 #define CONTENT_CHILD_CHILD_PROCESS_H_ | 6 #define CONTENT_CHILD_CHILD_PROCESS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/task_scheduler/scheduler_worker_pool_params.h" | |
14 #include "base/task_scheduler/task_scheduler.h" | 13 #include "base/task_scheduler/task_scheduler.h" |
15 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
16 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
17 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
18 | 17 |
| 18 namespace base { |
| 19 struct TaskSchedulerInitParams; |
| 20 } |
| 21 |
19 namespace content { | 22 namespace content { |
20 class ChildThreadImpl; | 23 class ChildThreadImpl; |
21 | 24 |
22 // Base class for child processes of the browser process (i.e. renderer and | 25 // Base class for child processes of the browser process (i.e. renderer and |
23 // plugin host). This is a singleton object for each child process. | 26 // plugin host). This is a singleton object for each child process. |
24 // | 27 // |
25 // During process shutdown the following sequence of actions happens in | 28 // During process shutdown the following sequence of actions happens in |
26 // order. | 29 // order. |
27 // | 30 // |
28 // 1. ChildProcess::~ChildProcess() is called. | 31 // 1. ChildProcess::~ChildProcess() is called. |
29 // 2. Shutdown event is fired. Background threads should stop. | 32 // 2. Shutdown event is fired. Background threads should stop. |
30 // 3. ChildThreadImpl::Shutdown() is called. ChildThread is also deleted. | 33 // 3. ChildThreadImpl::Shutdown() is called. ChildThread is also deleted. |
31 // 4. IO thread is stopped. | 34 // 4. IO thread is stopped. |
32 // 5. Main message loop exits. | 35 // 5. Main message loop exits. |
33 // 6. Child process is now fully stopped. | 36 // 6. Child process is now fully stopped. |
34 // | 37 // |
35 // Note: IO thread outlives the ChildThreadImpl object. | 38 // Note: IO thread outlives the ChildThreadImpl object. |
36 class CONTENT_EXPORT ChildProcess { | 39 class CONTENT_EXPORT ChildProcess { |
37 public: | 40 public: |
38 // Child processes should have an object that derives from this class. | 41 // Child processes should have an object that derives from this class. |
39 // Normally you would immediately call set_main_thread after construction. | 42 // Normally you would immediately call set_main_thread after construction. |
40 // |io_thread_priority| is the priority of the IO thread. |worker_pool_params| | 43 // |io_thread_priority| is the priority of the IO thread. |
41 // and |worker_pool_index_for_traits_callback| are used to initialize | 44 // |task_scheduler_name| and |task_scheduler_init_params| are used to |
42 // TaskScheduler. TaskScheduler is initialized with default values if these | 45 // initialize TaskScheduler. Default params are used if |
43 // arguments are left empty. | 46 // |task_scheduler_init_params| is nullptr. |
44 ChildProcess( | 47 ChildProcess( |
45 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL, | 48 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL, |
46 const std::vector<base::SchedulerWorkerPoolParams>& worker_pool_params = | 49 const std::string& task_scheduler_name = "ContentChild", |
47 std::vector<base::SchedulerWorkerPoolParams>(), | 50 std::unique_ptr<base::TaskSchedulerInitParams> |
48 base::TaskScheduler::WorkerPoolIndexForTraitsCallback | 51 task_scheduler_init_params = nullptr); |
49 worker_pool_index_for_traits_callback = | |
50 base::TaskScheduler::WorkerPoolIndexForTraitsCallback()); | |
51 virtual ~ChildProcess(); | 52 virtual ~ChildProcess(); |
52 | 53 |
53 // May be NULL if the main thread hasn't been set explicitly. | 54 // May be NULL if the main thread hasn't been set explicitly. |
54 ChildThreadImpl* main_thread(); | 55 ChildThreadImpl* main_thread(); |
55 | 56 |
56 // Sets the object associated with the main thread of this process. | 57 // Sets the object associated with the main thread of this process. |
57 // Takes ownership of the pointer. | 58 // Takes ownership of the pointer. |
58 void set_main_thread(ChildThreadImpl* thread); | 59 void set_main_thread(ChildThreadImpl* thread); |
59 | 60 |
60 base::MessageLoop* io_message_loop() { return io_thread_.message_loop(); } | 61 base::MessageLoop* io_message_loop() { return io_thread_.message_loop(); } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 109 |
109 // Whether this ChildProcess initialized TaskScheduler. | 110 // Whether this ChildProcess initialized TaskScheduler. |
110 bool initialized_task_scheduler_ = false; | 111 bool initialized_task_scheduler_ = false; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(ChildProcess); | 113 DISALLOW_COPY_AND_ASSIGN(ChildProcess); |
113 }; | 114 }; |
114 | 115 |
115 } // namespace content | 116 } // namespace content |
116 | 117 |
117 #endif // CONTENT_CHILD_CHILD_PROCESS_H_ | 118 #endif // CONTENT_CHILD_CHILD_PROCESS_H_ |
OLD | NEW |