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

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

Issue 2137303002: Allow ChildThreadImpl subclasses to manually start MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/renderer/render_thread_impl.h » ('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 #include "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } // namespace 258 } // namespace
259 259
260 ChildThread* ChildThread::Get() { 260 ChildThread* ChildThread::Get() {
261 return ChildThreadImpl::current(); 261 return ChildThreadImpl::current();
262 } 262 }
263 263
264 ChildThreadImpl::Options::Options() 264 ChildThreadImpl::Options::Options()
265 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 265 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
266 switches::kProcessChannelID)), 266 switches::kProcessChannelID)),
267 use_mojo_channel(base::CommandLine::ForCurrentProcess()->HasSwitch( 267 use_mojo_channel(base::CommandLine::ForCurrentProcess()->HasSwitch(
268 switches::kMojoChannelToken)) { 268 switches::kMojoChannelToken)),
269 auto_start_mojo_shell_connection(true) {
269 } 270 }
270 271
271 ChildThreadImpl::Options::Options(const Options& other) = default; 272 ChildThreadImpl::Options::Options(const Options& other) = default;
272 273
273 ChildThreadImpl::Options::~Options() { 274 ChildThreadImpl::Options::~Options() {
274 } 275 }
275 276
276 ChildThreadImpl::Options::Builder::Builder() { 277 ChildThreadImpl::Options::Builder::Builder() {
277 } 278 }
278 279
279 ChildThreadImpl::Options::Builder& 280 ChildThreadImpl::Options::Builder&
280 ChildThreadImpl::Options::Builder::InBrowserProcess( 281 ChildThreadImpl::Options::Builder::InBrowserProcess(
281 const InProcessChildThreadParams& params) { 282 const InProcessChildThreadParams& params) {
282 options_.browser_process_io_runner = params.io_runner(); 283 options_.browser_process_io_runner = params.io_runner();
283 options_.channel_name = params.channel_name(); 284 options_.channel_name = params.channel_name();
284 options_.in_process_ipc_token = params.ipc_token(); 285 options_.in_process_ipc_token = params.ipc_token();
285 options_.in_process_application_token = params.application_token(); 286 options_.in_process_application_token = params.application_token();
286 return *this; 287 return *this;
287 } 288 }
288 289
289 ChildThreadImpl::Options::Builder& 290 ChildThreadImpl::Options::Builder&
290 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) { 291 ChildThreadImpl::Options::Builder::UseMojoChannel(bool use_mojo_channel) {
291 options_.use_mojo_channel = use_mojo_channel; 292 options_.use_mojo_channel = use_mojo_channel;
292 return *this; 293 return *this;
293 } 294 }
294 295
295 ChildThreadImpl::Options::Builder& 296 ChildThreadImpl::Options::Builder&
297 ChildThreadImpl::Options::Builder::AutoStartMojoShellConnection(
298 bool auto_start) {
299 options_.auto_start_mojo_shell_connection = auto_start;
300 return *this;
301 }
302
303 ChildThreadImpl::Options::Builder&
296 ChildThreadImpl::Options::Builder::WithChannelName( 304 ChildThreadImpl::Options::Builder::WithChannelName(
297 const std::string& channel_name) { 305 const std::string& channel_name) {
298 options_.channel_name = channel_name; 306 options_.channel_name = channel_name;
299 return *this; 307 return *this;
300 } 308 }
301 309
302 ChildThreadImpl::Options::Builder& 310 ChildThreadImpl::Options::Builder&
303 ChildThreadImpl::Options::Builder::AddStartupFilter( 311 ChildThreadImpl::Options::Builder::AddStartupFilter(
304 IPC::MessageFilter* filter) { 312 IPC::MessageFilter* filter) {
305 options_.startup_filters.push_back(filter); 313 options_.startup_filters.push_back(filter);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 mojo::MakeRequest<shell::mojom::Service>(std::move(handle)), 430 mojo::MakeRequest<shell::mojom::Service>(std::move(handle)),
423 GetIOTaskRunner()); 431 GetIOTaskRunner());
424 432
425 // TODO(rockot): Remove this once all child-to-browser interface connections 433 // TODO(rockot): Remove this once all child-to-browser interface connections
426 // are made via a Connector rather than directly through an 434 // are made via a Connector rather than directly through an
427 // InterfaceProvider, and all exposed interfaces are exposed via a 435 // InterfaceProvider, and all exposed interfaces are exposed via a
428 // ConnectionFilter. 436 // ConnectionFilter.
429 mojo_shell_connection_->SetupInterfaceRequestProxies( 437 mojo_shell_connection_->SetupInterfaceRequestProxies(
430 GetInterfaceRegistry(), GetRemoteInterfaces()); 438 GetInterfaceRegistry(), GetRemoteInterfaces());
431 439
432 AddConnectionFilters(mojo_shell_connection_.get()); 440 if (options.auto_start_mojo_shell_connection)
433 mojo_shell_connection_->Start(); 441 StartMojoShellConnection();
434 } 442 }
435 443
436 sync_message_filter_ = channel_->CreateSyncMessageFilter(); 444 sync_message_filter_ = channel_->CreateSyncMessageFilter();
437 thread_safe_sender_ = new ThreadSafeSender( 445 thread_safe_sender_ = new ThreadSafeSender(
438 message_loop_->task_runner(), sync_message_filter_.get()); 446 message_loop_->task_runner(), sync_message_filter_.get());
439 447
440 resource_dispatcher_.reset(new ResourceDispatcher( 448 resource_dispatcher_.reset(new ResourceDispatcher(
441 this, message_loop()->task_runner())); 449 this, message_loop()->task_runner()));
442 websocket_dispatcher_.reset(new WebSocketDispatcher); 450 websocket_dispatcher_.reset(new WebSocketDispatcher);
443 file_system_dispatcher_.reset(new FileSystemDispatcher()); 451 file_system_dispatcher_.reset(new FileSystemDispatcher());
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 697
690 if (handled) 698 if (handled)
691 return true; 699 return true;
692 700
693 if (msg.routing_id() == MSG_ROUTING_CONTROL) 701 if (msg.routing_id() == MSG_ROUTING_CONTROL)
694 return OnControlMessageReceived(msg); 702 return OnControlMessageReceived(msg);
695 703
696 return router_.OnMessageReceived(msg); 704 return router_.OnMessageReceived(msg);
697 } 705 }
698 706
699 void ChildThreadImpl::AddConnectionFilters(MojoShellConnection* connection) {} 707 void ChildThreadImpl::StartMojoShellConnection() {
708 DCHECK(mojo_shell_connection_);
709 mojo_shell_connection_->Start();
710 }
700 711
701 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { 712 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
702 return false; 713 return false;
703 } 714 }
704 715
705 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { 716 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) {
706 // Set timer slack to maximum on main thread when in background. 717 // Set timer slack to maximum on main thread when in background.
707 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 718 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
708 if (backgrounded) 719 if (backgrounded)
709 timer_slack = base::TIMER_SLACK_MAXIMUM; 720 timer_slack = base::TIMER_SLACK_MAXIMUM;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 void ChildThreadImpl::EnsureConnected() { 784 void ChildThreadImpl::EnsureConnected() {
774 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 785 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
775 base::Process::Current().Terminate(0, false); 786 base::Process::Current().Terminate(0, false);
776 } 787 }
777 788
778 bool ChildThreadImpl::IsInBrowserProcess() const { 789 bool ChildThreadImpl::IsInBrowserProcess() const {
779 return static_cast<bool>(browser_process_io_runner_); 790 return static_cast<bool>(browser_process_io_runner_);
780 } 791 }
781 792
782 } // namespace content 793 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698