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

Unified Diff: chrome/browser/browser_process_impl.cc

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browser_process_impl.cc
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 6417c8e046d6eb0001975f42885efefe22181433..d819c0eb0e9cfbfdc0343d5a56c74898ae7a61ef 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -190,8 +190,7 @@ BrowserProcessImpl::BrowserProcessImpl(
created_icon_manager_(false),
created_notification_ui_manager_(false),
created_safe_browsing_service_(false),
- module_ref_count_(0),
- did_start_(false),
+ shutting_down_(false),
tearing_down_(false),
download_status_updater_(new DownloadStatusUpdater),
local_state_task_runner_(local_state_task_runner),
@@ -362,7 +361,7 @@ void BrowserProcessImpl::PostDestroyThreads() {
}
#endif // !defined(OS_ANDROID)
-unsigned int BrowserProcessImpl::AddRefModule() {
+void BrowserProcessImpl::Pin() {
DCHECK(CalledOnValidThread());
// CHECK(!IsShuttingDown());
@@ -373,44 +372,35 @@ unsigned int BrowserProcessImpl::AddRefModule() {
base::debug::Alias(&callstack);
CHECK(false);
}
-
- did_start_ = true;
- module_ref_count_++;
- return module_ref_count_;
}
-unsigned int BrowserProcessImpl::ReleaseModule() {
+void BrowserProcessImpl::Unpin() {
DCHECK(CalledOnValidThread());
- DCHECK_NE(0u, module_ref_count_);
- module_ref_count_--;
- if (0 == module_ref_count_) {
- release_last_reference_callstack_ = base::debug::StackTrace();
+ release_last_reference_callstack_ = base::debug::StackTrace();
+ shutting_down_ = true;
#if defined(ENABLE_PRINTING)
- // Wait for the pending print jobs to finish. Don't do this later, since
- // this might cause a nested message loop to run, and we don't want pending
- // tasks to run once teardown has started.
- print_job_manager_->Shutdown();
+ // Wait for the pending print jobs to finish. Don't do this later, since
+ // this might cause a nested message loop to run, and we don't want pending
+ // tasks to run once teardown has started.
+ print_job_manager_->Shutdown();
#endif
#if defined(LEAK_SANITIZER)
- // Check for memory leaks now, before we start shutting down threads. Doing
- // this early means we won't report any shutdown-only leaks (as they have
- // not yet happened at this point).
- // If leaks are found, this will make the process exit immediately.
- __lsan_do_leak_check();
+ // Check for memory leaks now, before we start shutting down threads. Doing
+ // this early means we won't report any shutdown-only leaks (as they have
+ // not yet happened at this point).
+ // If leaks are found, this will make the process exit immediately.
+ __lsan_do_leak_check();
#endif
- CHECK(base::MessageLoop::current()->is_running());
+ CHECK(base::MessageLoop::current()->is_running());
#if defined(OS_MACOSX)
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop));
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop));
#endif
- base::MessageLoop::current()->QuitWhenIdle();
- }
- return module_ref_count_;
+ base::MessageLoop::current()->QuitWhenIdle();
}
namespace {
@@ -689,7 +679,7 @@ bool BrowserProcessImpl::IsShuttingDown() {
DCHECK(CalledOnValidThread());
// TODO(crbug.com/560486): Fix the tests that make the check of
// |tearing_down_| necessary here.
- return (did_start_ && 0 == module_ref_count_) || tearing_down_;
+ return shutting_down_ || tearing_down_;
}
printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {

Powered by Google App Engine
This is Rietveld 408576698