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 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
11 #include <objbase.h> // For CoInitialize/CoUninitialize. | 11 #include <objbase.h> // For CoInitialize/CoUninitialize. |
12 #endif | 12 #endif |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <limits> | 15 #include <limits> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #if defined(OS_POSIX) | 18 #if defined(OS_POSIX) |
19 #include <utility> // for pair<> | 19 #include <utility> // for pair<> |
20 #endif | 20 #endif |
21 | 21 |
22 #include "base/base_switches.h" | 22 #include "base/base_switches.h" |
23 #include "base/bind.h" | 23 #include "base/bind.h" |
24 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
25 #include "base/callback.h" | 25 #include "base/callback.h" |
26 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 27 #include "base/debug/trace_event.h" |
27 #include "base/lazy_instance.h" | 28 #include "base/lazy_instance.h" |
28 #include "base/logging.h" | 29 #include "base/logging.h" |
29 #include "base/metrics/field_trial.h" | 30 #include "base/metrics/field_trial.h" |
30 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
31 #include "base/path_service.h" | 32 #include "base/path_service.h" |
32 #include "base/platform_file.h" | 33 #include "base/platform_file.h" |
33 #include "base/process_util.h" | 34 #include "base/process_util.h" |
34 #include "base/rand_util.h" | 35 #include "base/rand_util.h" |
35 #include "base/stl_util.h" | 36 #include "base/stl_util.h" |
36 #include "base/string_util.h" | 37 #include "base/string_util.h" |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // Dispatch incoming messages to the appropriate RenderView/WidgetHost. | 917 // Dispatch incoming messages to the appropriate RenderView/WidgetHost. |
917 RenderWidgetHost* rwh = render_widget_hosts_.Lookup(msg.routing_id()); | 918 RenderWidgetHost* rwh = render_widget_hosts_.Lookup(msg.routing_id()); |
918 if (!rwh) { | 919 if (!rwh) { |
919 if (msg.is_sync()) { | 920 if (msg.is_sync()) { |
920 // The listener has gone away, so we must respond or else the caller will | 921 // The listener has gone away, so we must respond or else the caller will |
921 // hang waiting for a reply. | 922 // hang waiting for a reply. |
922 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 923 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
923 reply->set_reply_error(); | 924 reply->set_reply_error(); |
924 Send(reply); | 925 Send(reply); |
925 } | 926 } |
| 927 |
| 928 // If this is a SwapBuffers, we need to ack it if we're not going to handle |
| 929 // it so that the GPU process doesn't get stuck in unscheduled state. |
| 930 bool msg_is_ok = true; |
| 931 IPC_BEGIN_MESSAGE_MAP_EX(RenderProcessHostImpl, msg, msg_is_ok) |
| 932 IPC_MESSAGE_HANDLER(ViewHostMsg_CompositorSurfaceBuffersSwapped, |
| 933 OnCompositorSurfaceBuffersSwappedNoHost) |
| 934 IPC_END_MESSAGE_MAP_EX() |
926 return true; | 935 return true; |
927 } | 936 } |
928 return RenderWidgetHostImpl::From(rwh)->OnMessageReceived(msg); | 937 return RenderWidgetHostImpl::From(rwh)->OnMessageReceived(msg); |
929 } | 938 } |
930 | 939 |
931 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { | 940 void RenderProcessHostImpl::OnChannelConnected(int32 peer_pid) { |
932 #if defined(IPC_MESSAGE_LOG_ENABLED) | 941 #if defined(IPC_MESSAGE_LOG_ENABLED) |
933 Send(new ChildProcessMsg_SetIPCLoggingEnabled( | 942 Send(new ChildProcessMsg_SetIPCLoggingEnabled( |
934 IPC::Logging::GetInstance()->Enabled())); | 943 IPC::Logging::GetInstance()->Enabled())); |
935 #endif | 944 #endif |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { | 1343 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { |
1335 // Only honor the request if appropriate persmissions are granted. | 1344 // Only honor the request if appropriate persmissions are granted. |
1336 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), | 1345 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), |
1337 path)) | 1346 path)) |
1338 content::GetContentClient()->browser()->OpenItem(path); | 1347 content::GetContentClient()->browser()->OpenItem(path); |
1339 } | 1348 } |
1340 | 1349 |
1341 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 1350 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
1342 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); | 1351 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); |
1343 } | 1352 } |
| 1353 |
| 1354 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( |
| 1355 int32 surface_id, |
| 1356 uint64 surface_handle, |
| 1357 int32 route_id, |
| 1358 int32 gpu_process_host_id) { |
| 1359 TRACE_EVENT0("renderer_host", |
| 1360 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1361 RenderWidgetHostImpl::AcknowledgeSwapBuffers(route_id, |
| 1362 gpu_process_host_id); |
| 1363 } |
OLD | NEW |