| 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 943 |
| 944 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { | 944 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { |
| 945 observers_.AddObserver(observer); | 945 observers_.AddObserver(observer); |
| 946 } | 946 } |
| 947 | 947 |
| 948 void RenderProcessHostImpl::RemoveObserver( | 948 void RenderProcessHostImpl::RemoveObserver( |
| 949 RenderProcessHostObserver* observer) { | 949 RenderProcessHostObserver* observer) { |
| 950 observers_.RemoveObserver(observer); | 950 observers_.RemoveObserver(observer); |
| 951 } | 951 } |
| 952 | 952 |
| 953 bool RenderProcessHostImpl::WaitForBackingStoreMsg( | |
| 954 int render_widget_id, | |
| 955 const base::TimeDelta& max_delay, | |
| 956 IPC::Message* msg) { | |
| 957 // The post task to this thread with the process id could be in queue, and we | |
| 958 // don't want to dispatch a message before then since it will need the handle. | |
| 959 if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) | |
| 960 return false; | |
| 961 | |
| 962 return widget_helper_->WaitForBackingStoreMsg(render_widget_id, | |
| 963 max_delay, msg); | |
| 964 } | |
| 965 | |
| 966 void RenderProcessHostImpl::ReceivedBadMessage() { | 953 void RenderProcessHostImpl::ReceivedBadMessage() { |
| 967 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 954 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 968 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) | 955 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) |
| 969 return; | 956 return; |
| 970 | 957 |
| 971 if (run_renderer_in_process()) { | 958 if (run_renderer_in_process()) { |
| 972 // In single process mode it is better if we don't suicide but just | 959 // In single process mode it is better if we don't suicide but just |
| 973 // crash. | 960 // crash. |
| 974 CHECK(false); | 961 CHECK(false); |
| 975 } | 962 } |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 // Dispatch incoming messages to the appropriate IPC::Listener. | 1385 // Dispatch incoming messages to the appropriate IPC::Listener. |
| 1399 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); | 1386 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); |
| 1400 if (!listener) { | 1387 if (!listener) { |
| 1401 if (msg.is_sync()) { | 1388 if (msg.is_sync()) { |
| 1402 // The listener has gone away, so we must respond or else the caller will | 1389 // The listener has gone away, so we must respond or else the caller will |
| 1403 // hang waiting for a reply. | 1390 // hang waiting for a reply. |
| 1404 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 1391 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 1405 reply->set_reply_error(); | 1392 reply->set_reply_error(); |
| 1406 Send(reply); | 1393 Send(reply); |
| 1407 } | 1394 } |
| 1408 | |
| 1409 // If this is a SwapBuffers, we need to ack it if we're not going to handle | |
| 1410 // it so that the GPU process doesn't get stuck in unscheduled state. | |
| 1411 IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg) | |
| 1412 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, | |
| 1413 OnCompositorSurfaceBuffersSwappedNoHost) | |
| 1414 IPC_END_MESSAGE_MAP() | |
| 1415 return true; | 1395 return true; |
| 1416 } | 1396 } |
| 1417 return listener->OnMessageReceived(msg); | 1397 return listener->OnMessageReceived(msg); |
| 1418 } | 1398 } |
| 1419 | 1399 |
| 1420 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { | 1400 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
| 1421 #if defined(IPC_MESSAGE_LOG_ENABLED) | 1401 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 1422 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 1402 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
| 1423 IPC::Logging::GetInstance()->Enabled())); | 1403 IPC::Logging::GetInstance()->Enabled())); |
| 1424 #endif | 1404 #endif |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 (GetUserData(kSessionStorageHolderKey)); | 2115 (GetUserData(kSessionStorageHolderKey)); |
| 2136 if (!holder) | 2116 if (!holder) |
| 2137 return; | 2117 return; |
| 2138 holder->Release(old_route_id); | 2118 holder->Release(old_route_id); |
| 2139 } | 2119 } |
| 2140 | 2120 |
| 2141 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 2121 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
| 2142 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); | 2122 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); |
| 2143 } | 2123 } |
| 2144 | 2124 |
| 2145 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( | |
| 2146 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { | |
| 2147 TRACE_EVENT0("renderer_host", | |
| 2148 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | |
| 2149 if (!ui::LatencyInfo::Verify(params.latency_info, | |
| 2150 "ViewHostMsg_CompositorSurfaceBuffersSwapped")) | |
| 2151 return; | |
| 2152 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 2153 ack_params.sync_point = 0; | |
| 2154 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, | |
| 2155 params.gpu_process_host_id, | |
| 2156 ack_params); | |
| 2157 } | |
| 2158 | |
| 2159 void RenderProcessHostImpl::OnGpuSwitching() { | 2125 void RenderProcessHostImpl::OnGpuSwitching() { |
| 2160 // We are updating all widgets including swapped out ones. | 2126 // We are updating all widgets including swapped out ones. |
| 2161 scoped_ptr<RenderWidgetHostIterator> widgets( | 2127 scoped_ptr<RenderWidgetHostIterator> widgets( |
| 2162 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); | 2128 RenderWidgetHostImpl::GetAllRenderWidgetHosts()); |
| 2163 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 2129 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 2164 if (!widget->IsRenderView()) | 2130 if (!widget->IsRenderView()) |
| 2165 continue; | 2131 continue; |
| 2166 | 2132 |
| 2167 // Skip widgets in other processes. | 2133 // Skip widgets in other processes. |
| 2168 if (widget->GetProcess()->GetID() != GetID()) | 2134 if (widget->GetProcess()->GetID() != GetID()) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2328 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
| 2363 IPC::Message* reply, | 2329 IPC::Message* reply, |
| 2364 const gfx::GpuMemoryBufferHandle& handle) { | 2330 const gfx::GpuMemoryBufferHandle& handle) { |
| 2365 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2331 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2366 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2332 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
| 2367 handle); | 2333 handle); |
| 2368 Send(reply); | 2334 Send(reply); |
| 2369 } | 2335 } |
| 2370 | 2336 |
| 2371 } // namespace content | 2337 } // namespace content |
| OLD | NEW |