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

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: 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_disallows_(0),
455 sudden_termination_enabled_(true),
455 ignore_input_events_(false), 456 ignore_input_events_(false),
456 is_isolated_guest_(is_isolated_guest), 457 is_isolated_guest_(is_isolated_guest),
457 gpu_observer_registered_(false), 458 gpu_observer_registered_(false),
458 delayed_cleanup_needed_(false), 459 delayed_cleanup_needed_(false),
459 within_process_died_observer_(false), 460 within_process_died_observer_(false),
460 power_monitor_broadcaster_(this), 461 power_monitor_broadcaster_(this),
461 worker_ref_count_(0), 462 worker_ref_count_(0),
462 permission_service_context_(new PermissionServiceContext(this)), 463 permission_service_context_(new PermissionServiceContext(this)),
463 pending_valuebuffer_state_(new gpu::ValueStateMap()), 464 pending_valuebuffer_state_(new gpu::ValueStateMap()),
464 subscribe_uniform_enabled_(false), 465 subscribe_uniform_enabled_(false),
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 1480
1480 mark_child_process_activity_time(); 1481 mark_child_process_activity_time();
1481 if (msg.routing_id() == MSG_ROUTING_CONTROL) { 1482 if (msg.routing_id() == MSG_ROUTING_CONTROL) {
1482 // Dispatch control messages. 1483 // Dispatch control messages.
1483 IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg) 1484 IPC_BEGIN_MESSAGE_MAP(RenderProcessHostImpl, msg)
1484 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest, 1485 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ShutdownRequest,
1485 OnShutdownRequest) 1486 OnShutdownRequest)
1486 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, 1487 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone,
1487 OnDumpHandlesDone) 1488 OnDumpHandlesDone)
1488 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, 1489 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged,
1489 SuddenTerminationChanged) 1490 OnSuddenTerminationChanged)
1490 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, 1491 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
1491 OnUserMetricsRecordAction) 1492 OnUserMetricsRecordAction)
1492 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) 1493 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML)
1493 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) 1494 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
1494 #if defined(ENABLE_WEBRTC) 1495 #if defined(ENABLE_WEBRTC)
1495 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, 1496 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer,
1496 OnRegisterAecDumpConsumer) 1497 OnRegisterAecDumpConsumer)
1497 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, 1498 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer,
1498 OnUnregisterAecDumpConsumer) 1499 OnUnregisterAecDumpConsumer)
1499 #endif 1500 #endif
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1637
1637 void RenderProcessHostImpl::AddPendingView() { 1638 void RenderProcessHostImpl::AddPendingView() {
1638 pending_views_++; 1639 pending_views_++;
1639 } 1640 }
1640 1641
1641 void RenderProcessHostImpl::RemovePendingView() { 1642 void RenderProcessHostImpl::RemovePendingView() {
1642 DCHECK(pending_views_); 1643 DCHECK(pending_views_);
1643 pending_views_--; 1644 pending_views_--;
1644 } 1645 }
1645 1646
1646 void RenderProcessHostImpl::SetSuddenTerminationAllowed(bool enabled) { 1647 void RenderProcessHostImpl::SuddenTerminationChangedForFrame(bool allowed) {
1647 sudden_termination_allowed_ = enabled; 1648 if (allowed)
1649 --sudden_termination_disallows_;
1650 else
1651 ++sudden_termination_disallows_;
1652 DCHECK(sudden_termination_disallows_ >= 0);
1648 } 1653 }
1649 1654
1650 bool RenderProcessHostImpl::SuddenTerminationAllowed() const { 1655 bool RenderProcessHostImpl::SuddenTerminationAllowed() const {
1651 return sudden_termination_allowed_; 1656 return sudden_termination_disallows_ == 0 && sudden_termination_enabled_;
1652 } 1657 }
1653 1658
1654 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const { 1659 base::TimeDelta RenderProcessHostImpl::GetChildProcessIdleTime() const {
1655 return base::TimeTicks::Now() - child_process_activity_time_; 1660 return base::TimeTicks::Now() - child_process_activity_time_;
1656 } 1661 }
1657 1662
1658 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) { 1663 void RenderProcessHostImpl::ResumeRequestsForView(int route_id) {
1659 widget_helper_->ResumeRequestsForView(route_id); 1664 widget_helper_->ResumeRequestsForView(route_id);
1660 } 1665 }
1661 1666
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 NotificationService::current()->Notify( 2147 NotificationService::current()->Notify(
2143 NOTIFICATION_RENDERER_PROCESS_CLOSING, 2148 NOTIFICATION_RENDERER_PROCESS_CLOSING,
2144 Source<RenderProcessHost>(this), 2149 Source<RenderProcessHost>(this),
2145 NotificationService::NoDetails()); 2150 NotificationService::NoDetails());
2146 2151
2147 mojo_application_host_->WillDestroySoon(); 2152 mojo_application_host_->WillDestroySoon();
2148 2153
2149 Send(new ChildProcessMsg_Shutdown()); 2154 Send(new ChildProcessMsg_Shutdown());
2150 } 2155 }
2151 2156
2152 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { 2157 void RenderProcessHostImpl::OnSuddenTerminationChanged(bool enabled) {
2153 SetSuddenTerminationAllowed(enabled); 2158 sudden_termination_enabled_ = enabled;
2154 } 2159 }
2155 2160
2156 void RenderProcessHostImpl::OnDumpHandlesDone() { 2161 void RenderProcessHostImpl::OnDumpHandlesDone() {
2157 Cleanup(); 2162 Cleanup();
2158 } 2163 }
2159 2164
2160 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) { 2165 void RenderProcessHostImpl::SetBackgrounded(bool backgrounded) {
2161 // Note: we always set the backgrounded_ value. If the process is NULL 2166 // Note: we always set the backgrounded_ value. If the process is NULL
2162 // (and hence hasn't been created yet), we will set the process priority 2167 // (and hence hasn't been created yet), we will set the process priority
2163 // later when we create the process. 2168 // later when we create the process.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 2364
2360 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2365 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2361 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2366 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2362 DCHECK_GT(worker_ref_count_, 0); 2367 DCHECK_GT(worker_ref_count_, 0);
2363 --worker_ref_count_; 2368 --worker_ref_count_;
2364 if (worker_ref_count_ == 0) 2369 if (worker_ref_count_ == 0)
2365 Cleanup(); 2370 Cleanup();
2366 } 2371 }
2367 2372
2368 } // namespace content 2373 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698