| OLD | NEW |
| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/time/default_tick_clock.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/apps/chrome_apps_client.h" | 11 #include "chrome/browser/apps/chrome_apps_client.h" |
| 11 #include "chrome/browser/background/background_mode_manager.h" | 12 #include "chrome/browser/background/background_mode_manager.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_process_impl.h" | 14 #include "chrome/browser/browser_process_impl.h" |
| 14 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" | 15 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
| 16 #include "chrome/browser/network_time/network_time_tracker.h" |
| 15 #include "chrome/browser/printing/print_job_manager.h" | 17 #include "chrome/browser/printing/print_job_manager.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/test/base/testing_browser_process_platform_part.h" | 19 #include "chrome/test/base/testing_browser_process_platform_part.h" |
| 18 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/message_center/message_center.h" | 23 #include "ui/message_center/message_center.h" |
| 22 | 24 |
| 23 #if !defined(OS_IOS) | 25 #if !defined(OS_IOS) |
| 24 #include "chrome/browser/notifications/notification_ui_manager.h" | 26 #include "chrome/browser/notifications/notification_ui_manager.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // g_browser_process must be NULL during its own destruction. | 61 // g_browser_process must be NULL during its own destruction. |
| 60 BrowserProcess* browser_process = g_browser_process; | 62 BrowserProcess* browser_process = g_browser_process; |
| 61 g_browser_process = NULL; | 63 g_browser_process = NULL; |
| 62 delete browser_process; | 64 delete browser_process; |
| 63 } | 65 } |
| 64 | 66 |
| 65 TestingBrowserProcess::TestingBrowserProcess() | 67 TestingBrowserProcess::TestingBrowserProcess() |
| 66 : notification_service_(content::NotificationService::Create()), | 68 : notification_service_(content::NotificationService::Create()), |
| 67 module_ref_count_(0), | 69 module_ref_count_(0), |
| 68 app_locale_("en"), | 70 app_locale_("en"), |
| 71 network_time_tracker_(new NetworkTimeTracker( |
| 72 scoped_ptr<base::TickClock>(new base::DefaultTickClock))), |
| 69 local_state_(NULL), | 73 local_state_(NULL), |
| 70 io_thread_(NULL), | 74 io_thread_(NULL), |
| 71 system_request_context_(NULL), | 75 system_request_context_(NULL), |
| 72 platform_part_(new TestingBrowserProcessPlatformPart()), | 76 platform_part_(new TestingBrowserProcessPlatformPart()), |
| 73 extensions_browser_client_( | 77 extensions_browser_client_( |
| 74 new extensions::ChromeExtensionsBrowserClient) { | 78 new extensions::ChromeExtensionsBrowserClient) { |
| 75 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); | 79 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); |
| 76 apps::AppsClient::Set(ChromeAppsClient::GetInstance()); | 80 apps::AppsClient::Set(ChromeAppsClient::GetInstance()); |
| 77 } | 81 } |
| 78 | 82 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 bool TestingBrowserProcess::created_local_state() const { | 357 bool TestingBrowserProcess::created_local_state() const { |
| 354 return (local_state_ != NULL); | 358 return (local_state_ != NULL); |
| 355 } | 359 } |
| 356 | 360 |
| 357 #if defined(ENABLE_WEBRTC) | 361 #if defined(ENABLE_WEBRTC) |
| 358 WebRtcLogUploader* TestingBrowserProcess::webrtc_log_uploader() { | 362 WebRtcLogUploader* TestingBrowserProcess::webrtc_log_uploader() { |
| 359 return NULL; | 363 return NULL; |
| 360 } | 364 } |
| 361 #endif | 365 #endif |
| 362 | 366 |
| 367 NetworkTimeTracker* TestingBrowserProcess::network_time_tracker() { |
| 368 return network_time_tracker_.get(); |
| 369 } |
| 370 |
| 363 void TestingBrowserProcess::SetSystemRequestContext( | 371 void TestingBrowserProcess::SetSystemRequestContext( |
| 364 net::URLRequestContextGetter* context_getter) { | 372 net::URLRequestContextGetter* context_getter) { |
| 365 system_request_context_ = context_getter; | 373 system_request_context_ = context_getter; |
| 366 } | 374 } |
| 367 | 375 |
| 368 void TestingBrowserProcess::SetLocalState(PrefService* local_state) { | 376 void TestingBrowserProcess::SetLocalState(PrefService* local_state) { |
| 369 if (!local_state) { | 377 if (!local_state) { |
| 370 // The local_state_ PrefService is owned outside of TestingBrowserProcess, | 378 // The local_state_ PrefService is owned outside of TestingBrowserProcess, |
| 371 // but some of the members of TestingBrowserProcess hold references to it | 379 // but some of the members of TestingBrowserProcess hold references to it |
| 372 // (for example, via PrefNotifier members). But given our test | 380 // (for example, via PrefNotifier members). But given our test |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 420 |
| 413 /////////////////////////////////////////////////////////////////////////////// | 421 /////////////////////////////////////////////////////////////////////////////// |
| 414 | 422 |
| 415 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { | 423 TestingBrowserProcessInitializer::TestingBrowserProcessInitializer() { |
| 416 TestingBrowserProcess::CreateInstance(); | 424 TestingBrowserProcess::CreateInstance(); |
| 417 } | 425 } |
| 418 | 426 |
| 419 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { | 427 TestingBrowserProcessInitializer::~TestingBrowserProcessInitializer() { |
| 420 TestingBrowserProcess::DeleteInstance(); | 428 TestingBrowserProcess::DeleteInstance(); |
| 421 } | 429 } |
| OLD | NEW |