| 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 #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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "ipc/ipc_logging.h" | 59 #include "ipc/ipc_logging.h" |
| 60 #include "ipc/ipc_platform_file.h" | 60 #include "ipc/ipc_platform_file.h" |
| 61 #include "ipc/ipc_sync_channel.h" | 61 #include "ipc/ipc_sync_channel.h" |
| 62 #include "ipc/ipc_sync_message_filter.h" | 62 #include "ipc/ipc_sync_message_filter.h" |
| 63 #include "mojo/edk/embedder/embedder.h" | 63 #include "mojo/edk/embedder/embedder.h" |
| 64 #include "mojo/edk/embedder/named_platform_channel_pair.h" | 64 #include "mojo/edk/embedder/named_platform_channel_pair.h" |
| 65 #include "mojo/edk/embedder/platform_channel_pair.h" | 65 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 66 #include "mojo/edk/embedder/scoped_ipc_support.h" | 66 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 67 #include "mojo/public/cpp/system/buffer.h" | 67 #include "mojo/public/cpp/system/buffer.h" |
| 68 #include "mojo/public/cpp/system/platform_handle.h" | 68 #include "mojo/public/cpp/system/platform_handle.h" |
| 69 #include "services/device/public/interfaces/constants.mojom.h" |
| 69 #include "services/service_manager/public/cpp/connector.h" | 70 #include "services/service_manager/public/cpp/connector.h" |
| 70 #include "services/service_manager/public/cpp/interface_factory.h" | 71 #include "services/service_manager/public/cpp/interface_factory.h" |
| 71 #include "services/service_manager/public/cpp/interface_provider.h" | 72 #include "services/service_manager/public/cpp/interface_provider.h" |
| 72 #include "services/service_manager/public/cpp/interface_registry.h" | 73 #include "services/service_manager/public/cpp/interface_registry.h" |
| 73 #include "services/service_manager/runner/common/client_util.h" | 74 #include "services/service_manager/runner/common/client_util.h" |
| 74 | 75 |
| 75 #if defined(OS_POSIX) | 76 #if defined(OS_POSIX) |
| 76 #include "base/posix/global_descriptors.h" | 77 #include "base/posix/global_descriptors.h" |
| 77 #include "content/public/common/content_descriptors.h" | 78 #include "content/public/common/content_descriptors.h" |
| 78 #endif | 79 #endif |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 channel_->AddFilter(service_worker_message_filter_->GetFilter()); | 503 channel_->AddFilter(service_worker_message_filter_->GetFilter()); |
| 503 | 504 |
| 504 if (!IsInBrowserProcess()) { | 505 if (!IsInBrowserProcess()) { |
| 505 // In single process mode, browser-side tracing and memory will cover the | 506 // In single process mode, browser-side tracing and memory will cover the |
| 506 // whole process including renderers. | 507 // whole process including renderers. |
| 507 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 508 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
| 508 ChildProcess::current()->io_task_runner())); | 509 ChildProcess::current()->io_task_runner())); |
| 509 channel_->AddFilter(new ChildMemoryMessageFilter()); | 510 channel_->AddFilter(new ChildMemoryMessageFilter()); |
| 510 } | 511 } |
| 511 | 512 |
| 512 // In single process mode we may already have a power monitor | 513 // In single process mode we may already have a power monitor, |
| 513 if (!base::PowerMonitor::Get()) { | 514 // also for some edge cases where there is no ServiceManagerConnection, we do |
| 514 std::unique_ptr<device::PowerMonitorBroadcastSource> power_monitor_source( | 515 // not create the power monitor. |
| 515 new device::PowerMonitorBroadcastSource(GetRemoteInterfaces())); | 516 if (!base::PowerMonitor::Get() && service_manager_connection_) { |
| 517 std::unique_ptr<service_manager::Connection> device_connection = |
| 518 service_manager_connection_->GetConnector()->Connect( |
| 519 device::mojom::kServiceName); |
| 520 auto power_monitor_source = |
| 521 base::MakeUnique<device::PowerMonitorBroadcastSource>( |
| 522 device_connection->GetRemoteInterfaces()); |
| 516 | 523 |
| 517 power_monitor_.reset( | 524 power_monitor_.reset( |
| 518 new base::PowerMonitor(std::move(power_monitor_source))); | 525 new base::PowerMonitor(std::move(power_monitor_source))); |
| 519 } | 526 } |
| 520 | 527 |
| 521 #if defined(OS_POSIX) | 528 #if defined(OS_POSIX) |
| 522 // Check that --process-type is specified so we don't do this in unit tests | 529 // Check that --process-type is specified so we don't do this in unit tests |
| 523 // and single-process mode. | 530 // and single-process mode. |
| 524 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) | 531 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) |
| 525 channel_->AddFilter(new SuicideOnChannelErrorFilter()); | 532 channel_->AddFilter(new SuicideOnChannelErrorFilter()); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 connected_to_browser_ = true; | 870 connected_to_browser_ = true; |
| 864 child_info_ = local_info; | 871 child_info_ = local_info; |
| 865 browser_info_ = remote_info; | 872 browser_info_ = remote_info; |
| 866 } | 873 } |
| 867 | 874 |
| 868 bool ChildThreadImpl::IsInBrowserProcess() const { | 875 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 869 return static_cast<bool>(browser_process_io_runner_); | 876 return static_cast<bool>(browser_process_io_runner_); |
| 870 } | 877 } |
| 871 | 878 |
| 872 } // namespace content | 879 } // namespace content |
| OLD | NEW |