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

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

Issue 2100693002: Make RenderProcessHost/RenderThread use MojoChildConnection/MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rph2
Patch Set: . Created 4 years, 5 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
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" 21 #include "content/child/mojo/mojo_application.h"
22 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
23 #include "content/public/child/child_thread.h" 23 #include "content/public/child/child_thread.h"
24 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 24 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
25 #include "ipc/ipc_platform_file.h" 25 #include "ipc/ipc_platform_file.h"
26 #include "ipc/message_router.h" 26 #include "ipc/message_router.h"
27 #include "services/shell/public/cpp/shell_client.h"
27 28
28 namespace base { 29 namespace base {
29 class MessageLoop; 30 class MessageLoop;
30 } // namespace base 31 } // namespace base
31 32
32 namespace IPC { 33 namespace IPC {
33 class MessageFilter; 34 class MessageFilter;
34 class SyncChannel; 35 class SyncChannel;
35 class SyncMessageFilter; 36 class SyncMessageFilter;
36 } // namespace IPC 37 } // namespace IPC
(...skipping 24 matching lines...) Expand all
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 public 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;
99 shell::InterfaceRegistry* GetInterfaceRegistry() override; 102 shell::InterfaceRegistry* GetInterfaceRegistry() override;
100 shell::InterfaceProvider* GetRemoteInterfaces() override; 103 shell::InterfaceProvider* GetRemoteInterfaces() override;
101 104
105 // shell::ShellClient:
106 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override;
107 shell::InterfaceProvider* GetInterfaceProviderForConnection() override;
108
102 IPC::SyncChannel* channel() { return channel_.get(); } 109 IPC::SyncChannel* channel() { return channel_.get(); }
103 110
104 IPC::MessageRouter* GetRouter(); 111 IPC::MessageRouter* GetRouter();
105 112
106 // 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
107 // failure. 114 // failure.
108 // 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,
109 // but on windows the child process directly allocates the block. 116 // but on windows the child process directly allocates the block.
110 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); 117 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size);
111 118
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
249 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; 256 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_;
257 bool use_mojo_shell_connection_ = false;
250 std::unique_ptr<MojoApplication> mojo_application_; 258 std::unique_ptr<MojoApplication> mojo_application_;
259 std::unique_ptr<MojoShellConnection> mojo_shell_connection_;
260 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
261 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
251 262
252 std::string channel_name_; 263 std::string channel_name_;
253 std::unique_ptr<IPC::SyncChannel> channel_; 264 std::unique_ptr<IPC::SyncChannel> channel_;
254 265
255 // Allows threads other than the main thread to send sync messages. 266 // Allows threads other than the main thread to send sync messages.
256 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 267 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
257 268
258 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 269 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
259 270
260 // Implements message routing functionality to the consumers of 271 // Implements message routing functionality to the consumers of
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ~Options(); 322 ~Options();
312 323
313 class Builder; 324 class Builder;
314 325
315 std::string channel_name; 326 std::string channel_name;
316 bool use_mojo_channel; 327 bool use_mojo_channel;
317 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner; 328 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner;
318 std::vector<IPC::MessageFilter*> startup_filters; 329 std::vector<IPC::MessageFilter*> startup_filters;
319 std::string in_process_ipc_token; 330 std::string in_process_ipc_token;
320 std::string in_process_application_token; 331 std::string in_process_application_token;
332 bool use_mojo_shell_connection = false;
321 333
322 private: 334 private:
323 Options(); 335 Options();
324 }; 336 };
325 337
326 class ChildThreadImpl::Options::Builder { 338 class ChildThreadImpl::Options::Builder {
327 public: 339 public:
328 Builder(); 340 Builder();
329 341
330 Builder& InBrowserProcess(const InProcessChildThreadParams& params); 342 Builder& InBrowserProcess(const InProcessChildThreadParams& params);
331 Builder& UseMojoChannel(bool use_mojo_channel); 343 Builder& UseMojoChannel(bool use_mojo_channel);
332 Builder& WithChannelName(const std::string& channel_name); 344 Builder& WithChannelName(const std::string& channel_name);
333 Builder& AddStartupFilter(IPC::MessageFilter* filter); 345 Builder& AddStartupFilter(IPC::MessageFilter* filter);
346 Builder& UseMojoShellConnection(bool use_mojo_shell_connection);
334 347
335 Options Build(); 348 Options Build();
336 349
337 private: 350 private:
338 struct Options options_; 351 struct Options options_;
339 352
340 DISALLOW_COPY_AND_ASSIGN(Builder); 353 DISALLOW_COPY_AND_ASSIGN(Builder);
341 }; 354 };
342 355
343 } // namespace content 356 } // namespace content
344 357
345 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 358 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698