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_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_piece.h" | |
Alexei Svitkine (slow)
2016/08/19 16:31:56
Nit: Not needed anymore.
bcwhite
2016/08/19 17:19:46
Done.
| |
18 #include "base/synchronization/waitable_event_watcher.h" | 19 #include "base/synchronization/waitable_event_watcher.h" |
19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
20 #include "content/browser/child_process_launcher.h" | 21 #include "content/browser/child_process_launcher.h" |
21 #include "content/browser/power_monitor_message_broadcaster.h" | 22 #include "content/browser/power_monitor_message_broadcaster.h" |
22 #include "content/public/browser/browser_child_process_host.h" | 23 #include "content/public/browser/browser_child_process_host.h" |
23 #include "content/public/browser/child_process_data.h" | 24 #include "content/public/browser/child_process_data.h" |
24 #include "content/public/common/child_process_host_delegate.h" | 25 #include "content/public/common/child_process_host_delegate.h" |
25 | 26 |
26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
27 #include "base/win/object_watcher.h" | 28 #include "base/win/object_watcher.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 69 |
69 // BrowserChildProcessHost implementation: | 70 // BrowserChildProcessHost implementation: |
70 bool Send(IPC::Message* message) override; | 71 bool Send(IPC::Message* message) override; |
71 void Launch(SandboxedProcessLauncherDelegate* delegate, | 72 void Launch(SandboxedProcessLauncherDelegate* delegate, |
72 base::CommandLine* cmd_line, | 73 base::CommandLine* cmd_line, |
73 bool terminate_on_shutdown) override; | 74 bool terminate_on_shutdown) override; |
74 const ChildProcessData& GetData() const override; | 75 const ChildProcessData& GetData() const override; |
75 ChildProcessHost* GetHost() const override; | 76 ChildProcessHost* GetHost() const override; |
76 base::TerminationStatus GetTerminationStatus(bool known_dead, | 77 base::TerminationStatus GetTerminationStatus(bool known_dead, |
77 int* exit_code) override; | 78 int* exit_code) override; |
79 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() | |
80 override; | |
78 void SetName(const base::string16& name) override; | 81 void SetName(const base::string16& name) override; |
79 void SetHandle(base::ProcessHandle handle) override; | 82 void SetHandle(base::ProcessHandle handle) override; |
80 shell::InterfaceProvider* GetRemoteInterfaces() override; | 83 shell::InterfaceProvider* GetRemoteInterfaces() override; |
81 | 84 |
82 // ChildProcessHostDelegate implementation: | 85 // ChildProcessHostDelegate implementation: |
83 bool CanShutdown() override; | 86 bool CanShutdown() override; |
84 void OnChildDisconnected() override; | 87 void OnChildDisconnected() override; |
85 const base::Process& GetProcess() const override; | 88 const base::Process& GetProcess() const override; |
86 bool OnMessageReceived(const IPC::Message& message) override; | 89 bool OnMessageReceived(const IPC::Message& message) override; |
87 void OnChannelConnected(int32_t peer_pid) override; | 90 void OnChannelConnected(int32_t peer_pid) override; |
(...skipping 20 matching lines...) Expand all Loading... | |
108 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; | 111 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; |
109 private: | 112 private: |
110 friend class BrowserChildProcessHostIterator; | 113 friend class BrowserChildProcessHostIterator; |
111 friend class BrowserChildProcessObserver; | 114 friend class BrowserChildProcessObserver; |
112 | 115 |
113 static BrowserChildProcessList* GetIterator(); | 116 static BrowserChildProcessList* GetIterator(); |
114 | 117 |
115 static void AddObserver(BrowserChildProcessObserver* observer); | 118 static void AddObserver(BrowserChildProcessObserver* observer); |
116 static void RemoveObserver(BrowserChildProcessObserver* observer); | 119 static void RemoveObserver(BrowserChildProcessObserver* observer); |
117 | 120 |
121 // Creates the |metrics_allocator_|. | |
122 void CreateMetricsAllocator(); | |
123 | |
124 // Passes the |metrics_allocator_|, if any, to the managed process. This | |
125 // requires the process to have been launched and the RPC channel to be | |
126 // available. | |
127 void ShareMetricsAllocatorToProcess(); | |
128 | |
118 // ChildProcessLauncher::Client implementation. | 129 // ChildProcessLauncher::Client implementation. |
119 void OnProcessLaunched() override; | 130 void OnProcessLaunched() override; |
120 void OnProcessLaunchFailed(int error_code) override; | 131 void OnProcessLaunchFailed(int error_code) override; |
121 | 132 |
122 // Returns true if the process has successfully launched. Must only be called | 133 // Returns true if the process has successfully launched. Must only be called |
123 // on the IO thread. | 134 // on the IO thread. |
124 bool IsProcessLaunched() const; | 135 bool IsProcessLaunched() const; |
125 | 136 |
126 static void OnMojoError( | 137 static void OnMojoError( |
127 base::WeakPtr<BrowserChildProcessHostImpl> process, | 138 base::WeakPtr<BrowserChildProcessHostImpl> process, |
(...skipping 14 matching lines...) Expand all Loading... | |
142 | 153 |
143 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; | 154 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; |
144 | 155 |
145 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
146 // Watches to see if the child process exits before the IPC channel has | 157 // Watches to see if the child process exits before the IPC channel has |
147 // been connected. Thereafter, its exit is determined by an error on the | 158 // been connected. Thereafter, its exit is determined by an error on the |
148 // IPC channel. | 159 // IPC channel. |
149 base::win::ObjectWatcher early_exit_watcher_; | 160 base::win::ObjectWatcher early_exit_watcher_; |
150 #endif | 161 #endif |
151 | 162 |
163 // The memory allocator, if any, in which the process will write its metrics. | |
164 std::unique_ptr<base::SharedPersistentMemoryAllocator> metrics_allocator_; | |
165 | |
152 bool is_channel_connected_; | 166 bool is_channel_connected_; |
153 bool notify_child_disconnected_; | 167 bool notify_child_disconnected_; |
154 | 168 |
155 base::WeakPtrFactory<BrowserChildProcessHostImpl> weak_factory_; | 169 base::WeakPtrFactory<BrowserChildProcessHostImpl> weak_factory_; |
156 }; | 170 }; |
157 | 171 |
158 } // namespace content | 172 } // namespace content |
159 | 173 |
160 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 174 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
OLD | NEW |