| 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_IMPL_H_ | 5 #ifndef CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class ResourceDispatcher; | 54 class ResourceDispatcher; |
| 55 class ThreadSafeSender; | 55 class ThreadSafeSender; |
| 56 class WebSocketDispatcher; | 56 class WebSocketDispatcher; |
| 57 struct RequestInfo; | 57 struct RequestInfo; |
| 58 | 58 |
| 59 // The main thread of a child process derives from this class. | 59 // The main thread of a child process derives from this class. |
| 60 class CONTENT_EXPORT ChildThreadImpl | 60 class CONTENT_EXPORT ChildThreadImpl |
| 61 : public IPC::Listener, | 61 : public IPC::Listener, |
| 62 virtual public ChildThread { | 62 virtual public ChildThread { |
| 63 public: | 63 public: |
| 64 struct CONTENT_EXPORT Options { | 64 struct CONTENT_EXPORT Options; |
| 65 Options(); | |
| 66 explicit Options(bool mojo); | |
| 67 Options(std::string name, bool mojo); | |
| 68 ~Options(); | |
| 69 | |
| 70 std::string channel_name; | |
| 71 bool use_mojo_channel; | |
| 72 bool in_browser_process; | |
| 73 std::vector<IPC::MessageFilter*> startup_filters; | |
| 74 }; | |
| 75 | 65 |
| 76 // Creates the thread. | 66 // Creates the thread. |
| 77 ChildThreadImpl(); | 67 ChildThreadImpl(); |
| 78 // Allow to be used for single-process mode and for in process gpu mode via | 68 // Allow to be used for single-process mode and for in process gpu mode via |
| 79 // options. | 69 // options. |
| 80 explicit ChildThreadImpl(const Options& options); | 70 explicit ChildThreadImpl(const Options& options); |
| 81 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 71 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
| 82 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 72 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
| 83 // must be terminated before Shutdown returns. In particular, if a subsystem | 73 // must be terminated before Shutdown returns. In particular, if a subsystem |
| 84 // has a thread that post tasks to ChildProcess::main_thread(), that thread | 74 // has a thread that post tasks to ChildProcess::main_thread(), that thread |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 288 |
| 299 scoped_refptr<NavigatorConnectDispatcher> navigator_connect_dispatcher_; | 289 scoped_refptr<NavigatorConnectDispatcher> navigator_connect_dispatcher_; |
| 300 | 290 |
| 301 bool in_browser_process_; | 291 bool in_browser_process_; |
| 302 | 292 |
| 303 base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_; | 293 base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_; |
| 304 | 294 |
| 305 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); | 295 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); |
| 306 }; | 296 }; |
| 307 | 297 |
| 298 struct ChildThreadImpl::Options { |
| 299 ~Options(); |
| 300 |
| 301 class Builder; |
| 302 |
| 303 std::string channel_name; |
| 304 bool use_mojo_channel; |
| 305 bool in_browser_process; |
| 306 std::vector<IPC::MessageFilter*> startup_filters; |
| 307 |
| 308 private: |
| 309 Options(); |
| 310 }; |
| 311 |
| 312 class ChildThreadImpl::Options::Builder { |
| 313 public: |
| 314 Builder(); |
| 315 |
| 316 Builder& InBrowserProcess(bool in_browser_process); |
| 317 Builder& UseMojoChannel(bool use_mojo_channel); |
| 318 Builder& WithChannelName(const std::string& channel_name); |
| 319 Builder& AddStartupFilter(IPC::MessageFilter* filter); |
| 320 |
| 321 Options Build(); |
| 322 |
| 323 private: |
| 324 struct Options options_; |
| 325 |
| 326 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 327 }; |
| 328 |
| 308 } // namespace content | 329 } // namespace content |
| 309 | 330 |
| 310 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 331 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
| OLD | NEW |