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

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

Issue 2755813002: Begin to wean child processes off reliance on a persistent service_manager::Connection to the brows… (Closed)
Patch Set: . Created 3 years, 9 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/child/push_messaging/push_provider.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 #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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 mojo::ScopedMessagePipeHandle handle = 447 mojo::ScopedMessagePipeHandle handle =
448 mojo::edk::CreateChildMessagePipe(service_request_token); 448 mojo::edk::CreateChildMessagePipe(service_request_token);
449 DCHECK(handle.is_valid()); 449 DCHECK(handle.is_valid());
450 service_manager_connection_ = ServiceManagerConnection::Create( 450 service_manager_connection_ = ServiceManagerConnection::Create(
451 mojo::MakeRequest<service_manager::mojom::Service>(std::move(handle)), 451 mojo::MakeRequest<service_manager::mojom::Service>(std::move(handle)),
452 GetIOTaskRunner()); 452 GetIOTaskRunner());
453 453
454 // When connect_to_browser is true, we obtain interfaces from the browser 454 // When connect_to_browser is true, we obtain interfaces from the browser
455 // process by connecting to it, rather than from the incoming interface 455 // process by connecting to it, rather than from the incoming interface
456 // provider. Exposed interfaces are subject to manifest capability spec. 456 // provider. Exposed interfaces are subject to manifest capability spec.
457 service_manager::InterfaceProvider* remote_interfaces = nullptr;
458 if (options.connect_to_browser) { 457 if (options.connect_to_browser) {
459 browser_connection_ = 458 browser_connection_ =
460 service_manager_connection_->GetConnector()->Connect( 459 service_manager_connection_->GetConnector()->Connect(
461 mojom::kBrowserServiceName); 460 mojom::kBrowserServiceName);
462 } else {
463 remote_interfaces = GetRemoteInterfaces();
464 } 461 }
465 462
466 // TODO(rockot): Remove this once all child-to-browser interface connections 463 // TODO(rockot): Remove this once all child-to-browser interface connections
467 // are made via a Connector rather than directly through an 464 // are made via a Connector rather than directly through an
468 // InterfaceProvider, and all exposed interfaces are exposed via a 465 // InterfaceProvider, and all exposed interfaces are exposed via a
469 // ConnectionFilter. 466 // ConnectionFilter.
470 service_manager_connection_->SetupInterfaceRequestProxies( 467 service_manager_connection_->SetupInterfaceRequestProxies(
471 GetInterfaceRegistry(), remote_interfaces); 468 GetInterfaceRegistry(), nullptr);
472 } 469 }
473 470
474 sync_message_filter_ = channel_->CreateSyncMessageFilter(); 471 sync_message_filter_ = channel_->CreateSyncMessageFilter();
475 thread_safe_sender_ = new ThreadSafeSender( 472 thread_safe_sender_ = new ThreadSafeSender(
476 message_loop_->task_runner(), sync_message_filter_.get()); 473 message_loop_->task_runner(), sync_message_filter_.get());
477 474
478 resource_dispatcher_.reset(new ResourceDispatcher( 475 resource_dispatcher_.reset(new ResourceDispatcher(
479 this, message_loop()->task_runner())); 476 this, message_loop()->task_runner()));
480 file_system_dispatcher_.reset(new FileSystemDispatcher()); 477 file_system_dispatcher_.reset(new FileSystemDispatcher());
481 478
(...skipping 18 matching lines...) Expand all
500 channel_->AddFilter(service_worker_message_filter_->GetFilter()); 497 channel_->AddFilter(service_worker_message_filter_->GetFilter());
501 498
502 if (!IsInBrowserProcess()) { 499 if (!IsInBrowserProcess()) {
503 // In single process mode, browser-side tracing and memory will cover the 500 // In single process mode, browser-side tracing and memory will cover the
504 // whole process including renderers. 501 // whole process including renderers.
505 channel_->AddFilter(new tracing::ChildTraceMessageFilter( 502 channel_->AddFilter(new tracing::ChildTraceMessageFilter(
506 ChildProcess::current()->io_task_runner())); 503 ChildProcess::current()->io_task_runner()));
507 channel_->AddFilter(new ChildMemoryMessageFilter()); 504 channel_->AddFilter(new ChildMemoryMessageFilter());
508 505
509 memory_instrumentation::MemoryDumpManagerDelegateImpl::Config config( 506 memory_instrumentation::MemoryDumpManagerDelegateImpl::Config config(
510 GetRemoteInterfaces()); 507 GetConnector(), mojom::kBrowserServiceName);
511 auto delegate = 508 auto delegate =
512 base::MakeUnique<memory_instrumentation::MemoryDumpManagerDelegateImpl>( 509 base::MakeUnique<memory_instrumentation::MemoryDumpManagerDelegateImpl>(
513 config); 510 config);
514 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( 511 base::trace_event::MemoryDumpManager::GetInstance()->Initialize(
515 std::move(delegate)); 512 std::move(delegate));
516 } 513 }
517 514
518 // In single process mode we may already have a power monitor, 515 // In single process mode we may already have a power monitor,
519 // also for some edge cases where there is no ServiceManagerConnection, we do 516 // also for some edge cases where there is no ServiceManagerConnection, we do
520 // not create the power monitor. 517 // not create the power monitor.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 642 }
646 643
647 service_manager::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { 644 service_manager::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() {
648 if (!interface_registry_.get()) { 645 if (!interface_registry_.get()) {
649 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( 646 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>(
650 service_manager::mojom::kServiceManager_ConnectorSpec); 647 service_manager::mojom::kServiceManager_ConnectorSpec);
651 } 648 }
652 return interface_registry_.get(); 649 return interface_registry_.get();
653 } 650 }
654 651
655 service_manager::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { 652 service_manager::Connector* ChildThreadImpl::GetConnector() {
656 if (browser_connection_) 653 return service_manager_connection_->GetConnector();
657 return browser_connection_->GetRemoteInterfaces();
658
659 if (!remote_interfaces_.get())
660 remote_interfaces_.reset(new service_manager::InterfaceProvider);
661 return remote_interfaces_.get();
662 } 654 }
663 655
664 const service_manager::ServiceInfo& 656 const service_manager::ServiceInfo&
665 ChildThreadImpl::GetChildServiceInfo() const { 657 ChildThreadImpl::GetChildServiceInfo() const {
666 DCHECK(IsConnectedToBrowser()); 658 DCHECK(IsConnectedToBrowser());
667 return child_info_; 659 return child_info_;
668 } 660 }
669 661
670 const service_manager::ServiceInfo& 662 const service_manager::ServiceInfo&
671 ChildThreadImpl::GetBrowserServiceInfo() const { 663 ChildThreadImpl::GetBrowserServiceInfo() const {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 connected_to_browser_ = true; 874 connected_to_browser_ = true;
883 child_info_ = local_info; 875 child_info_ = local_info;
884 browser_info_ = remote_info; 876 browser_info_ = remote_info;
885 } 877 }
886 878
887 bool ChildThreadImpl::IsInBrowserProcess() const { 879 bool ChildThreadImpl::IsInBrowserProcess() const {
888 return static_cast<bool>(browser_process_io_runner_); 880 return static_cast<bool>(browser_process_io_runner_);
889 } 881 }
890 882
891 } // namespace content 883 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/child/push_messaging/push_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698