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

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

Issue 857213003: Refactor sudden termination (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Charlie's comments Created 5 years, 11 months 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
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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 is_self_deleted_(false), 444 is_self_deleted_(false),
445 #endif 445 #endif
446 pending_views_(0), 446 pending_views_(0),
447 mojo_application_host_(new MojoApplicationHost), 447 mojo_application_host_(new MojoApplicationHost),
448 visible_widgets_(0), 448 visible_widgets_(0),
449 backgrounded_(true), 449 backgrounded_(true),
450 is_initialized_(false), 450 is_initialized_(false),
451 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 451 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
452 browser_context_(browser_context), 452 browser_context_(browser_context),
453 storage_partition_impl_(storage_partition_impl), 453 storage_partition_impl_(storage_partition_impl),
454 sudden_termination_allowed_(true), 454 sudden_termination_enabled_(true),
455 ignore_input_events_(false), 455 ignore_input_events_(false),
456 is_isolated_guest_(is_isolated_guest), 456 is_isolated_guest_(is_isolated_guest),
457 gpu_observer_registered_(false), 457 gpu_observer_registered_(false),
458 delayed_cleanup_needed_(false), 458 delayed_cleanup_needed_(false),
459 within_process_died_observer_(false), 459 within_process_died_observer_(false),
460 power_monitor_broadcaster_(this), 460 power_monitor_broadcaster_(this),
461 worker_ref_count_(0), 461 worker_ref_count_(0),
462 permission_service_context_(new PermissionServiceContext(this)), 462 permission_service_context_(new PermissionServiceContext(this)),
463 pending_valuebuffer_state_(new gpu::ValueStateMap()), 463 pending_valuebuffer_state_(new gpu::ValueStateMap()),
464 subscribe_uniform_enabled_(false), 464 subscribe_uniform_enabled_(false),
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 if (!child_process_launcher_.get() || 1419 if (!child_process_launcher_.get() ||
1420 child_process_launcher_->IsStarting() || 1420 child_process_launcher_->IsStarting() ||
1421 !GetHandle()) 1421 !GetHandle())
1422 return false; // Render process hasn't started or is probably crashed. 1422 return false; // Render process hasn't started or is probably crashed.
1423 1423
1424 // Test if there's an unload listener. 1424 // Test if there's an unload listener.
1425 // NOTE: It's possible that an onunload listener may be installed 1425 // NOTE: It's possible that an onunload listener may be installed
1426 // while we're shutting down, so there's a small race here. Given that 1426 // while we're shutting down, so there's a small race here. Given that
1427 // the window is small, it's unlikely that the web page has much 1427 // the window is small, it's unlikely that the web page has much
1428 // state that will be lost by not calling its unload handlers properly. 1428 // state that will be lost by not calling its unload handlers properly.
1429 if (!SuddenTerminationAllowed()) 1429 if (!SuddenTerminationAllowed())
Charlie Reis 2015/01/29 23:20:41 This confused me at first, but I think I follow it
clamy 2015/02/02 16:16:27 As I explained in the other comment, I was planing
Charlie Reis 2015/02/02 20:14:50 I think tracking the handlers twice is fine. It's
clamy 2015/02/03 12:54:02 Acknowledged.
1430 return false; 1430 return false;
1431 1431
1432 if (worker_ref_count_ != 0) { 1432 if (worker_ref_count_ != 0) {
1433 if (survive_for_worker_start_time_.is_null()) 1433 if (survive_for_worker_start_time_.is_null())
1434 survive_for_worker_start_time_ = base::TimeTicks::Now(); 1434 survive_for_worker_start_time_ = base::TimeTicks::Now();
1435 return false; 1435 return false;
1436 } 1436 }
1437 1437
1438 // Set this before ProcessDied() so observers can tell if the render process 1438 // Set this before ProcessDied() so observers can tell if the render process
1439 // died due to fast shutdown versus another cause. 1439 // died due to fast shutdown versus another cause.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 1480
1481 mark_child_process_activity_time(); 1481 mark_child_process_activity_time();
1482 if (msg.routing_id() == MSG_ROUTING_CONTROL) { 1482 if (msg.routing_id() == MSG_ROUTING_CONTROL) {
1483 // Dispatch control messages. 1483 // Dispatch control messages.
1484 IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg) 1484 IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg)
1485 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 1485 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
1486 OnShutdownRequest) 1486 OnShutdownRequest)
1487 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, 1487 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone,
1488 OnDumpHandlesDone) 1488 OnDumpHandlesDone)
1489 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, 1489 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged,
1490 SuddenTerminationChanged) 1490 OnSuddenTerminationChanged)
1491 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, 1491 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
1492 OnUserMetricsRecordAction) 1492 OnUserMetricsRecordAction)
1493 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) 1493 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML)
1494 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) 1494 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
1495 #if defined(ENABLE_WEBRTC) 1495 #if defined(ENABLE_WEBRTC)
1496 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, 1496 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
1497 OnRegisterAecDumpConsumer) 1497 OnRegisterAecDumpConsumer)
1498 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, 1498 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer,
1499 OnUnregisterAecDumpConsumer) 1499 OnUnregisterAecDumpConsumer)
1500 #endif 1500 #endif
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 1637
1638 void RenderProcessHostImpl::AddPendingView() { 1638 void RenderProcessHostImpl::AddPendingView() {
1639 pending_views_++; 1639 pending_views_++;
1640 } 1640 }
1641 1641
1642 void RenderProcessHostImpl::RemovePendingView() { 1642 void RenderProcessHostImpl::RemovePendingView() {
1643 DCHECK(pending_views_); 1643 DCHECK(pending_views_);
1644 pending_views_--; 1644 pending_views_--;
1645 } 1645 }
1646 1646
1647 void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) {
1648 sudden_termination_allowed_ = enabled;
1649 }
1650
1651 bool RenderProcessHostImpl::SuddenTerminationAllowed() const { 1647 bool RenderProcessHostImpl::SuddenTerminationAllowed() const {
1652 return sudden_termination_allowed_; 1648 return sudden_termination_enabled_;
1653 } 1649 }
1654 1650
1655 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { 1651 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const {
1656 return base::TimeTicks::Now() - child_process_activity_time_; 1652 return base::TimeTicks::Now() - child_process_activity_time_;
1657 } 1653 }
1658 1654
1659 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { 1655 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) {
1660 widget_helper_->ResumeRequestsForView(route_id); 1656 widget_helper_->ResumeRequestsForView(route_id);
1661 } 1657 }
1662 1658
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 NotificationService::current()->Notify( 2139 NotificationService::current()->Notify(
2144 NOTIFICATION_RENDERER_PROCESS_CLOSING, 2140 NOTIFICATION_RENDERER_PROCESS_CLOSING,
2145 Source<RenderProcessHost>(this), 2141 Source<RenderProcessHost>(this),
2146 NotificationService::NoDetails()); 2142 NotificationService::NoDetails());
2147 2143
2148 mojo_application_host_->WillDestroySoon(); 2144 mojo_application_host_->WillDestroySoon();
2149 2145
2150 Send(new ChildProcessMsg_Shutdown()); 2146 Send(new ChildProcessMsg_Shutdown());
2151 } 2147 }
2152 2148
2153 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { 2149 void RenderProcessHostImpl::OnSuddenTerminationChanged(bool enabled) {
2154 SetSuddenTerminationAllowed(enabled); 2150 sudden_termination_enabled_ = enabled;
2155 } 2151 }
2156 2152
2157 void RenderProcessHostImpl::OnDumpHandlesDone() { 2153 void RenderProcessHostImpl::OnDumpHandlesDone() {
2158 Cleanup(); 2154 Cleanup();
2159 } 2155 }
2160 2156
2161 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) { 2157 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) {
2162 // Note: we always set the backgrounded_ value. If the process is NULL 2158 // Note: we always set the backgrounded_ value. If the process is NULL
2163 // (and hence hasn't been created yet), we will set the process priority 2159 // (and hence hasn't been created yet), we will set the process priority
2164 // later when we create the process. 2160 // later when we create the process.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 2356
2361 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2357 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2362 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2358 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2363 DCHECK_GT(worker_ref_count_, 0); 2359 DCHECK_GT(worker_ref_count_, 0);
2364 --worker_ref_count_; 2360 --worker_ref_count_;
2365 if (worker_ref_count_ == 0) 2361 if (worker_ref_count_ == 0)
2366 Cleanup(); 2362 Cleanup();
2367 } 2363 }
2368 2364
2369 } // namespace content 2365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698