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

Side by Side 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 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 #include "chrome/test/base/testing_browser_process.h" 5 #include "chrome/test/base/testing_browser_process.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/time/default_clock.h" 8 #include "base/time/default_clock.h"
9 #include "base/time/default_tick_clock.h" 9 #include "base/time/default_tick_clock.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_process_impl.h" 12 #include "chrome/browser/browser_process_impl.h"
13 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h" 14 #include "chrome/browser/notifications/notification_ui_manager.h"
14 #include "chrome/browser/printing/print_job_manager.h" 15 #include "chrome/browser/printing/print_job_manager.h"
15 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 17 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
17 #include "chrome/common/features.h" 18 #include "chrome/common/features.h"
18 #include "chrome/test/base/testing_browser_process_platform_part.h" 19 #include "chrome/test/base/testing_browser_process_platform_part.h"
19 #include "components/network_time/network_time_tracker.h" 20 #include "components/network_time/network_time_tracker.h"
20 #include "components/policy/core/browser/browser_policy_connector.h" 21 #include "components/policy/core/browser/browser_policy_connector.h"
21 #include "components/prefs/pref_service.h" 22 #include "components/prefs/pref_service.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // static 56 // static
56 void TestingBrowserProcess::DeleteInstance() { 57 void TestingBrowserProcess::DeleteInstance() {
57 // g_browser_process must be null during its own destruction. 58 // g_browser_process must be null during its own destruction.
58 BrowserProcess* browser_process = g_browser_process; 59 BrowserProcess* browser_process = g_browser_process;
59 g_browser_process = nullptr; 60 g_browser_process = nullptr;
60 delete browser_process; 61 delete browser_process;
61 } 62 }
62 63
63 TestingBrowserProcess::TestingBrowserProcess() 64 TestingBrowserProcess::TestingBrowserProcess()
64 : notification_service_(content::NotificationService::Create()), 65 : notification_service_(content::NotificationService::Create()),
65 module_ref_count_(0), 66 is_pinned_(false),
66 app_locale_("en"), 67 app_locale_("en"),
67 local_state_(nullptr), 68 local_state_(nullptr),
68 io_thread_(nullptr), 69 io_thread_(nullptr),
69 system_request_context_(nullptr), 70 system_request_context_(nullptr),
70 rappor_service_(nullptr), 71 rappor_service_(nullptr),
71 platform_part_(new TestingBrowserProcessPlatformPart()) { 72 platform_part_(new TestingBrowserProcessPlatformPart()) {
72 #if defined(ENABLE_EXTENSIONS) 73 #if defined(ENABLE_EXTENSIONS)
73 extensions_browser_client_.reset( 74 extensions_browser_client_.reset(
74 new extensions::ChromeExtensionsBrowserClient); 75 new extensions::ChromeExtensionsBrowserClient);
75 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance()); 76 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 228 }
228 229
229 void TestingBrowserProcess::CreateDevToolsHttpProtocolHandler( 230 void TestingBrowserProcess::CreateDevToolsHttpProtocolHandler(
230 const std::string& ip, 231 const std::string& ip,
231 uint16_t port) { 232 uint16_t port) {
232 } 233 }
233 234
234 void TestingBrowserProcess::CreateDevToolsAutoOpener() { 235 void TestingBrowserProcess::CreateDevToolsAutoOpener() {
235 } 236 }
236 237
237 unsigned int TestingBrowserProcess::AddRefModule() { 238 void TestingBrowserProcess::Pin() {
238 return ++module_ref_count_; 239 is_pinned_ = true;
239 } 240 }
240 241
241 unsigned int TestingBrowserProcess::ReleaseModule() { 242 void TestingBrowserProcess::Unpin() {
242 DCHECK_GT(module_ref_count_, 0U); 243 is_pinned_ = false;
243 return --module_ref_count_; 244
245 #if !defined(OS_ANDROID)
246 // Don't allow the browser to be closed because the shutdown procedure will
247 // attempt to access objects that we haven't created (e.g., MessageCenter).
248 chrome::DisableShutdownForTesting(true);
249 #endif // !defined(OS_ANDROID)
244 } 250 }
245 251
246 bool TestingBrowserProcess::IsShuttingDown() { 252 bool TestingBrowserProcess::IsShuttingDown() {
247 return false; 253 return false;
248 } 254 }
249 255
250 printing::PrintJobManager* TestingBrowserProcess::print_job_manager() { 256 printing::PrintJobManager* TestingBrowserProcess::print_job_manager() {
251 #if defined(ENABLE_PRINTING) 257 #if defined(ENABLE_PRINTING)
252 if (!print_job_manager_.get()) 258 if (!print_job_manager_.get())
253 print_job_manager_.reset(new printing::PrintJobManager()); 259 print_job_manager_.reset(new printing::PrintJobManager());
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 427
422 /////////////////////////////////////////////////////////////////////////////// 428 ///////////////////////////////////////////////////////////////////////////////
423 429
424 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { 430 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() {
425 TestingBrowserProcess::CreateInstance(); 431 TestingBrowserProcess::CreateInstance();
426 } 432 }
427 433
428 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { 434 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() {
429 TestingBrowserProcess::DeleteInstance(); 435 TestingBrowserProcess::DeleteInstance();
430 } 436 }
OLDNEW
« 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