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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/power_monitor/power_monitor.h" | 17 #include "base/power_monitor/power_monitor.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 #include "base/tracked_objects.h" | 19 #include "base/tracked_objects.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "content/common/associated_interfaces.mojom.h" |
21 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
22 #include "content/public/child/child_thread.h" | 23 #include "content/public/child/child_thread.h" |
23 #include "ipc/ipc.mojom.h" | 24 #include "ipc/ipc.mojom.h" |
24 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 25 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
25 #include "ipc/ipc_platform_file.h" | 26 #include "ipc/ipc_platform_file.h" |
26 #include "ipc/message_router.h" | 27 #include "ipc/message_router.h" |
| 28 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 29 #include "mojo/public/cpp/bindings/associated_binding_set.h" |
27 | 30 |
28 namespace base { | 31 namespace base { |
29 class MessageLoop; | 32 class MessageLoop; |
30 } // namespace base | 33 } // namespace base |
31 | 34 |
32 namespace IPC { | 35 namespace IPC { |
33 class MessageFilter; | 36 class MessageFilter; |
34 class SyncChannel; | 37 class SyncChannel; |
35 class SyncMessageFilter; | 38 class SyncMessageFilter; |
36 } // namespace IPC | 39 } // namespace IPC |
(...skipping 26 matching lines...) Expand all Loading... |
63 class ServiceWorkerMessageFilter; | 66 class ServiceWorkerMessageFilter; |
64 class QuotaDispatcher; | 67 class QuotaDispatcher; |
65 class QuotaMessageFilter; | 68 class QuotaMessageFilter; |
66 class ResourceDispatcher; | 69 class ResourceDispatcher; |
67 class ThreadSafeSender; | 70 class ThreadSafeSender; |
68 struct RequestInfo; | 71 struct RequestInfo; |
69 | 72 |
70 // The main thread of a child process derives from this class. | 73 // The main thread of a child process derives from this class. |
71 class CONTENT_EXPORT ChildThreadImpl | 74 class CONTENT_EXPORT ChildThreadImpl |
72 : public IPC::Listener, | 75 : public IPC::Listener, |
73 virtual public ChildThread { | 76 virtual public ChildThread, |
| 77 NON_EXPORTED_BASE(public mojom::RouteProvider), |
| 78 NON_EXPORTED_BASE(public mojom::AssociatedInterfaceProvider) { |
74 public: | 79 public: |
75 struct CONTENT_EXPORT Options; | 80 struct CONTENT_EXPORT Options; |
76 | 81 |
77 // Creates the thread. | 82 // Creates the thread. |
78 ChildThreadImpl(); | 83 ChildThreadImpl(); |
79 // Allow to be used for single-process mode and for in process gpu mode via | 84 // Allow to be used for single-process mode and for in process gpu mode via |
80 // options. | 85 // options. |
81 explicit ChildThreadImpl(const Options& options); | 86 explicit ChildThreadImpl(const Options& options); |
82 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 87 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
83 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 88 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
(...skipping 15 matching lines...) Expand all Loading... |
99 void RecordAction(const base::UserMetricsAction& action) override; | 104 void RecordAction(const base::UserMetricsAction& action) override; |
100 void RecordComputedAction(const std::string& action) override; | 105 void RecordComputedAction(const std::string& action) override; |
101 MojoShellConnection* GetMojoShellConnection() override; | 106 MojoShellConnection* GetMojoShellConnection() override; |
102 shell::InterfaceRegistry* GetInterfaceRegistry() override; | 107 shell::InterfaceRegistry* GetInterfaceRegistry() override; |
103 shell::InterfaceProvider* GetRemoteInterfaces() override; | 108 shell::InterfaceProvider* GetRemoteInterfaces() override; |
104 | 109 |
105 IPC::SyncChannel* channel() { return channel_.get(); } | 110 IPC::SyncChannel* channel() { return channel_.get(); } |
106 | 111 |
107 IPC::MessageRouter* GetRouter(); | 112 IPC::MessageRouter* GetRouter(); |
108 | 113 |
| 114 mojom::RouteProvider* GetRemoteRouteProvider(); |
| 115 |
109 // Allocates a block of shared memory of the given size. Returns NULL on | 116 // Allocates a block of shared memory of the given size. Returns NULL on |
110 // failure. | 117 // failure. |
111 // Note: On posix, this requires a sync IPC to the browser process, | 118 // Note: On posix, this requires a sync IPC to the browser process, |
112 // but on windows the child process directly allocates the block. | 119 // but on windows the child process directly allocates the block. |
113 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); | 120 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); |
114 | 121 |
115 // A static variant that can be called on background threads provided | 122 // A static variant that can be called on background threads provided |
116 // the |sender| passed in is safe to use on background threads. | 123 // the |sender| passed in is safe to use on background threads. |
117 // |out_of_memory| is an output variable populated on failure which tells the | 124 // |out_of_memory| is an output variable populated on failure which tells the |
118 // caller whether the failure was caused by an out of memory error. | 125 // caller whether the failure was caused by an out of memory error. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void OnShutdown(); | 246 void OnShutdown(); |
240 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); | 247 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); |
241 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); | 248 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); |
242 void OnProfilingPhaseCompleted(int profiling_phase); | 249 void OnProfilingPhaseCompleted(int profiling_phase); |
243 #ifdef IPC_MESSAGE_LOG_ENABLED | 250 #ifdef IPC_MESSAGE_LOG_ENABLED |
244 void OnSetIPCLoggingEnabled(bool enable); | 251 void OnSetIPCLoggingEnabled(bool enable); |
245 #endif | 252 #endif |
246 | 253 |
247 void EnsureConnected(); | 254 void EnsureConnected(); |
248 | 255 |
| 256 void OnRouteProviderRequest(mojom::RouteProviderAssociatedRequest request); |
| 257 |
| 258 // mojom::RouteProvider: |
| 259 void GetRoute( |
| 260 int32_t routing_id, |
| 261 mojom::AssociatedInterfaceProviderAssociatedRequest request) override; |
| 262 |
| 263 // mojom::AssociatedInterfaceProvider: |
| 264 void GetAssociatedInterface( |
| 265 const std::string& name, |
| 266 mojom::AssociatedInterfaceAssociatedRequest request) override; |
| 267 |
249 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; | 268 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; |
250 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; | 269 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; |
251 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; | 270 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; |
252 std::unique_ptr<MojoShellConnection> mojo_shell_connection_; | 271 std::unique_ptr<MojoShellConnection> mojo_shell_connection_; |
253 std::unique_ptr<shell::Connection> browser_connection_; | 272 std::unique_ptr<shell::Connection> browser_connection_; |
254 | 273 |
| 274 mojo::AssociatedBinding<mojom::RouteProvider> route_provider_binding_; |
| 275 mojo::AssociatedBindingSet<mojom::AssociatedInterfaceProvider> |
| 276 associated_interface_provider_bindings_; |
| 277 mojom::RouteProviderAssociatedPtr remote_route_provider_; |
| 278 |
255 std::string channel_name_; | 279 std::string channel_name_; |
256 std::unique_ptr<IPC::SyncChannel> channel_; | 280 std::unique_ptr<IPC::SyncChannel> channel_; |
257 | 281 |
258 // Allows threads other than the main thread to send sync messages. | 282 // Allows threads other than the main thread to send sync messages. |
259 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; | 283 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; |
260 | 284 |
261 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 285 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
262 | 286 |
263 // Implements message routing functionality to the consumers of | 287 // Implements message routing functionality to the consumers of |
264 // ChildThreadImpl. | 288 // ChildThreadImpl. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 365 |
342 private: | 366 private: |
343 struct Options options_; | 367 struct Options options_; |
344 | 368 |
345 DISALLOW_COPY_AND_ASSIGN(Builder); | 369 DISALLOW_COPY_AND_ASSIGN(Builder); |
346 }; | 370 }; |
347 | 371 |
348 } // namespace content | 372 } // namespace content |
349 | 373 |
350 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 374 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
OLD | NEW |