| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "cc/base/switches.h" | 54 #include "cc/base/switches.h" |
| 55 #include "cc/output/buffer_to_texture_target_map.h" | 55 #include "cc/output/buffer_to_texture_target_map.h" |
| 56 #include "components/metrics/single_sample_metrics.h" | 56 #include "components/metrics/single_sample_metrics.h" |
| 57 #include "components/tracing/common/tracing_switches.h" | 57 #include "components/tracing/common/tracing_switches.h" |
| 58 #include "content/browser/appcache/appcache_dispatcher_host.h" | 58 #include "content/browser/appcache/appcache_dispatcher_host.h" |
| 59 #include "content/browser/appcache/chrome_appcache_service.h" | 59 #include "content/browser/appcache/chrome_appcache_service.h" |
| 60 #include "content/browser/background_fetch/background_fetch_service_impl.h" | 60 #include "content/browser/background_fetch/background_fetch_service_impl.h" |
| 61 #include "content/browser/background_sync/background_sync_service_impl.h" | 61 #include "content/browser/background_sync/background_sync_service_impl.h" |
| 62 #include "content/browser/bad_message.h" | 62 #include "content/browser/bad_message.h" |
| 63 #include "content/browser/blob_storage/blob_dispatcher_host.h" | 63 #include "content/browser/blob_storage/blob_dispatcher_host.h" |
| 64 #include "content/browser/blob_storage/blob_url_loader_factory.h" |
| 64 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 65 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 65 #include "content/browser/broadcast_channel/broadcast_channel_provider.h" | 66 #include "content/browser/broadcast_channel/broadcast_channel_provider.h" |
| 66 #include "content/browser/browser_child_process_host_impl.h" | 67 #include "content/browser/browser_child_process_host_impl.h" |
| 67 #include "content/browser/browser_main.h" | 68 #include "content/browser/browser_main.h" |
| 68 #include "content/browser/browser_main_loop.h" | 69 #include "content/browser/browser_main_loop.h" |
| 69 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" | 70 #include "content/browser/browser_plugin/browser_plugin_message_filter.h" |
| 70 #include "content/browser/cache_storage/cache_storage_context_impl.h" | 71 #include "content/browser/cache_storage/cache_storage_context_impl.h" |
| 71 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" | 72 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" |
| 72 #include "content/browser/child_process_security_policy_impl.h" | 73 #include "content/browser/child_process_security_policy_impl.h" |
| 73 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 74 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 id_, | 942 id_, |
| 942 storage_partition_impl_->GetURLRequestContext(), | 943 storage_partition_impl_->GetURLRequestContext(), |
| 943 storage_partition_impl_->GetIndexedDBContext(), | 944 storage_partition_impl_->GetIndexedDBContext(), |
| 944 ChromeBlobStorageContext::GetFor(browser_context_))), | 945 ChromeBlobStorageContext::GetFor(browser_context_))), |
| 945 channel_connected_(false), | 946 channel_connected_(false), |
| 946 sent_render_process_ready_(false), | 947 sent_render_process_ready_(false), |
| 947 #if defined(OS_ANDROID) | 948 #if defined(OS_ANDROID) |
| 948 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, | 949 never_signaled_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 949 base::WaitableEvent::InitialState::NOT_SIGNALED), | 950 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 950 #endif | 951 #endif |
| 952 renderer_host_binding_(this), |
| 951 instance_weak_factory_( | 953 instance_weak_factory_( |
| 952 new base::WeakPtrFactory<RenderProcessHostImpl>(this)), | 954 new base::WeakPtrFactory<RenderProcessHostImpl>(this)), |
| 953 frame_sink_provider_(id_), | 955 frame_sink_provider_(id_), |
| 954 weak_factory_(this) { | 956 weak_factory_(this) { |
| 955 widget_helper_ = new RenderWidgetHelper(); | 957 widget_helper_ = new RenderWidgetHelper(); |
| 956 | 958 |
| 957 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); | 959 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); |
| 958 | 960 |
| 959 CHECK(!BrowserMainRunner::ExitedMainMessageLoop()); | 961 CHECK(!BrowserMainRunner::ExitedMainMessageLoop()); |
| 960 RegisterHost(GetID(), this); | 962 RegisterHost(GetID(), this); |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 | 1558 |
| 1557 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); | 1559 AddUIThreadInterface(registry.get(), base::Bind(&FieldTrialRecorder::Create)); |
| 1558 | 1560 |
| 1559 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); | 1561 associated_interfaces_.reset(new AssociatedInterfaceRegistryImpl()); |
| 1560 GetContentClient()->browser()->ExposeInterfacesToRenderer( | 1562 GetContentClient()->browser()->ExposeInterfacesToRenderer( |
| 1561 registry.get(), associated_interfaces_.get(), this); | 1563 registry.get(), associated_interfaces_.get(), this); |
| 1562 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) | 1564 static_cast<AssociatedInterfaceRegistry*>(associated_interfaces_.get()) |
| 1563 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, | 1565 ->AddInterface(base::Bind(&RenderProcessHostImpl::BindRouteProvider, |
| 1564 base::Unretained(this))); | 1566 base::Unretained(this))); |
| 1565 | 1567 |
| 1568 AddUIThreadInterface(registry.get(), |
| 1569 base::Bind(&RenderProcessHostImpl::CreateRendererHost, |
| 1570 base::Unretained(this))); |
| 1571 |
| 1566 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1572 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1567 switches::kEnableNetworkService)) { | 1573 switches::kEnableNetworkService)) { |
| 1568 AddUIThreadInterface( | 1574 AddUIThreadInterface( |
| 1569 registry.get(), | 1575 registry.get(), |
| 1570 base::Bind(&RenderProcessHostImpl::CreateURLLoaderFactory, | 1576 base::Bind(&RenderProcessHostImpl::CreateURLLoaderFactory, |
| 1571 base::Unretained(this))); | 1577 base::Unretained(this))); |
| 1572 } | 1578 } |
| 1573 | 1579 |
| 1574 ServiceManagerConnection* service_manager_connection = | 1580 ServiceManagerConnection* service_manager_connection = |
| 1575 BrowserContext::GetServiceManagerConnectionFor(browser_context_); | 1581 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1599 void RenderProcessHostImpl::GetAssociatedInterface( | 1605 void RenderProcessHostImpl::GetAssociatedInterface( |
| 1600 const std::string& name, | 1606 const std::string& name, |
| 1601 mojom::AssociatedInterfaceAssociatedRequest request) { | 1607 mojom::AssociatedInterfaceAssociatedRequest request) { |
| 1602 int32_t routing_id = | 1608 int32_t routing_id = |
| 1603 associated_interface_provider_bindings_.dispatch_context(); | 1609 associated_interface_provider_bindings_.dispatch_context(); |
| 1604 IPC::Listener* listener = listeners_.Lookup(routing_id); | 1610 IPC::Listener* listener = listeners_.Lookup(routing_id); |
| 1605 if (listener) | 1611 if (listener) |
| 1606 listener->OnAssociatedInterfaceRequest(name, request.PassHandle()); | 1612 listener->OnAssociatedInterfaceRequest(name, request.PassHandle()); |
| 1607 } | 1613 } |
| 1608 | 1614 |
| 1615 void RenderProcessHostImpl::GetBlobURLLoaderFactory( |
| 1616 mojom::URLLoaderFactoryRequest request) { |
| 1617 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1618 switches::kEnableNetworkService)) { |
| 1619 NOTREACHED(); |
| 1620 return; |
| 1621 } |
| 1622 storage_partition_impl_->GetBlobURLLoaderFactory()->HandleRequest( |
| 1623 std::move(request)); |
| 1624 } |
| 1625 |
| 1609 void RenderProcessHostImpl::CreateMusGpuRequest( | 1626 void RenderProcessHostImpl::CreateMusGpuRequest( |
| 1610 const service_manager::BindSourceInfo& source_info, | 1627 const service_manager::BindSourceInfo& source_info, |
| 1611 ui::mojom::GpuRequest request) { | 1628 ui::mojom::GpuRequest request) { |
| 1612 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1629 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1613 if (!gpu_client_) | 1630 if (!gpu_client_) |
| 1614 gpu_client_.reset(new GpuClient(GetID())); | 1631 gpu_client_.reset(new GpuClient(GetID())); |
| 1615 gpu_client_->Add(std::move(request)); | 1632 gpu_client_->Add(std::move(request)); |
| 1616 } | 1633 } |
| 1617 | 1634 |
| 1618 void RenderProcessHostImpl::CreateOffscreenCanvasProvider( | 1635 void RenderProcessHostImpl::CreateOffscreenCanvasProvider( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1637 void RenderProcessHostImpl::CreateStoragePartitionService( | 1654 void RenderProcessHostImpl::CreateStoragePartitionService( |
| 1638 const service_manager::BindSourceInfo& source_info, | 1655 const service_manager::BindSourceInfo& source_info, |
| 1639 mojom::StoragePartitionServiceRequest request) { | 1656 mojom::StoragePartitionServiceRequest request) { |
| 1640 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! | 1657 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! |
| 1641 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1658 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1642 switches::kMojoLocalStorage)) { | 1659 switches::kMojoLocalStorage)) { |
| 1643 storage_partition_impl_->Bind(std::move(request)); | 1660 storage_partition_impl_->Bind(std::move(request)); |
| 1644 } | 1661 } |
| 1645 } | 1662 } |
| 1646 | 1663 |
| 1664 void RenderProcessHostImpl::CreateRendererHost( |
| 1665 const service_manager::BindSourceInfo& source_info, |
| 1666 mojom::RendererHostRequest request) { |
| 1667 renderer_host_binding_.Bind(std::move(request)); |
| 1668 } |
| 1669 |
| 1647 void RenderProcessHostImpl::CreateURLLoaderFactory( | 1670 void RenderProcessHostImpl::CreateURLLoaderFactory( |
| 1648 const service_manager::BindSourceInfo& source_info, | 1671 const service_manager::BindSourceInfo& source_info, |
| 1649 mojom::URLLoaderFactoryRequest request) { | 1672 mojom::URLLoaderFactoryRequest request) { |
| 1650 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1673 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1651 switches::kEnableNetworkService)) { | 1674 switches::kEnableNetworkService)) { |
| 1652 NOTREACHED(); | 1675 NOTREACHED(); |
| 1653 return; | 1676 return; |
| 1654 } | 1677 } |
| 1655 storage_partition_impl_->network_context()->CreateURLLoaderFactory( | 1678 storage_partition_impl_->network_context()->CreateURLLoaderFactory( |
| 1656 std::move(request), id_); | 1679 std::move(request), id_); |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3600 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3623 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3601 | 3624 |
| 3602 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3625 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3603 // Capture the error message in a crash key value. | 3626 // Capture the error message in a crash key value. |
| 3604 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3627 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3605 bad_message::ReceivedBadMessage(render_process_id, | 3628 bad_message::ReceivedBadMessage(render_process_id, |
| 3606 bad_message::RPH_MOJO_PROCESS_ERROR); | 3629 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3607 } | 3630 } |
| 3608 | 3631 |
| 3609 } // namespace content | 3632 } // namespace content |
| OLD | NEW |