Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 11314014: Don't shutdown render "process" in single process mode (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: block renderer initiated shutdowns too Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 g_all_hosts.Get().set_check_on_null_data(true); 350 g_all_hosts.Get().set_check_on_null_data(true);
351 // Initialize |child_process_activity_time_| to a reasonable value. 351 // Initialize |child_process_activity_time_| to a reasonable value.
352 mark_child_process_activity_time(); 352 mark_child_process_activity_time();
353 // Note: When we create the RenderProcessHostImpl, it's technically 353 // Note: When we create the RenderProcessHostImpl, it's technically
354 // backgrounded, because it has no visible listeners. But the process 354 // backgrounded, because it has no visible listeners. But the process
355 // doesn't actually exist yet, so we'll Background it later, after 355 // doesn't actually exist yet, so we'll Background it later, after
356 // creation. 356 // creation.
357 } 357 }
358 358
359 RenderProcessHostImpl::~RenderProcessHostImpl() { 359 RenderProcessHostImpl::~RenderProcessHostImpl() {
360 DCHECK(!run_renderer_in_process());
360 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID()); 361 ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID());
361 362
362 // We may have some unsent messages at this point, but that's OK. 363 // We may have some unsent messages at this point, but that's OK.
363 channel_.reset(); 364 channel_.reset();
364 while (!queued_messages_.empty()) { 365 while (!queued_messages_.empty()) {
365 delete queued_messages_.front(); 366 delete queued_messages_.front();
366 queued_messages_.pop(); 367 queued_messages_.pop();
367 } 368 }
368 369
369 if (run_renderer_in_process()) {
370 // In single process mode, need to set IO allowed in browser main thread
371 // before joining the renderer thread
372 base::ThreadRestrictions::ScopedAllowIO allow_io;
373 in_process_renderer_.reset();
374 }
375
376 ClearTransportDIBCache(); 370 ClearTransportDIBCache();
377 UnregisterHost(GetID()); 371 UnregisterHost(GetID());
378 } 372 }
379 373
380 void RenderProcessHostImpl::EnableSendQueue() { 374 void RenderProcessHostImpl::EnableSendQueue() {
381 is_initialized_ = false; 375 is_initialized_ = false;
382 } 376 }
383 377
384 bool RenderProcessHostImpl::Init() { 378 bool RenderProcessHostImpl::Init() {
385 // calling Init() more than once does nothing, this makes it more convenient 379 // calling Init() more than once does nothing, this makes it more convenient
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 return base::Process::Current().handle(); 863 return base::Process::Current().handle();
870 864
871 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) 865 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting())
872 return base::kNullProcessHandle; 866 return base::kNullProcessHandle;
873 867
874 return child_process_launcher_->GetHandle(); 868 return child_process_launcher_->GetHandle();
875 } 869 }
876 870
877 bool RenderProcessHostImpl::FastShutdownIfPossible() { 871 bool RenderProcessHostImpl::FastShutdownIfPossible() {
878 if (run_renderer_in_process()) 872 if (run_renderer_in_process())
879 return false; // Single process mode can't do fast shutdown. 873 return false; // Single process mode never shutdown the renderer.
880 874
881 if (!GetContentClient()->browser()->IsFastShutdownPossible()) 875 if (!GetContentClient()->browser()->IsFastShutdownPossible())
882 return false; 876 return false;
883 877
884 if (!child_process_launcher_.get() || 878 if (!child_process_launcher_.get() ||
885 child_process_launcher_->IsStarting() || 879 child_process_launcher_->IsStarting() ||
886 !GetHandle()) 880 !GetHandle())
887 return false; // Render process hasn't started or is probably crashed. 881 return false; // Render process hasn't started or is probably crashed.
888 882
889 // Test if there's an unload listener. 883 // Test if there's an unload listener.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 *CommandLine::ForCurrentProcess(); 1120 *CommandLine::ForCurrentProcess();
1127 if (browser_command_line.HasSwitch(switches::kAuditHandles) || 1121 if (browser_command_line.HasSwitch(switches::kAuditHandles) ||
1128 browser_command_line.HasSwitch(switches::kAuditAllHandles)) { 1122 browser_command_line.HasSwitch(switches::kAuditAllHandles)) {
1129 DumpHandles(); 1123 DumpHandles();
1130 1124
1131 // We wait to close the channels until the child process has finished 1125 // We wait to close the channels until the child process has finished
1132 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone. 1126 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone.
1133 return; 1127 return;
1134 } 1128 }
1135 #endif 1129 #endif
1136 Cleanup(); 1130 // Keep the one renderer thread around forever in single process mode.
Jeffrey Yasskin 2012/12/14 22:10:51 I'm now seeing a DCHECK-failure when running `xvfb
joth 2012/12/14 22:34:12 Good question. Most of the logic in the DestroyPro
1131 if (!run_renderer_in_process())
1132 Cleanup();
1137 } 1133 }
1138 1134
1139 void RenderProcessHostImpl::Cleanup() { 1135 void RenderProcessHostImpl::Cleanup() {
1140 // When no other owners of this object, we can delete ourselves 1136 // When no other owners of this object, we can delete ourselves
1141 if (render_widget_hosts_.IsEmpty()) { 1137 if (render_widget_hosts_.IsEmpty()) {
1142 DCHECK_EQ(0, pending_views_); 1138 DCHECK_EQ(0, pending_views_);
1143 NotificationService::current()->Notify( 1139 NotificationService::current()->Notify(
1144 NOTIFICATION_RENDERER_PROCESS_TERMINATED, 1140 NOTIFICATION_RENDERER_PROCESS_TERMINATED,
1145 Source<RenderProcessHost>(this), 1141 Source<RenderProcessHost>(this),
1146 NotificationService::NoDetails()); 1142 NotificationService::NoDetails());
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); 1475 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
1480 if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) 1476 if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out())
1481 num_active_views++; 1477 num_active_views++;
1482 } 1478 }
1483 return num_active_views; 1479 return num_active_views;
1484 } 1480 }
1485 1481
1486 void RenderProcessHostImpl::OnShutdownRequest() { 1482 void RenderProcessHostImpl::OnShutdownRequest() {
1487 // Don't shut down if there are more active RenderViews than the one asking 1483 // Don't shut down if there are more active RenderViews than the one asking
1488 // to close, or if there are pending RenderViews being swapped back in. 1484 // to close, or if there are pending RenderViews being swapped back in.
1485 // In single process mode, we never shutdown the renderer.
1489 int num_active_views = GetActiveViewCount(); 1486 int num_active_views = GetActiveViewCount();
1490 if (pending_views_ || num_active_views > 1) 1487 if (pending_views_ || num_active_views > 1 || run_renderer_in_process())
joth 2012/11/29 23:00:24 I did consider doing this check in render process
1491 return; 1488 return;
1492 1489
1493 // Notify any contents that might have swapped out renderers from this 1490 // Notify any contents that might have swapped out renderers from this
1494 // process. They should not attempt to swap them back in. 1491 // process. They should not attempt to swap them back in.
1495 NotificationService::current()->Notify( 1492 NotificationService::current()->Notify(
1496 NOTIFICATION_RENDERER_PROCESS_CLOSING, 1493 NOTIFICATION_RENDERER_PROCESS_CLOSING,
1497 Source<RenderProcessHost>(this), 1494 Source<RenderProcessHost>(this),
1498 NotificationService::NoDetails()); 1495 NotificationService::NoDetails());
1499 1496
1500 Send(new ChildProcessMsg_Shutdown()); 1497 Send(new ChildProcessMsg_Shutdown());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 int32 gpu_process_host_id) { 1579 int32 gpu_process_host_id) {
1583 TRACE_EVENT0("renderer_host", 1580 TRACE_EVENT0("renderer_host",
1584 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); 1581 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost");
1585 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, 1582 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id,
1586 gpu_process_host_id, 1583 gpu_process_host_id,
1587 false, 1584 false,
1588 0); 1585 0);
1589 } 1586 }
1590 1587
1591 } // namespace content 1588 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698