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" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class QuotaMessageFilter; | 46 class QuotaMessageFilter; |
47 class ResourceDispatcher; | 47 class ResourceDispatcher; |
48 class SocketStreamDispatcher; | 48 class SocketStreamDispatcher; |
49 class ThreadSafeSender; | 49 class ThreadSafeSender; |
50 class WebSocketDispatcher; | 50 class WebSocketDispatcher; |
51 struct RequestInfo; | 51 struct RequestInfo; |
52 | 52 |
53 // The main thread of a child process derives from this class. | 53 // The main thread of a child process derives from this class. |
54 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { | 54 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { |
55 public: | 55 public: |
| 56 struct CONTENT_EXPORT Options { |
| 57 Options(); |
| 58 explicit Options(bool mojo); |
| 59 Options(std::string name, bool mojo) |
| 60 : channel_name(name), use_mojo_channel(mojo) {} |
| 61 |
| 62 std::string channel_name; |
| 63 bool use_mojo_channel; |
| 64 }; |
| 65 |
56 // Creates the thread. | 66 // Creates the thread. |
57 ChildThread(); | 67 ChildThread(); |
58 // Used for single-process mode and for in process gpu mode. | 68 // Used for single-process mode and for in process gpu mode. |
59 explicit ChildThread(const std::string& channel_name); | 69 explicit ChildThread(const Options& options); |
60 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 70 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
61 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 71 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
62 // must be terminated before Shutdown returns. In particular, if a subsystem | 72 // must be terminated before Shutdown returns. In particular, if a subsystem |
63 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 73 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
64 // should be joined in Shutdown(). | 74 // should be joined in Shutdown(). |
65 virtual ~ChildThread(); | 75 virtual ~ChildThread(); |
66 virtual void Shutdown(); | 76 virtual void Shutdown(); |
67 | 77 |
68 // IPC::Sender implementation: | 78 // IPC::Sender implementation: |
69 virtual bool Send(IPC::Message* msg) OVERRIDE; | 79 virtual bool Send(IPC::Message* msg) OVERRIDE; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 class ChildThreadMessageRouter : public MessageRouter { | 176 class ChildThreadMessageRouter : public MessageRouter { |
167 public: | 177 public: |
168 // |sender| must outlive this object. | 178 // |sender| must outlive this object. |
169 explicit ChildThreadMessageRouter(IPC::Sender* sender); | 179 explicit ChildThreadMessageRouter(IPC::Sender* sender); |
170 virtual bool Send(IPC::Message* msg) OVERRIDE; | 180 virtual bool Send(IPC::Message* msg) OVERRIDE; |
171 | 181 |
172 private: | 182 private: |
173 IPC::Sender* const sender_; | 183 IPC::Sender* const sender_; |
174 }; | 184 }; |
175 | 185 |
176 void Init(); | 186 void Init(const Options& options); |
| 187 scoped_ptr<IPC::SyncChannel> CreateChannel(bool use_mojo_channel); |
177 | 188 |
178 // IPC message handlers. | 189 // IPC message handlers. |
179 void OnShutdown(); | 190 void OnShutdown(); |
180 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); | 191 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); |
181 void OnGetChildProfilerData(int sequence_number); | 192 void OnGetChildProfilerData(int sequence_number); |
182 void OnDumpHandles(); | 193 void OnDumpHandles(); |
183 #ifdef IPC_MESSAGE_LOG_ENABLED | 194 #ifdef IPC_MESSAGE_LOG_ENABLED |
184 void OnSetIPCLoggingEnabled(bool enable); | 195 void OnSetIPCLoggingEnabled(bool enable); |
185 #endif | 196 #endif |
186 #if defined(USE_TCMALLOC) | 197 #if defined(USE_TCMALLOC) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 scoped_ptr<base::PowerMonitor> power_monitor_; | 253 scoped_ptr<base::PowerMonitor> power_monitor_; |
243 | 254 |
244 bool in_browser_process_; | 255 bool in_browser_process_; |
245 | 256 |
246 DISALLOW_COPY_AND_ASSIGN(ChildThread); | 257 DISALLOW_COPY_AND_ASSIGN(ChildThread); |
247 }; | 258 }; |
248 | 259 |
249 } // namespace content | 260 } // namespace content |
250 | 261 |
251 #endif // CONTENT_CHILD_CHILD_THREAD_H_ | 262 #endif // CONTENT_CHILD_CHILD_THREAD_H_ |
OLD | NEW |