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