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