| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "chrome/browser/automation/automation_provider_list.h" | 16 #include "chrome/browser/automation/automation_provider_list.h" |
| 17 #include "chrome/browser/browser_child_process_host.h" | 17 #include "chrome/browser/browser_child_process_host.h" |
| 18 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
| 19 #include "chrome/browser/browser_main.h" | 19 #include "chrome/browser/browser_main.h" |
| 20 #include "chrome/browser/browser_process_sub_thread.h" | 20 #include "chrome/browser/browser_process_sub_thread.h" |
| 21 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
| 22 #include "chrome/browser/browser_trial.h" | 22 #include "chrome/browser/browser_trial.h" |
| 23 #include "chrome/browser/debugger/debugger_wrapper.h" | 23 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" |
| 24 #include "chrome/browser/debugger/devtools_manager.h" | 24 #include "chrome/browser/debugger/devtools_manager.h" |
| 25 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
| 25 #include "chrome/browser/download/download_file_manager.h" | 26 #include "chrome/browser/download/download_file_manager.h" |
| 26 #include "chrome/browser/download/save_file_manager.h" | 27 #include "chrome/browser/download/save_file_manager.h" |
| 27 #include "chrome/browser/first_run/first_run.h" | 28 #include "chrome/browser/first_run/first_run.h" |
| 28 #include "chrome/browser/google/google_url_tracker.h" | 29 #include "chrome/browser/google/google_url_tracker.h" |
| 29 #include "chrome/browser/icon_manager.h" | 30 #include "chrome/browser/icon_manager.h" |
| 30 #include "chrome/browser/intranet_redirect_detector.h" | 31 #include "chrome/browser/intranet_redirect_detector.h" |
| 31 #include "chrome/browser/io_thread.h" | 32 #include "chrome/browser/io_thread.h" |
| 32 #include "chrome/browser/metrics/metrics_service.h" | 33 #include "chrome/browser/metrics/metrics_service.h" |
| 33 #include "chrome/browser/net/chrome_net_log.h" | 34 #include "chrome/browser/net/chrome_net_log.h" |
| 34 #include "chrome/browser/net/predictor_api.h" | 35 #include "chrome/browser/net/predictor_api.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 : created_resource_dispatcher_host_(false), | 91 : created_resource_dispatcher_host_(false), |
| 91 created_metrics_service_(false), | 92 created_metrics_service_(false), |
| 92 created_io_thread_(false), | 93 created_io_thread_(false), |
| 93 created_file_thread_(false), | 94 created_file_thread_(false), |
| 94 created_db_thread_(false), | 95 created_db_thread_(false), |
| 95 created_process_launcher_thread_(false), | 96 created_process_launcher_thread_(false), |
| 96 created_cache_thread_(false), | 97 created_cache_thread_(false), |
| 97 created_profile_manager_(false), | 98 created_profile_manager_(false), |
| 98 created_local_state_(false), | 99 created_local_state_(false), |
| 99 created_icon_manager_(false), | 100 created_icon_manager_(false), |
| 100 created_debugger_wrapper_(false), | |
| 101 created_devtools_manager_(false), | 101 created_devtools_manager_(false), |
| 102 created_sidebar_manager_(false), | 102 created_sidebar_manager_(false), |
| 103 created_configuration_policy_provider_keeper_(false), | 103 created_configuration_policy_provider_keeper_(false), |
| 104 created_notification_ui_manager_(false), | 104 created_notification_ui_manager_(false), |
| 105 created_safe_browsing_detection_service_(false), | 105 created_safe_browsing_detection_service_(false), |
| 106 module_ref_count_(0), | 106 module_ref_count_(0), |
| 107 did_start_(false), | 107 did_start_(false), |
| 108 checked_for_new_frames_(false), | 108 checked_for_new_frames_(false), |
| 109 using_new_frames_(false), | 109 using_new_frames_(false), |
| 110 have_inspector_files_(true) { | 110 have_inspector_files_(true) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 // Need to clear the desktop notification balloons before the io_thread_ and | 160 // Need to clear the desktop notification balloons before the io_thread_ and |
| 161 // before the profiles, since if there are any still showing we will access | 161 // before the profiles, since if there are any still showing we will access |
| 162 // those things during teardown. | 162 // those things during teardown. |
| 163 notification_ui_manager_.reset(); | 163 notification_ui_manager_.reset(); |
| 164 | 164 |
| 165 // Need to clear profiles (download managers) before the io_thread_. | 165 // Need to clear profiles (download managers) before the io_thread_. |
| 166 profile_manager_.reset(); | 166 profile_manager_.reset(); |
| 167 | 167 |
| 168 // Debugger must be cleaned up before IO thread and NotificationService. | 168 // Debugger must be cleaned up before IO thread and NotificationService. |
| 169 debugger_wrapper_ = NULL; | 169 if (devtools_http_handler_.get()) { |
| 170 devtools_http_handler_->Stop(); |
| 171 devtools_http_handler_ = NULL; |
| 172 } |
| 173 if (devtools_legacy_handler_.get()) { |
| 174 devtools_legacy_handler_->Stop(); |
| 175 devtools_legacy_handler_ = NULL; |
| 176 } |
| 170 | 177 |
| 171 if (resource_dispatcher_host_.get()) { | 178 if (resource_dispatcher_host_.get()) { |
| 172 // Need to tell Safe Browsing Service that the IO thread is going away | 179 // Need to tell Safe Browsing Service that the IO thread is going away |
| 173 // since it cached a pointer to it. | 180 // since it cached a pointer to it. |
| 174 if (resource_dispatcher_host()->safe_browsing_service()) | 181 if (resource_dispatcher_host()->safe_browsing_service()) |
| 175 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); | 182 resource_dispatcher_host()->safe_browsing_service()->ShutDown(); |
| 176 | 183 |
| 177 // Cancel pending requests and prevent new requests. | 184 // Cancel pending requests and prevent new requests. |
| 178 resource_dispatcher_host()->Shutdown(); | 185 resource_dispatcher_host()->Shutdown(); |
| 179 } | 186 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 452 } |
| 446 | 453 |
| 447 AutomationProviderList* BrowserProcessImpl::InitAutomationProviderList() { | 454 AutomationProviderList* BrowserProcessImpl::InitAutomationProviderList() { |
| 448 DCHECK(CalledOnValidThread()); | 455 DCHECK(CalledOnValidThread()); |
| 449 if (automation_provider_list_.get() == NULL) { | 456 if (automation_provider_list_.get() == NULL) { |
| 450 automation_provider_list_.reset(AutomationProviderList::GetInstance()); | 457 automation_provider_list_.reset(AutomationProviderList::GetInstance()); |
| 451 } | 458 } |
| 452 return automation_provider_list_.get(); | 459 return automation_provider_list_.get(); |
| 453 } | 460 } |
| 454 | 461 |
| 455 void BrowserProcessImpl::InitDebuggerWrapper(int port, bool useHttp) { | 462 void BrowserProcessImpl::InitDevToolsHttpProtocolHandler( |
| 463 int port, |
| 464 const std::string& frontend_url) { |
| 456 DCHECK(CalledOnValidThread()); | 465 DCHECK(CalledOnValidThread()); |
| 457 if (!created_debugger_wrapper_) | 466 devtools_http_handler_ = |
| 458 CreateDebuggerWrapper(port, useHttp); | 467 DevToolsHttpProtocolHandler::Start(port, frontend_url); |
| 468 } |
| 469 |
| 470 void BrowserProcessImpl::InitDevToolsLegacyProtocolHandler(int port) { |
| 471 DCHECK(CalledOnValidThread()); |
| 472 devtools_legacy_handler_ = DevToolsProtocolHandler::Start(port); |
| 459 } | 473 } |
| 460 | 474 |
| 461 bool BrowserProcessImpl::IsShuttingDown() { | 475 bool BrowserProcessImpl::IsShuttingDown() { |
| 462 DCHECK(CalledOnValidThread()); | 476 DCHECK(CalledOnValidThread()); |
| 463 return did_start_ && 0 == module_ref_count_; | 477 return did_start_ && 0 == module_ref_count_; |
| 464 } | 478 } |
| 465 | 479 |
| 466 printing::PrintJobManager* BrowserProcessImpl::print_job_manager() { | 480 printing::PrintJobManager* BrowserProcessImpl::print_job_manager() { |
| 467 // TODO(abarth): DCHECK(CalledOnValidThread()); | 481 // TODO(abarth): DCHECK(CalledOnValidThread()); |
| 468 // http://code.google.com/p/chromium/issues/detail?id=6828 | 482 // http://code.google.com/p/chromium/issues/detail?id=6828 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 pref_change_registrar_.Add(prefs::kPrintingEnabled, | 740 pref_change_registrar_.Add(prefs::kPrintingEnabled, |
| 727 print_job_manager_.get()); | 741 print_job_manager_.get()); |
| 728 } | 742 } |
| 729 | 743 |
| 730 void BrowserProcessImpl::CreateIconManager() { | 744 void BrowserProcessImpl::CreateIconManager() { |
| 731 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); | 745 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); |
| 732 created_icon_manager_ = true; | 746 created_icon_manager_ = true; |
| 733 icon_manager_.reset(new IconManager); | 747 icon_manager_.reset(new IconManager); |
| 734 } | 748 } |
| 735 | 749 |
| 736 void BrowserProcessImpl::CreateDebuggerWrapper(int port, bool useHttp) { | |
| 737 DCHECK(debugger_wrapper_.get() == NULL); | |
| 738 created_debugger_wrapper_ = true; | |
| 739 | |
| 740 debugger_wrapper_ = new DebuggerWrapper(port, useHttp); | |
| 741 } | |
| 742 | |
| 743 void BrowserProcessImpl::CreateDevToolsManager() { | 750 void BrowserProcessImpl::CreateDevToolsManager() { |
| 744 DCHECK(devtools_manager_.get() == NULL); | 751 DCHECK(devtools_manager_.get() == NULL); |
| 745 created_devtools_manager_ = true; | 752 created_devtools_manager_ = true; |
| 746 devtools_manager_ = new DevToolsManager(); | 753 devtools_manager_ = new DevToolsManager(); |
| 747 } | 754 } |
| 748 | 755 |
| 749 void BrowserProcessImpl::CreateSidebarManager() { | 756 void BrowserProcessImpl::CreateSidebarManager() { |
| 750 DCHECK(sidebar_manager_.get() == NULL); | 757 DCHECK(sidebar_manager_.get() == NULL); |
| 751 created_sidebar_manager_ = true; | 758 created_sidebar_manager_ = true; |
| 752 sidebar_manager_ = new SidebarManager(); | 759 sidebar_manager_ = new SidebarManager(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 922 } |
| 916 | 923 |
| 917 void BrowserProcessImpl::OnAutoupdateTimer() { | 924 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 918 if (CanAutorestartForUpdate()) { | 925 if (CanAutorestartForUpdate()) { |
| 919 DLOG(WARNING) << "Detected update. Restarting browser."; | 926 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 920 RestartPersistentInstance(); | 927 RestartPersistentInstance(); |
| 921 } | 928 } |
| 922 } | 929 } |
| 923 | 930 |
| 924 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 931 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |