| 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) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 #include "third_party/skia/include/core/SkBitmap.h" | 122 #include "third_party/skia/include/core/SkBitmap.h" |
| 123 | 123 |
| 124 using content::BrowserContext; | 124 using content::BrowserContext; |
| 125 using content::BrowserMessageFilter; | 125 using content::BrowserMessageFilter; |
| 126 using content::BrowserThread; | 126 using content::BrowserThread; |
| 127 using content::ChildProcessHost; | 127 using content::ChildProcessHost; |
| 128 using content::ChildProcessHostImpl; | 128 using content::ChildProcessHostImpl; |
| 129 using content::RenderWidgetHost; | 129 using content::RenderWidgetHost; |
| 130 using content::RenderWidgetHostImpl; | 130 using content::RenderWidgetHostImpl; |
| 131 using content::RenderViewHost; |
| 132 using content::RenderViewHostImpl; |
| 131 using content::UserMetricsAction; | 133 using content::UserMetricsAction; |
| 132 using content::WebUIControllerFactory; | 134 using content::WebUIControllerFactory; |
| 133 | 135 |
| 134 extern bool g_exited_main_message_loop; | 136 extern bool g_exited_main_message_loop; |
| 135 | 137 |
| 136 // This class creates the IO thread for the renderer when running in | 138 // This class creates the IO thread for the renderer when running in |
| 137 // single-process mode. It's not used in multi-process mode. | 139 // single-process mode. It's not used in multi-process mode. |
| 138 class RendererMainThread : public base::Thread { | 140 class RendererMainThread : public base::Thread { |
| 139 public: | 141 public: |
| 140 explicit RendererMainThread(const std::string& channel_id) | 142 explicit RendererMainThread(const std::string& channel_id) |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 iter.Advance(); | 1252 iter.Advance(); |
| 1251 } | 1253 } |
| 1252 | 1254 |
| 1253 ClearTransportDIBCache(); | 1255 ClearTransportDIBCache(); |
| 1254 | 1256 |
| 1255 // this object is not deleted at this point and may be reused later. | 1257 // this object is not deleted at this point and may be reused later. |
| 1256 // TODO(darin): clean this up | 1258 // TODO(darin): clean this up |
| 1257 } | 1259 } |
| 1258 | 1260 |
| 1259 void RenderProcessHostImpl::OnShutdownRequest() { | 1261 void RenderProcessHostImpl::OnShutdownRequest() { |
| 1260 // Don't shut down if there are more RenderViews than the one asking to | 1262 // Don't shut down if there are more active RenderViews than the one asking |
| 1261 // close, or if there are pending RenderViews being swapped back in. | 1263 // to close, or if there are pending RenderViews being swapped back in. |
| 1262 if (pending_views_ || render_widget_hosts_.size() > 1) | 1264 int num_active_views = 0; |
| 1265 for (RenderWidgetHostsIterator iter = GetRenderWidgetHostsIterator(); |
| 1266 iter.IsAtEnd(); |
| 1267 iter.Advance()) { |
| 1268 const RenderWidgetHost* widget = iter.GetCurrentValue(); |
| 1269 DCHECK(widget); |
| 1270 if (!widget) |
| 1271 continue; |
| 1272 |
| 1273 // All RenderWidgetHosts are swapped in. |
| 1274 if (!widget->IsRenderView()) { |
| 1275 num_active_views++; |
| 1276 continue; |
| 1277 } |
| 1278 |
| 1279 // Don't count swapped out views. |
| 1280 RenderViewHost* rvh = |
| 1281 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
| 1282 if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) |
| 1283 num_active_views++; |
| 1284 } |
| 1285 if (pending_views_ || num_active_views > 1) |
| 1263 return; | 1286 return; |
| 1264 | 1287 |
| 1265 // Notify any contents that might have swapped out renderers from this | 1288 // Notify any contents that might have swapped out renderers from this |
| 1266 // process. They should not attempt to swap them back in. | 1289 // process. They should not attempt to swap them back in. |
| 1267 content::NotificationService::current()->Notify( | 1290 content::NotificationService::current()->Notify( |
| 1268 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 1291 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 1269 content::Source<RenderProcessHost>(this), | 1292 content::Source<RenderProcessHost>(this), |
| 1270 content::NotificationService::NoDetails()); | 1293 content::NotificationService::NoDetails()); |
| 1271 | 1294 |
| 1272 Send(new ChildProcessMsg_Shutdown()); | 1295 Send(new ChildProcessMsg_Shutdown()); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( | 1379 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( |
| 1357 int32 surface_id, | 1380 int32 surface_id, |
| 1358 uint64 surface_handle, | 1381 uint64 surface_handle, |
| 1359 int32 route_id, | 1382 int32 route_id, |
| 1360 int32 gpu_process_host_id) { | 1383 int32 gpu_process_host_id) { |
| 1361 TRACE_EVENT0("renderer_host", | 1384 TRACE_EVENT0("renderer_host", |
| 1362 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1385 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1363 RenderWidgetHostImpl::AcknowledgeSwapBuffers(route_id, | 1386 RenderWidgetHostImpl::AcknowledgeSwapBuffers(route_id, |
| 1364 gpu_process_host_id); | 1387 gpu_process_host_id); |
| 1365 } | 1388 } |
| OLD | NEW |