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

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

Issue 176843004: Add IncrementWorkerRefCount() and DecrementWorkerRefCount() to RenderProcessHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 6 years, 9 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
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // static 366 // static
367 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { 367 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
368 g_max_renderer_count_override = count; 368 g_max_renderer_count_override = count;
369 } 369 }
370 370
371 RenderProcessHostImpl::RenderProcessHostImpl( 371 RenderProcessHostImpl::RenderProcessHostImpl(
372 BrowserContext* browser_context, 372 BrowserContext* browser_context,
373 StoragePartitionImpl* storage_partition_impl, 373 StoragePartitionImpl* storage_partition_impl,
374 bool supports_browser_plugin, 374 bool supports_browser_plugin,
375 bool is_guest) 375 bool is_guest)
376 : fast_shutdown_started_(false), 376 : fast_shutdown_started_(false),
377 deleting_soon_(false), 377 deleting_soon_(false),
378 #ifndef NDEBUG 378 #ifndef NDEBUG
379 is_self_deleted_(false), 379 is_self_deleted_(false),
380 #endif 380 #endif
381 pending_views_(0), 381 pending_views_(0),
382 visible_widgets_(0), 382 visible_widgets_(0),
383 backgrounded_(true), 383 backgrounded_(true),
384 cached_dibs_cleaner_( 384 cached_dibs_cleaner_(FROM_HERE,
385 FROM_HERE, base::TimeDelta::FromSeconds(5), 385 base::TimeDelta::FromSeconds(5),
386 this, &RenderProcessHostImpl::ClearTransportDIBCache), 386 this,
387 is_initialized_(false), 387 &RenderProcessHostImpl::ClearTransportDIBCache),
388 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 388 is_initialized_(false),
389 browser_context_(browser_context), 389 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
390 storage_partition_impl_(storage_partition_impl), 390 browser_context_(browser_context),
391 sudden_termination_allowed_(true), 391 storage_partition_impl_(storage_partition_impl),
392 ignore_input_events_(false), 392 sudden_termination_allowed_(true),
393 supports_browser_plugin_(supports_browser_plugin), 393 ignore_input_events_(false),
394 is_guest_(is_guest), 394 supports_browser_plugin_(supports_browser_plugin),
395 gpu_observer_registered_(false), 395 is_guest_(is_guest),
396 delayed_cleanup_needed_(false), 396 gpu_observer_registered_(false),
397 within_process_died_observer_(false), 397 delayed_cleanup_needed_(false),
398 power_monitor_broadcaster_(this), 398 within_process_died_observer_(false),
399 geolocation_dispatcher_host_(NULL), 399 power_monitor_broadcaster_(this),
400 weak_factory_(this), 400 geolocation_dispatcher_host_(NULL),
401 screen_orientation_dispatcher_host_(NULL) { 401 weak_factory_(this),
402 screen_orientation_dispatcher_host_(NULL),
403 worker_ref_count_(0) {
402 widget_helper_ = new RenderWidgetHelper(); 404 widget_helper_ = new RenderWidgetHelper();
403 405
404 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID()); 406 ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
405 407
406 CHECK(!g_exited_main_message_loop); 408 CHECK(!g_exited_main_message_loop);
407 RegisterHost(GetID(), this); 409 RegisterHost(GetID(), this);
408 g_all_hosts.Get().set_check_on_null_data(true); 410 g_all_hosts.Get().set_check_on_null_data(true);
409 // Initialize |child_process_activity_time_| to a reasonable value. 411 // Initialize |child_process_activity_time_| to a reasonable value.
410 mark_child_process_activity_time(); 412 mark_child_process_activity_time();
411 413
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return false; // Render process hasn't started or is probably crashed. 1222 return false; // Render process hasn't started or is probably crashed.
1221 1223
1222 // Test if there's an unload listener. 1224 // Test if there's an unload listener.
1223 // NOTE: It's possible that an onunload listener may be installed 1225 // NOTE: It's possible that an onunload listener may be installed
1224 // while we're shutting down, so there's a small race here. Given that 1226 // while we're shutting down, so there's a small race here. Given that
1225 // the window is small, it's unlikely that the web page has much 1227 // the window is small, it's unlikely that the web page has much
1226 // state that will be lost by not calling its unload handlers properly. 1228 // state that will be lost by not calling its unload handlers properly.
1227 if (!SuddenTerminationAllowed()) 1229 if (!SuddenTerminationAllowed())
1228 return false; 1230 return false;
1229 1231
1232 if (worker_ref_count_ != 0)
1233 return false;
1234
1230 // Set this before ProcessDied() so observers can tell if the render process 1235 // Set this before ProcessDied() so observers can tell if the render process
1231 // died due to fast shutdown versus another cause. 1236 // died due to fast shutdown versus another cause.
1232 fast_shutdown_started_ = true; 1237 fast_shutdown_started_ = true;
1233 1238
1234 ProcessDied(false /* already_dead */); 1239 ProcessDied(false /* already_dead */);
1235 return true; 1240 return true;
1236 } 1241 }
1237 1242
1238 void RenderProcessHostImpl::DumpHandles() { 1243 void RenderProcessHostImpl::DumpHandles() {
1239 #if defined(OS_WIN) 1244 #if defined(OS_WIN)
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // delay the destruction until all of the observer callbacks have been made, 1450 // delay the destruction until all of the observer callbacks have been made,
1446 // and guarantee that the RenderProcessHostDestroyed observer callback is 1451 // and guarantee that the RenderProcessHostDestroyed observer callback is
1447 // always the last callback fired. 1452 // always the last callback fired.
1448 if (within_process_died_observer_) { 1453 if (within_process_died_observer_) {
1449 delayed_cleanup_needed_ = true; 1454 delayed_cleanup_needed_ = true;
1450 return; 1455 return;
1451 } 1456 }
1452 delayed_cleanup_needed_ = false; 1457 delayed_cleanup_needed_ = false;
1453 1458
1454 // When there are no other owners of this object, we can delete ourselves. 1459 // When there are no other owners of this object, we can delete ourselves.
1455 if (listeners_.IsEmpty()) { 1460 if (listeners_.IsEmpty() && worker_ref_count_ == 0) {
1456 // We cannot clean up twice; if this fails, there is an issue with our 1461 // We cannot clean up twice; if this fails, there is an issue with our
1457 // control flow. 1462 // control flow.
1458 DCHECK(!deleting_soon_); 1463 DCHECK(!deleting_soon_);
1459 1464
1460 DCHECK_EQ(0, pending_views_); 1465 DCHECK_EQ(0, pending_views_);
1461 FOR_EACH_OBSERVER(RenderProcessHostObserver, 1466 FOR_EACH_OBSERVER(RenderProcessHostObserver,
1462 observers_, 1467 observers_,
1463 RenderProcessHostDestroyed(this)); 1468 RenderProcessHostDestroyed(this));
1464 NotificationService::current()->Notify( 1469 NotificationService::current()->Notify(
1465 NOTIFICATION_RENDERER_PROCESS_TERMINATED, 1470 NOTIFICATION_RENDERER_PROCESS_TERMINATED,
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) 2081 if (file_for_transit == IPC::InvalidPlatformFileForTransit())
2077 return; 2082 return;
2078 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); 2083 Send(new MediaStreamMsg_EnableAecDump(file_for_transit));
2079 } 2084 }
2080 2085
2081 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { 2086 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() {
2082 Send(new MediaStreamMsg_DisableAecDump()); 2087 Send(new MediaStreamMsg_DisableAecDump());
2083 } 2088 }
2084 #endif 2089 #endif
2085 2090
2091 void RenderProcessHostImpl::IncrementWorkerRefCount() {
2092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2093 ++worker_ref_count_;
2094 }
2095
2096 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2097 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2098 DCHECK_GT(worker_ref_count_, 0);
2099 --worker_ref_count_;
2100 if (worker_ref_count_ == 0)
2101 Cleanup();
2102 }
2103
2086 } // namespace content 2104 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698