| 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/shell/shell.mojom.h" | 19 #include "mojo/public/interfaces/service_provider/service_provider.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 : public IPC::Listener, | 59 class CONTENT_EXPORT ChildThread |
| 60 public IPC::Sender, | 60 : public IPC::Listener, |
| 61 public NON_EXPORTED_BASE(mojo::ShellClient) { | 61 public IPC::Sender, |
| 62 public NON_EXPORTED_BASE(mojo::ServiceProvider) { |
| 62 public: | 63 public: |
| 63 // Creates the thread. | 64 // Creates the thread. |
| 64 ChildThread(); | 65 ChildThread(); |
| 65 // Used for single-process mode and for in process gpu mode. | 66 // Used for single-process mode and for in process gpu mode. |
| 66 explicit ChildThread(const std::string& channel_name); | 67 explicit ChildThread(const std::string& channel_name); |
| 67 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 68 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
| 68 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 69 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
| 69 // must be terminated before Shutdown returns. In particular, if a subsystem | 70 // must be terminated before Shutdown returns. In particular, if a subsystem |
| 70 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 71 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
| 71 // should be joined in Shutdown(). | 72 // should be joined in Shutdown(). |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void set_on_channel_error_called(bool on_channel_error_called) { | 164 void set_on_channel_error_called(bool on_channel_error_called) { |
| 164 on_channel_error_called_ = on_channel_error_called; | 165 on_channel_error_called_ = on_channel_error_called; |
| 165 } | 166 } |
| 166 | 167 |
| 167 // IPC::Listener implementation: | 168 // IPC::Listener implementation: |
| 168 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 169 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 169 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 170 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 170 virtual void OnChannelError() OVERRIDE; | 171 virtual void OnChannelError() OVERRIDE; |
| 171 | 172 |
| 172 // mojo::ShellClient implementation: | 173 // mojo::ShellClient implementation: |
| 173 virtual void AcceptConnection( | 174 virtual void ConnectToService( |
| 174 const mojo::String& service_name, | 175 const mojo::String& service_name, |
| 175 mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; | 176 mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; |
| 176 | 177 |
| 177 private: | 178 private: |
| 178 class ChildThreadMessageRouter : public MessageRouter { | 179 class ChildThreadMessageRouter : public MessageRouter { |
| 179 public: | 180 public: |
| 180 // |sender| must outlive this object. | 181 // |sender| must outlive this object. |
| 181 explicit ChildThreadMessageRouter(IPC::Sender* sender); | 182 explicit ChildThreadMessageRouter(IPC::Sender* sender); |
| 182 virtual bool Send(IPC::Message* msg) OVERRIDE; | 183 virtual bool Send(IPC::Message* msg) OVERRIDE; |
| 183 | 184 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 scoped_ptr<base::PowerMonitor> power_monitor_; | 254 scoped_ptr<base::PowerMonitor> power_monitor_; |
| 254 | 255 |
| 255 bool in_browser_process_; | 256 bool in_browser_process_; |
| 256 | 257 |
| 257 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 258 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
| 258 }; | 259 }; |
| 259 | 260 |
| 260 } // namespace content | 261 } // namespace content |
| 261 | 262 |
| 262 #endif // CONTENT_CHILD_CHILD_THREAD_H_ | 263 #endif // CONTENT_CHILD_CHILD_THREAD_H_ |
| OLD | NEW |