| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/first_run/first_run.h" | 29 #include "chrome/browser/first_run/first_run.h" |
| 30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
| 31 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
| 32 #include "chrome/browser/intranet_redirect_detector.h" | 32 #include "chrome/browser/intranet_redirect_detector.h" |
| 33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
| 34 #include "chrome/browser/metrics/metrics_service.h" | 34 #include "chrome/browser/metrics/metrics_service.h" |
| 35 #include "chrome/browser/net/chrome_net_log.h" | 35 #include "chrome/browser/net/chrome_net_log.h" |
| 36 #include "chrome/browser/net/predictor_api.h" | 36 #include "chrome/browser/net/predictor_api.h" |
| 37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 38 #include "chrome/browser/notifications/notification_ui_manager.h" | 38 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 39 #include "chrome/browser/plugin_data_remover.h" |
| 39 #include "chrome/browser/plugin_service.h" | 40 #include "chrome/browser/plugin_service.h" |
| 40 #include "chrome/browser/plugin_updater.h" | 41 #include "chrome/browser/plugin_updater.h" |
| 41 #include "chrome/browser/prefs/pref_service.h" | 42 #include "chrome/browser/prefs/pref_service.h" |
| 42 #include "chrome/browser/printing/print_job_manager.h" | 43 #include "chrome/browser/printing/print_job_manager.h" |
| 43 #include "chrome/browser/printing/print_preview_tab_controller.h" | 44 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 44 #include "chrome/browser/profiles/profile_manager.h" | 45 #include "chrome/browser/profiles/profile_manager.h" |
| 45 #include "chrome/browser/renderer_host/render_process_host.h" | 46 #include "chrome/browser/renderer_host/render_process_host.h" |
| 46 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 47 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 47 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 48 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 48 #include "chrome/browser/sidebar/sidebar_manager.h" | 49 #include "chrome/browser/sidebar/sidebar_manager.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 created_notification_ui_manager_(false), | 101 created_notification_ui_manager_(false), |
| 101 module_ref_count_(0), | 102 module_ref_count_(0), |
| 102 did_start_(false), | 103 did_start_(false), |
| 103 checked_for_new_frames_(false), | 104 checked_for_new_frames_(false), |
| 104 using_new_frames_(false), | 105 using_new_frames_(false), |
| 105 have_inspector_files_(true) { | 106 have_inspector_files_(true) { |
| 106 g_browser_process = this; | 107 g_browser_process = this; |
| 107 clipboard_.reset(new Clipboard); | 108 clipboard_.reset(new Clipboard); |
| 108 main_notification_service_.reset(new NotificationService); | 109 main_notification_service_.reset(new NotificationService); |
| 109 | 110 |
| 111 notification_registrar_.Add(this, |
| 112 NotificationType::APP_TERMINATING, |
| 113 NotificationService::AllSources()); |
| 114 |
| 110 // Must be created after the NotificationService. | 115 // Must be created after the NotificationService. |
| 111 print_job_manager_.reset(new printing::PrintJobManager); | 116 print_job_manager_.reset(new printing::PrintJobManager); |
| 112 | 117 |
| 113 shutdown_event_.reset(new base::WaitableEvent(true, false)); | 118 shutdown_event_.reset(new base::WaitableEvent(true, false)); |
| 114 | 119 |
| 115 net_log_.reset(new ChromeNetLog); | 120 net_log_.reset(new ChromeNetLog); |
| 116 } | 121 } |
| 117 | 122 |
| 118 BrowserProcessImpl::~BrowserProcessImpl() { | 123 BrowserProcessImpl::~BrowserProcessImpl() { |
| 119 FilePath profile_path; | 124 FilePath profile_path; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 170 |
| 166 // Cancel pending requests and prevent new requests. | 171 // Cancel pending requests and prevent new requests. |
| 167 resource_dispatcher_host()->Shutdown(); | 172 resource_dispatcher_host()->Shutdown(); |
| 168 } | 173 } |
| 169 | 174 |
| 170 #if defined(USE_X11) | 175 #if defined(USE_X11) |
| 171 // The IO thread must outlive the BACKGROUND_X11 thread. | 176 // The IO thread must outlive the BACKGROUND_X11 thread. |
| 172 background_x11_thread_.reset(); | 177 background_x11_thread_.reset(); |
| 173 #endif | 178 #endif |
| 174 | 179 |
| 180 // Wait for removing plugin data to finish before shutting down the IO thread. |
| 181 WaitForPluginDataRemoverToFinish(); |
| 182 |
| 175 // Need to stop io_thread_ before resource_dispatcher_host_, since | 183 // Need to stop io_thread_ before resource_dispatcher_host_, since |
| 176 // io_thread_ may still deref ResourceDispatcherHost and handle resource | 184 // io_thread_ may still deref ResourceDispatcherHost and handle resource |
| 177 // request before going away. | 185 // request before going away. |
| 178 io_thread_.reset(); | 186 io_thread_.reset(); |
| 179 | 187 |
| 180 // The IO thread was the only user of this thread. | 188 // The IO thread was the only user of this thread. |
| 181 cache_thread_.reset(); | 189 cache_thread_.reset(); |
| 182 | 190 |
| 183 // Stop the process launcher thread after the IO thread, in case the IO thread | 191 // Stop the process launcher thread after the IO thread, in case the IO thread |
| 184 // posted a task to terminate a process on the process launcher thread. | 192 // posted a task to terminate a process on the process launcher thread. |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 CreateTabCloseableStateWatcher(); | 490 CreateTabCloseableStateWatcher(); |
| 483 return tab_closeable_state_watcher_.get(); | 491 return tab_closeable_state_watcher_.get(); |
| 484 } | 492 } |
| 485 | 493 |
| 486 void BrowserProcessImpl::CheckForInspectorFiles() { | 494 void BrowserProcessImpl::CheckForInspectorFiles() { |
| 487 file_thread()->message_loop()->PostTask | 495 file_thread()->message_loop()->PostTask |
| 488 (FROM_HERE, | 496 (FROM_HERE, |
| 489 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck)); | 497 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck)); |
| 490 } | 498 } |
| 491 | 499 |
| 500 void BrowserProcessImpl::Observe(NotificationType type, |
| 501 const NotificationSource& source, |
| 502 const NotificationDetails& details) { |
| 503 if (type == NotificationType::APP_TERMINATING) { |
| 504 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 505 if (profile) { |
| 506 PrefService* prefs = profile->GetPrefs(); |
| 507 if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) && |
| 508 local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) { |
| 509 plugin_data_remover_.reset(new PluginDataRemover()); |
| 510 plugin_data_remover_->StartRemoving(base::Time(), NULL); |
| 511 } |
| 512 } |
| 513 } else { |
| 514 NOTREACHED(); |
| 515 } |
| 516 } |
| 517 |
| 518 void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() { |
| 519 if (!plugin_data_remover_.get() || !plugin_data_remover_->is_removing()) |
| 520 return; |
| 521 plugin_data_remover_->set_done_task(new MessageLoop::QuitTask()); |
| 522 base::Time start_time(base::Time::Now()); |
| 523 MessageLoop::current()->Run(); |
| 524 UMA_HISTOGRAM_TIMES("ClearPluginData.wait_at_shutdown", |
| 525 base::Time::Now() - start_time); |
| 526 } |
| 527 |
| 492 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 528 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 493 void BrowserProcessImpl::StartAutoupdateTimer() { | 529 void BrowserProcessImpl::StartAutoupdateTimer() { |
| 494 autoupdate_timer_.Start( | 530 autoupdate_timer_.Start( |
| 495 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), | 531 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), |
| 496 this, | 532 this, |
| 497 &BrowserProcessImpl::OnAutoupdateTimer); | 533 &BrowserProcessImpl::OnAutoupdateTimer); |
| 498 } | 534 } |
| 499 #endif | 535 #endif |
| 500 | 536 |
| 501 bool BrowserProcessImpl::have_inspector_files() const { | 537 bool BrowserProcessImpl::have_inspector_files() const { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 852 } |
| 817 | 853 |
| 818 void BrowserProcessImpl::OnAutoupdateTimer() { | 854 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 819 if (CanAutorestartForUpdate()) { | 855 if (CanAutorestartForUpdate()) { |
| 820 DLOG(WARNING) << "Detected update. Restarting browser."; | 856 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 821 RestartPersistentInstance(); | 857 RestartPersistentInstance(); |
| 822 } | 858 } |
| 823 } | 859 } |
| 824 | 860 |
| 825 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 861 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |