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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 5579002: Add a preference to clear plugin data on browser shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/plugin_data_remover_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 #include "chrome/browser/first_run/first_run.h" 30 #include "chrome/browser/first_run/first_run.h"
31 #include "chrome/browser/google/google_url_tracker.h" 31 #include "chrome/browser/google/google_url_tracker.h"
32 #include "chrome/browser/icon_manager.h" 32 #include "chrome/browser/icon_manager.h"
33 #include "chrome/browser/intranet_redirect_detector.h" 33 #include "chrome/browser/intranet_redirect_detector.h"
34 #include "chrome/browser/io_thread.h" 34 #include "chrome/browser/io_thread.h"
35 #include "chrome/browser/metrics/metrics_service.h" 35 #include "chrome/browser/metrics/metrics_service.h"
36 #include "chrome/browser/net/chrome_net_log.h" 36 #include "chrome/browser/net/chrome_net_log.h"
37 #include "chrome/browser/net/predictor_api.h" 37 #include "chrome/browser/net/predictor_api.h"
38 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 38 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
39 #include "chrome/browser/notifications/notification_ui_manager.h" 39 #include "chrome/browser/notifications/notification_ui_manager.h"
40 #include "chrome/browser/plugin_data_remover.h"
40 #include "chrome/browser/plugin_service.h" 41 #include "chrome/browser/plugin_service.h"
41 #include "chrome/browser/plugin_updater.h" 42 #include "chrome/browser/plugin_updater.h"
42 #include "chrome/browser/prefs/pref_service.h" 43 #include "chrome/browser/prefs/pref_service.h"
43 #include "chrome/browser/printing/print_job_manager.h" 44 #include "chrome/browser/printing/print_job_manager.h"
44 #include "chrome/browser/printing/print_preview_tab_controller.h" 45 #include "chrome/browser/printing/print_preview_tab_controller.h"
45 #include "chrome/browser/profiles/profile_manager.h" 46 #include "chrome/browser/profiles/profile_manager.h"
46 #include "chrome/browser/renderer_host/render_process_host.h" 47 #include "chrome/browser/renderer_host/render_process_host.h"
47 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
48 #include "chrome/browser/safe_browsing/client_side_detection_service.h" 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 created_safe_browsing_detection_service_(false), 104 created_safe_browsing_detection_service_(false),
104 module_ref_count_(0), 105 module_ref_count_(0),
105 did_start_(false), 106 did_start_(false),
106 checked_for_new_frames_(false), 107 checked_for_new_frames_(false),
107 using_new_frames_(false), 108 using_new_frames_(false),
108 have_inspector_files_(true) { 109 have_inspector_files_(true) {
109 g_browser_process = this; 110 g_browser_process = this;
110 clipboard_.reset(new Clipboard); 111 clipboard_.reset(new Clipboard);
111 main_notification_service_.reset(new NotificationService); 112 main_notification_service_.reset(new NotificationService);
112 113
114 notification_registrar_.Add(this,
115 NotificationType::APP_TERMINATING,
116 NotificationService::AllSources());
117
113 // Must be created after the NotificationService. 118 // Must be created after the NotificationService.
114 print_job_manager_.reset(new printing::PrintJobManager); 119 print_job_manager_.reset(new printing::PrintJobManager);
115 120
116 shutdown_event_.reset(new base::WaitableEvent(true, false)); 121 shutdown_event_.reset(new base::WaitableEvent(true, false));
117 122
118 net_log_.reset(new ChromeNetLog); 123 net_log_.reset(new ChromeNetLog);
119 } 124 }
120 125
121 BrowserProcessImpl::~BrowserProcessImpl() { 126 BrowserProcessImpl::~BrowserProcessImpl() {
122 FilePath profile_path; 127 FilePath profile_path;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 173
169 // Cancel pending requests and prevent new requests. 174 // Cancel pending requests and prevent new requests.
170 resource_dispatcher_host()->Shutdown(); 175 resource_dispatcher_host()->Shutdown();
171 } 176 }
172 177
173 #if defined(USE_X11) 178 #if defined(USE_X11)
174 // The IO thread must outlive the BACKGROUND_X11 thread. 179 // The IO thread must outlive the BACKGROUND_X11 thread.
175 background_x11_thread_.reset(); 180 background_x11_thread_.reset();
176 #endif 181 #endif
177 182
183 // Wait for removing plugin data to finish before shutting down the IO thread.
184 WaitForPluginDataRemoverToFinish();
185
178 // Need to stop io_thread_ before resource_dispatcher_host_, since 186 // Need to stop io_thread_ before resource_dispatcher_host_, since
179 // io_thread_ may still deref ResourceDispatcherHost and handle resource 187 // io_thread_ may still deref ResourceDispatcherHost and handle resource
180 // request before going away. 188 // request before going away.
181 io_thread_.reset(); 189 io_thread_.reset();
182 190
183 // The IO thread was the only user of this thread. 191 // The IO thread was the only user of this thread.
184 cache_thread_.reset(); 192 cache_thread_.reset();
185 193
186 // Stop the process launcher thread after the IO thread, in case the IO thread 194 // Stop the process launcher thread after the IO thread, in case the IO thread
187 // posted a task to terminate a process on the process launcher thread. 195 // posted a task to terminate a process on the process launcher thread.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 508 }
501 return safe_browsing_detection_service_.get(); 509 return safe_browsing_detection_service_.get();
502 } 510 }
503 511
504 void BrowserProcessImpl::CheckForInspectorFiles() { 512 void BrowserProcessImpl::CheckForInspectorFiles() {
505 file_thread()->message_loop()->PostTask 513 file_thread()->message_loop()->PostTask
506 (FROM_HERE, 514 (FROM_HERE,
507 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck)); 515 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
508 } 516 }
509 517
518 void BrowserProcessImpl::Observe(NotificationType type,
519 const NotificationSource& source,
520 const NotificationDetails& details) {
521 if (type == NotificationType::APP_TERMINATING) {
522 Profile* profile = ProfileManager::GetDefaultProfile();
523 if (profile) {
524 PrefService* prefs = profile->GetPrefs();
525 if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) &&
526 local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) {
527 plugin_data_remover_ = new PluginDataRemover();
528 plugin_data_remover_->StartRemoving(base::Time(), NULL);
529 }
530 }
531 } else {
532 NOTREACHED();
533 }
534 }
535
536 void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() {
537 if (!plugin_data_remover_.get() || !plugin_data_remover_->is_removing())
538 return;
539 plugin_data_remover_->set_done_task(new MessageLoop::QuitTask());
540 base::Time start_time(base::Time::Now());
541 MessageLoop::current()->Run();
542 UMA_HISTOGRAM_TIMES("ClearPluginData.wait_at_shutdown",
543 base::Time::Now() - start_time);
544 }
545
510 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 546 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
511 void BrowserProcessImpl::StartAutoupdateTimer() { 547 void BrowserProcessImpl::StartAutoupdateTimer() {
512 autoupdate_timer_.Start( 548 autoupdate_timer_.Start(
513 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), 549 base::TimeDelta::FromHours(kUpdateCheckIntervalHours),
514 this, 550 this,
515 &BrowserProcessImpl::OnAutoupdateTimer); 551 &BrowserProcessImpl::OnAutoupdateTimer);
516 } 552 }
517 #endif 553 #endif
518 554
519 bool BrowserProcessImpl::have_inspector_files() const { 555 bool BrowserProcessImpl::have_inspector_files() const {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 } 903 }
868 904
869 void BrowserProcessImpl::OnAutoupdateTimer() { 905 void BrowserProcessImpl::OnAutoupdateTimer() {
870 if (CanAutorestartForUpdate()) { 906 if (CanAutorestartForUpdate()) {
871 DLOG(WARNING) << "Detected update. Restarting browser."; 907 DLOG(WARNING) << "Detected update. Restarting browser.";
872 RestartPersistentInstance(); 908 RestartPersistentInstance();
873 } 909 }
874 } 910 }
875 911
876 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 912 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/plugin_data_remover_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698