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

Unified Diff: chrome/test/base/testing_browser_process.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/test/base/testing_browser_process.cc
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 4f2cd474d7245346e43f11049370bd633dae2ca1..b01fb815e1f1ca0dacdadaf6c22b661b4760ed23 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -10,6 +10,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_impl.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -62,7 +63,7 @@ void TestingBrowserProcess::DeleteInstance() {
TestingBrowserProcess::TestingBrowserProcess()
: notification_service_(content::NotificationService::Create()),
- module_ref_count_(0),
+ is_pinned_(false),
app_locale_("en"),
local_state_(nullptr),
io_thread_(nullptr),
@@ -234,13 +235,18 @@ void TestingBrowserProcess::CreateDevToolsHttpProtocolHandler(
void TestingBrowserProcess::CreateDevToolsAutoOpener() {
}
-unsigned int TestingBrowserProcess::AddRefModule() {
- return ++module_ref_count_;
+void TestingBrowserProcess::Pin() {
+ is_pinned_ = true;
}
-unsigned int TestingBrowserProcess::ReleaseModule() {
- DCHECK_GT(module_ref_count_, 0U);
- return --module_ref_count_;
+void TestingBrowserProcess::Unpin() {
+ is_pinned_ = false;
+
+#if !defined(OS_ANDROID)
+ // Don't allow the browser to be closed because the shutdown procedure will
+ // attempt to access objects that we haven't created (e.g., MessageCenter).
+ chrome::DisableShutdownForTesting(true);
+#endif // !defined(OS_ANDROID)
}
bool TestingBrowserProcess::IsShuttingDown() {
« chrome/browser/lifetime/keep_alive_registry.h ('K') | « chrome/test/base/testing_browser_process.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698