Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: content/child/child_thread_impl.h

Issue 2096643002: Eliminate MojoApplicationHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mah3
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/child/mojo/mojo_application.h"
22 #include "content/common/content_export.h" 21 #include "content/common/content_export.h"
23 #include "content/public/child/child_thread.h" 22 #include "content/public/child/child_thread.h"
24 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 23 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
25 #include "ipc/ipc_platform_file.h" 24 #include "ipc/ipc_platform_file.h"
26 #include "ipc/message_router.h" 25 #include "ipc/message_router.h"
26 #include "services/shell/public/cpp/shell_client.h"
27 27
28 namespace base { 28 namespace base {
29 class MessageLoop; 29 class MessageLoop;
30 } // namespace base 30 } // namespace base
31 31
32 namespace IPC { 32 namespace IPC {
33 class MessageFilter; 33 class MessageFilter;
34 class SyncChannel; 34 class SyncChannel;
35 class SyncMessageFilter; 35 class SyncMessageFilter;
36 } // namespace IPC 36 } // namespace IPC
(...skipping 10 matching lines...) Expand all
47 47
48 namespace content { 48 namespace content {
49 class ChildMessageFilter; 49 class ChildMessageFilter;
50 class ChildDiscardableSharedMemoryManager; 50 class ChildDiscardableSharedMemoryManager;
51 class ChildGpuMemoryBufferManager; 51 class ChildGpuMemoryBufferManager;
52 class ChildHistogramMessageFilter; 52 class ChildHistogramMessageFilter;
53 class ChildResourceMessageFilter; 53 class ChildResourceMessageFilter;
54 class ChildSharedBitmapManager; 54 class ChildSharedBitmapManager;
55 class FileSystemDispatcher; 55 class FileSystemDispatcher;
56 class InProcessChildThreadParams; 56 class InProcessChildThreadParams;
57 class MojoShellConnection;
57 class NotificationDispatcher; 58 class NotificationDispatcher;
58 class PushDispatcher; 59 class PushDispatcher;
59 class ServiceWorkerMessageFilter; 60 class ServiceWorkerMessageFilter;
60 class QuotaDispatcher; 61 class QuotaDispatcher;
61 class QuotaMessageFilter; 62 class QuotaMessageFilter;
62 class ResourceDispatcher; 63 class ResourceDispatcher;
63 class ThreadSafeSender; 64 class ThreadSafeSender;
64 class WebSocketDispatcher; 65 class WebSocketDispatcher;
65 class WebSocketMessageFilter; 66 class WebSocketMessageFilter;
66 struct RequestInfo; 67 struct RequestInfo;
67 68
68 // The main thread of a child process derives from this class. 69 // The main thread of a child process derives from this class.
69 class CONTENT_EXPORT ChildThreadImpl 70 class CONTENT_EXPORT ChildThreadImpl
70 : public IPC::Listener, 71 : public IPC::Listener,
71 virtual public ChildThread { 72 virtual public ChildThread,
73 NON_EXPORTED_BASE(shell::ShellClient) {
72 public: 74 public:
73 struct CONTENT_EXPORT Options; 75 struct CONTENT_EXPORT Options;
74 76
75 // Creates the thread. 77 // Creates the thread.
76 ChildThreadImpl(); 78 ChildThreadImpl();
77 // Allow to be used for single-process mode and for in process gpu mode via 79 // Allow to be used for single-process mode and for in process gpu mode via
78 // options. 80 // options.
79 explicit ChildThreadImpl(const Options& options); 81 explicit ChildThreadImpl(const Options& options);
80 // ChildProcess::main_thread() is reset after Shutdown(), and before the 82 // ChildProcess::main_thread() is reset after Shutdown(), and before the
81 // destructor, so any subsystem that relies on ChildProcess::main_thread() 83 // destructor, so any subsystem that relies on ChildProcess::main_thread()
82 // must be terminated before Shutdown returns. In particular, if a subsystem 84 // must be terminated before Shutdown returns. In particular, if a subsystem
83 // has a thread that post tasks to ChildProcess::main_thread(), that thread 85 // has a thread that post tasks to ChildProcess::main_thread(), that thread
84 // should be joined in Shutdown(). 86 // should be joined in Shutdown().
85 ~ChildThreadImpl() override; 87 ~ChildThreadImpl() override;
86 virtual void Shutdown(); 88 virtual void Shutdown();
87 void ShutdownDiscardableSharedMemoryManager(); 89 void ShutdownDiscardableSharedMemoryManager();
88 90
89 // IPC::Sender implementation: 91 // IPC::Sender implementation:
90 bool Send(IPC::Message* msg) override; 92 bool Send(IPC::Message* msg) override;
91 93
92 // ChildThread implementation: 94 // ChildThread implementation:
93 #if defined(OS_WIN) 95 #if defined(OS_WIN)
94 void PreCacheFont(const LOGFONT& log_font) override; 96 void PreCacheFont(const LOGFONT& log_font) override;
95 void ReleaseCachedFonts() override; 97 void ReleaseCachedFonts() override;
96 #endif 98 #endif
97 void RecordAction(const base::UserMetricsAction& action) override; 99 void RecordAction(const base::UserMetricsAction& action) override;
98 void RecordComputedAction(const std::string& action) override; 100 void RecordComputedAction(const std::string& action) override;
101 MojoShellConnection* GetMojoShellConnection() override;
102 shell::InterfaceRegistry* GetInterfaceRegistry() override;
103 shell::InterfaceProvider* GetRemoteInterfaces() override;
104
105 // shell::ShellClient implementation:
106 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override;
107 shell::InterfaceProvider* GetInterfaceProviderForConnection() override;
99 108
100 IPC::SyncChannel* channel() { return channel_.get(); } 109 IPC::SyncChannel* channel() { return channel_.get(); }
101 110
102 IPC::MessageRouter* GetRouter(); 111 IPC::MessageRouter* GetRouter();
103 112
104 // Allocates a block of shared memory of the given size. Returns NULL on 113 // Allocates a block of shared memory of the given size. Returns NULL on
105 // failure. 114 // failure.
106 // Note: On posix, this requires a sync IPC to the browser process, 115 // Note: On posix, this requires a sync IPC to the browser process,
107 // but on windows the child process directly allocates the block. 116 // but on windows the child process directly allocates the block.
108 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); 117 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 197
189 // Returns the one child thread. Can only be called on the main thread. 198 // Returns the one child thread. Can only be called on the main thread.
190 static ChildThreadImpl* current(); 199 static ChildThreadImpl* current();
191 200
192 #if defined(OS_ANDROID) 201 #if defined(OS_ANDROID)
193 // Called on Android's service thread to shutdown the main thread of this 202 // Called on Android's service thread to shutdown the main thread of this
194 // process. 203 // process.
195 static void ShutdownThread(); 204 static void ShutdownThread();
196 #endif 205 #endif
197 206
198 shell::InterfaceRegistry* interface_registry() {
199 return mojo_application_->interface_registry();
200 }
201
202 shell::InterfaceProvider* remote_interfaces() const {
203 return mojo_application_->remote_interfaces();
204 }
205
206 protected: 207 protected:
207 friend class ChildProcess; 208 friend class ChildProcess;
208 209
209 // Called when the process refcount is 0. 210 // Called when the process refcount is 0.
210 void OnProcessFinalRelease(); 211 void OnProcessFinalRelease();
211 212
212 virtual bool OnControlMessageReceived(const IPC::Message& msg); 213 virtual bool OnControlMessageReceived(const IPC::Message& msg);
213 virtual void OnProcessBackgrounded(bool backgrounded); 214 virtual void OnProcessBackgrounded(bool backgrounded);
214 virtual void OnProcessPurgeAndSuspend(); 215 virtual void OnProcessPurgeAndSuspend();
215 216
(...skipping 30 matching lines...) Expand all
246 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); 247 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
247 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); 248 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase);
248 void OnProfilingPhaseCompleted(int profiling_phase); 249 void OnProfilingPhaseCompleted(int profiling_phase);
249 #ifdef IPC_MESSAGE_LOG_ENABLED 250 #ifdef IPC_MESSAGE_LOG_ENABLED
250 void OnSetIPCLoggingEnabled(bool enable); 251 void OnSetIPCLoggingEnabled(bool enable);
251 #endif 252 #endif
252 253
253 void EnsureConnected(); 254 void EnsureConnected();
254 255
255 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; 256 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_;
256 std::unique_ptr<MojoApplication> mojo_application_; 257 std::unique_ptr<MojoShellConnection> mojo_shell_connection_;
258 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
259 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
257 260
258 std::string channel_name_; 261 std::string channel_name_;
259 std::unique_ptr<IPC::SyncChannel> channel_; 262 std::unique_ptr<IPC::SyncChannel> channel_;
260 263
261 // Allows threads other than the main thread to send sync messages. 264 // Allows threads other than the main thread to send sync messages.
262 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 265 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
263 266
264 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 267 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
265 268
266 // Implements message routing functionality to the consumers of 269 // Implements message routing functionality to the consumers of
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 345
343 private: 346 private:
344 struct Options options_; 347 struct Options options_;
345 348
346 DISALLOW_COPY_AND_ASSIGN(Builder); 349 DISALLOW_COPY_AND_ASSIGN(Builder);
347 }; 350 };
348 351
349 } // namespace content 352 } // namespace content
350 353
351 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 354 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/blink_platform_impl.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698