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 // 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 #include "content/public/common/content_switches.h" | 134 #include "content/public/common/content_switches.h" |
135 #include "content/public/common/process_type.h" | 135 #include "content/public/common/process_type.h" |
136 #include "content/public/common/result_codes.h" | 136 #include "content/public/common/result_codes.h" |
137 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 137 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
138 #include "content/public/common/url_constants.h" | 138 #include "content/public/common/url_constants.h" |
139 #include "gpu/command_buffer/service/gpu_switches.h" | 139 #include "gpu/command_buffer/service/gpu_switches.h" |
140 #include "ipc/ipc_channel.h" | 140 #include "ipc/ipc_channel.h" |
141 #include "ipc/ipc_logging.h" | 141 #include "ipc/ipc_logging.h" |
142 #include "ipc/ipc_switches.h" | 142 #include "ipc/ipc_switches.h" |
143 #include "media/base/media_switches.h" | 143 #include "media/base/media_switches.h" |
144 #include "mojo/common/common_type_converters.h" | |
145 #include "net/url_request/url_request_context_getter.h" | 144 #include "net/url_request/url_request_context_getter.h" |
146 #include "ppapi/shared_impl/ppapi_switches.h" | 145 #include "ppapi/shared_impl/ppapi_switches.h" |
147 #include "third_party/skia/include/core/SkBitmap.h" | 146 #include "third_party/skia/include/core/SkBitmap.h" |
148 #include "ui/base/ui_base_switches.h" | 147 #include "ui/base/ui_base_switches.h" |
149 #include "ui/events/event_switches.h" | 148 #include "ui/events/event_switches.h" |
150 #include "ui/gfx/switches.h" | 149 #include "ui/gfx/switches.h" |
151 #include "ui/gl/gl_switches.h" | 150 #include "ui/gl/gl_switches.h" |
152 #include "ui/native_theme/native_theme_switches.h" | 151 #include "ui/native_theme/native_theme_switches.h" |
153 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 152 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
154 #include "webkit/common/resource_type.h" | 153 #include "webkit/common/resource_type.h" |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // Setup the IPC channel. | 589 // Setup the IPC channel. |
591 const std::string channel_id = | 590 const std::string channel_id = |
592 IPC::Channel::GenerateVerifiedChannelID(std::string()); | 591 IPC::Channel::GenerateVerifiedChannelID(std::string()); |
593 channel_ = IPC::ChannelProxy::Create( | 592 channel_ = IPC::ChannelProxy::Create( |
594 channel_id, | 593 channel_id, |
595 IPC::Channel::MODE_SERVER, | 594 IPC::Channel::MODE_SERVER, |
596 this, | 595 this, |
597 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); | 596 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()); |
598 | 597 |
599 // Setup the Mojo channel. | 598 // Setup the Mojo channel. |
| 599 mojo::ScopedMessagePipeHandle shell_handle; |
600 mojo_application_host_.reset(new MojoApplicationHost()); | 600 mojo_application_host_.reset(new MojoApplicationHost()); |
601 mojo_application_host_->Init(); | 601 mojo_application_host_->Init(&shell_handle); |
| 602 service_registry_.Bind(shell_handle.Pass()); |
602 | 603 |
603 // Call the embedder first so that their IPC filters have priority. | 604 // Call the embedder first so that their IPC filters have priority. |
604 GetContentClient()->browser()->RenderProcessWillLaunch(this); | 605 GetContentClient()->browser()->RenderProcessWillLaunch(this); |
605 | 606 |
606 CreateMessageFilters(); | 607 CreateMessageFilters(); |
607 | 608 |
608 if (run_renderer_in_process()) { | 609 if (run_renderer_in_process()) { |
609 DCHECK(g_renderer_main_thread_factory); | 610 DCHECK(g_renderer_main_thread_factory); |
610 // Crank up a thread and run the initialization there. With the way that | 611 // Crank up a thread and run the initialization there. With the way that |
611 // messages flow between the browser and renderer, this thread is required | 612 // messages flow between the browser and renderer, this thread is required |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 | 898 |
898 void RenderProcessHostImpl::ResumeDeferredNavigation( | 899 void RenderProcessHostImpl::ResumeDeferredNavigation( |
899 const GlobalRequestID& request_id) { | 900 const GlobalRequestID& request_id) { |
900 widget_helper_->ResumeDeferredNavigation(request_id); | 901 widget_helper_->ResumeDeferredNavigation(request_id); |
901 } | 902 } |
902 | 903 |
903 void RenderProcessHostImpl::NotifyTimezoneChange() { | 904 void RenderProcessHostImpl::NotifyTimezoneChange() { |
904 Send(new ViewMsg_TimezoneChange()); | 905 Send(new ViewMsg_TimezoneChange()); |
905 } | 906 } |
906 | 907 |
| 908 ServiceRegistry* RenderProcessHostImpl::GetServiceRegistry() { |
| 909 return &service_registry_; |
| 910 } |
| 911 |
| 912 void RenderProcessHostImpl::ActivateMojo() { |
| 913 mojo_activation_required_ = true; |
| 914 MaybeActivateMojo(); |
| 915 } |
| 916 |
907 void RenderProcessHostImpl::AddRoute( | 917 void RenderProcessHostImpl::AddRoute( |
908 int32 routing_id, | 918 int32 routing_id, |
909 IPC::Listener* listener) { | 919 IPC::Listener* listener) { |
910 listeners_.AddWithID(listener, routing_id); | 920 listeners_.AddWithID(listener, routing_id); |
911 } | 921 } |
912 | 922 |
913 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { | 923 void RenderProcessHostImpl::RemoveRoute(int32 routing_id) { |
914 DCHECK(listeners_.Lookup(routing_id) != NULL); | 924 DCHECK(listeners_.Lookup(routing_id) != NULL); |
915 listeners_.Remove(routing_id); | 925 listeners_.Remove(routing_id); |
916 | 926 |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 } | 2196 } |
2187 | 2197 |
2188 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2198 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2189 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2199 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2190 DCHECK_GT(worker_ref_count_, 0); | 2200 DCHECK_GT(worker_ref_count_, 0); |
2191 --worker_ref_count_; | 2201 --worker_ref_count_; |
2192 if (worker_ref_count_ == 0) | 2202 if (worker_ref_count_ == 0) |
2193 Cleanup(); | 2203 Cleanup(); |
2194 } | 2204 } |
2195 | 2205 |
2196 void RenderProcessHostImpl::ConnectTo( | |
2197 const base::StringPiece& service_name, | |
2198 mojo::ScopedMessagePipeHandle handle) { | |
2199 mojo_activation_required_ = true; | |
2200 MaybeActivateMojo(); | |
2201 | |
2202 mojo_application_host_->service_provider()->ConnectToService( | |
2203 mojo::String::From(service_name), | |
2204 std::string(), | |
2205 handle.Pass(), | |
2206 mojo::String()); | |
2207 } | |
2208 | |
2209 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, | 2206 void RenderProcessHostImpl::OnAllocateGpuMemoryBuffer(uint32 width, |
2210 uint32 height, | 2207 uint32 height, |
2211 uint32 internalformat, | 2208 uint32 internalformat, |
2212 uint32 usage, | 2209 uint32 usage, |
2213 IPC::Message* reply) { | 2210 IPC::Message* reply) { |
2214 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2211 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2215 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || | 2212 if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || |
2216 !GpuMemoryBufferImpl::IsUsageValid(usage)) { | 2213 !GpuMemoryBufferImpl::IsUsageValid(usage)) { |
2217 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle()); | 2214 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle()); |
2218 return; | 2215 return; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2301 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2298 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
2302 IPC::Message* reply, | 2299 IPC::Message* reply, |
2303 const gfx::GpuMemoryBufferHandle& handle) { | 2300 const gfx::GpuMemoryBufferHandle& handle) { |
2304 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2301 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2305 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2302 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
2306 handle); | 2303 handle); |
2307 Send(reply); | 2304 Send(reply); |
2308 } | 2305 } |
2309 | 2306 |
2310 } // namespace content | 2307 } // namespace content |
OLD | NEW |