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/content_export.h" | 21 #include "content/common/content_export.h" |
22 #include "content/public/child/child_thread.h" | 22 #include "content/public/child/child_thread.h" |
23 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. | 23 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. |
24 #include "ipc/ipc_platform_file.h" | 24 #include "ipc/ipc_platform_file.h" |
25 #include "ipc/message_router.h" | 25 #include "ipc/message_router.h" |
26 #include "services/shell/public/cpp/shell_client.h" | |
27 | 26 |
28 namespace base { | 27 namespace base { |
29 class MessageLoop; | 28 class MessageLoop; |
30 } // namespace base | 29 } // namespace base |
31 | 30 |
32 namespace IPC { | 31 namespace IPC { |
33 class MessageFilter; | 32 class MessageFilter; |
34 class SyncChannel; | 33 class SyncChannel; |
35 class SyncMessageFilter; | 34 class SyncMessageFilter; |
36 } // namespace IPC | 35 } // namespace IPC |
(...skipping 24 matching lines...) Expand all Loading... |
61 class QuotaMessageFilter; | 60 class QuotaMessageFilter; |
62 class ResourceDispatcher; | 61 class ResourceDispatcher; |
63 class ThreadSafeSender; | 62 class ThreadSafeSender; |
64 class WebSocketDispatcher; | 63 class WebSocketDispatcher; |
65 class WebSocketMessageFilter; | 64 class WebSocketMessageFilter; |
66 struct RequestInfo; | 65 struct RequestInfo; |
67 | 66 |
68 // The main thread of a child process derives from this class. | 67 // The main thread of a child process derives from this class. |
69 class CONTENT_EXPORT ChildThreadImpl | 68 class CONTENT_EXPORT ChildThreadImpl |
70 : public IPC::Listener, | 69 : public IPC::Listener, |
71 virtual public ChildThread, | 70 virtual public ChildThread { |
72 public NON_EXPORTED_BASE(shell::ShellClient){ | |
73 public: | 71 public: |
74 struct CONTENT_EXPORT Options; | 72 struct CONTENT_EXPORT Options; |
75 | 73 |
76 // Creates the thread. | 74 // Creates the thread. |
77 ChildThreadImpl(); | 75 ChildThreadImpl(); |
78 // Allow to be used for single-process mode and for in process gpu mode via | 76 // Allow to be used for single-process mode and for in process gpu mode via |
79 // options. | 77 // options. |
80 explicit ChildThreadImpl(const Options& options); | 78 explicit ChildThreadImpl(const Options& options); |
81 // ChildProcess::main_thread() is reset after Shutdown(), and before the | 79 // ChildProcess::main_thread() is reset after Shutdown(), and before the |
82 // destructor, so any subsystem that relies on ChildProcess::main_thread() | 80 // destructor, so any subsystem that relies on ChildProcess::main_thread() |
(...skipping 11 matching lines...) Expand all Loading... |
94 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
95 void PreCacheFont(const LOGFONT& log_font) override; | 93 void PreCacheFont(const LOGFONT& log_font) override; |
96 void ReleaseCachedFonts() override; | 94 void ReleaseCachedFonts() override; |
97 #endif | 95 #endif |
98 void RecordAction(const base::UserMetricsAction& action) override; | 96 void RecordAction(const base::UserMetricsAction& action) override; |
99 void RecordComputedAction(const std::string& action) override; | 97 void RecordComputedAction(const std::string& action) override; |
100 MojoShellConnection* GetMojoShellConnection() override; | 98 MojoShellConnection* GetMojoShellConnection() override; |
101 shell::InterfaceRegistry* GetInterfaceRegistry() override; | 99 shell::InterfaceRegistry* GetInterfaceRegistry() override; |
102 shell::InterfaceProvider* GetRemoteInterfaces() override; | 100 shell::InterfaceProvider* GetRemoteInterfaces() override; |
103 | 101 |
104 // shell::ShellClient: | |
105 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override; | |
106 shell::InterfaceProvider* GetInterfaceProviderForConnection() override; | |
107 | |
108 IPC::SyncChannel* channel() { return channel_.get(); } | 102 IPC::SyncChannel* channel() { return channel_.get(); } |
109 | 103 |
110 IPC::MessageRouter* GetRouter(); | 104 IPC::MessageRouter* GetRouter(); |
111 | 105 |
112 // Allocates a block of shared memory of the given size. Returns NULL on | 106 // Allocates a block of shared memory of the given size. Returns NULL on |
113 // failure. | 107 // failure. |
114 // Note: On posix, this requires a sync IPC to the browser process, | 108 // Note: On posix, this requires a sync IPC to the browser process, |
115 // but on windows the child process directly allocates the block. | 109 // but on windows the child process directly allocates the block. |
116 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); | 110 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); |
117 | 111 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 296 |
303 std::unique_ptr<ChildGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 297 std::unique_ptr<ChildGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
304 | 298 |
305 std::unique_ptr<ChildDiscardableSharedMemoryManager> | 299 std::unique_ptr<ChildDiscardableSharedMemoryManager> |
306 discardable_shared_memory_manager_; | 300 discardable_shared_memory_manager_; |
307 | 301 |
308 std::unique_ptr<base::PowerMonitor> power_monitor_; | 302 std::unique_ptr<base::PowerMonitor> power_monitor_; |
309 | 303 |
310 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_; | 304 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_; |
311 | 305 |
312 base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_; | 306 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>> |
| 307 channel_connected_factory_; |
| 308 |
| 309 base::WeakPtrFactory<ChildThreadImpl> weak_factory_; |
313 | 310 |
314 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); | 311 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); |
315 }; | 312 }; |
316 | 313 |
317 struct ChildThreadImpl::Options { | 314 struct ChildThreadImpl::Options { |
318 Options(const Options& other); | 315 Options(const Options& other); |
319 ~Options(); | 316 ~Options(); |
320 | 317 |
321 class Builder; | 318 class Builder; |
322 | 319 |
(...skipping 21 matching lines...) Expand all Loading... |
344 | 341 |
345 private: | 342 private: |
346 struct Options options_; | 343 struct Options options_; |
347 | 344 |
348 DISALLOW_COPY_AND_ASSIGN(Builder); | 345 DISALLOW_COPY_AND_ASSIGN(Builder); |
349 }; | 346 }; |
350 | 347 |
351 } // namespace content | 348 } // namespace content |
352 | 349 |
353 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ | 350 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ |
OLD | NEW |