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_THREAD_H_ | 5 #ifndef CONTENT_CHILD_CHILD_THREAD_H_ |
6 #define CONTENT_CHILD_CHILD_THREAD_H_ | 6 #define CONTENT_CHILD_CHILD_THREAD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/power_monitor/power_monitor.h" | 14 #include "base/power_monitor/power_monitor.h" |
15 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/common/message_router.h" | 17 #include "content/common/message_router.h" |
18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
19 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 19 #include "mojo/public/interfaces/shell/shell.mojom.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class MessageLoop; | 22 class MessageLoop; |
23 | 23 |
24 namespace debug { | 24 namespace debug { |
25 class TraceMemoryController; | 25 class TraceMemoryController; |
26 } // namespace debug | 26 } // namespace debug |
27 } // namespace base | 27 } // namespace base |
28 | 28 |
29 namespace IPC { | 29 namespace IPC { |
(...skipping 19 matching lines...) Expand all Loading... |
49 class ServiceWorkerMessageFilter; | 49 class ServiceWorkerMessageFilter; |
50 class QuotaDispatcher; | 50 class QuotaDispatcher; |
51 class QuotaMessageFilter; | 51 class QuotaMessageFilter; |
52 class ResourceDispatcher; | 52 class ResourceDispatcher; |
53 class SocketStreamDispatcher; | 53 class SocketStreamDispatcher; |
54 class ThreadSafeSender; | 54 class ThreadSafeSender; |
55 class WebSocketDispatcher; | 55 class WebSocketDispatcher; |
56 struct RequestInfo; | 56 struct RequestInfo; |
57 | 57 |
58 // The main thread of a child process derives from this class. | 58 // The main thread of a child process derives from this class. |
59 class CONTENT_EXPORT ChildThread | 59 class CONTENT_EXPORT ChildThread : public IPC::Listener, |
60 : public IPC::Listener, | 60 public IPC::Sender, |
61 public IPC::Sender, | 61 public NON_EXPORTED_BASE(mojo::ShellClient) { |
62 public NON_EXPORTED_BASE(mojo::ServiceProvider) { | |
63 public: | 62 public: |
64 // Creates the thread. | 63 // Creates the thread. |
65 ChildThread(); | 64 ChildThread(); |
66 // Used for single-process mode and for in process gpu mode. | 65 // Used for single-process mode and for in process gpu mode. |
67 explicit ChildThread(const std::string& channel_name); | 66 explicit ChildThread(const std::string& channel_name); |
68 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 67 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
69 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 68 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
70 // must be terminated before Shutdown returns. In particular, if a subsystem | 69 // must be terminated before Shutdown returns. In particular, if a subsystem |
71 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 70 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
72 // should be joined in Shutdown(). | 71 // should be joined in Shutdown(). |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void set_on_channel_error_called(bool on_channel_error_called) { | 163 void set_on_channel_error_called(bool on_channel_error_called) { |
165 on_channel_error_called_ = on_channel_error_called; | 164 on_channel_error_called_ = on_channel_error_called; |
166 } | 165 } |
167 | 166 |
168 // IPC::Listener implementation: | 167 // IPC::Listener implementation: |
169 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 168 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
170 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 169 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
171 virtual void OnChannelError() OVERRIDE; | 170 virtual void OnChannelError() OVERRIDE; |
172 | 171 |
173 // mojo::ShellClient implementation: | 172 // mojo::ShellClient implementation: |
174 virtual void ConnectToService( | 173 virtual void AcceptConnection( |
175 const mojo::String& service_name, | 174 const mojo::String& service_name, |
176 mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; | 175 mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; |
177 | 176 |
178 private: | 177 private: |
179 class ChildThreadMessageRouter : public MessageRouter { | 178 class ChildThreadMessageRouter : public MessageRouter { |
180 public: | 179 public: |
181 // |sender| must outlive this object. | 180 // |sender| must outlive this object. |
182 explicit ChildThreadMessageRouter(IPC::Sender* sender); | 181 explicit ChildThreadMessageRouter(IPC::Sender* sender); |
183 virtual bool Send(IPC::Message* msg) OVERRIDE; | 182 virtual bool Send(IPC::Message* msg) OVERRIDE; |
184 | 183 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 scoped_ptr<base::PowerMonitor> power_monitor_; | 253 scoped_ptr<base::PowerMonitor> power_monitor_; |
255 | 254 |
256 bool in_browser_process_; | 255 bool in_browser_process_; |
257 | 256 |
258 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 257 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
259 }; | 258 }; |
260 | 259 |
261 } // namespace content | 260 } // namespace content |
262 | 261 |
263 #endif // CONTENT_CHILD_CHILD_THREAD_H_ | 262 #endif // CONTENT_CHILD_CHILD_THREAD_H_ |
OLD | NEW |