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

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

Issue 10542151: Move the window destruction and registration out of cleanup and into BrowserProcessImpl::EndSession… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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/browser/browser_process_impl.h" 5 #include "chrome/browser/browser_process_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 43 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
44 #include "chrome/browser/notifications/notification_ui_manager.h" 44 #include "chrome/browser/notifications/notification_ui_manager.h"
45 #include "chrome/browser/policy/browser_policy_connector.h" 45 #include "chrome/browser/policy/browser_policy_connector.h"
46 #include "chrome/browser/policy/policy_service.h" 46 #include "chrome/browser/policy/policy_service.h"
47 #include "chrome/browser/prefs/browser_prefs.h" 47 #include "chrome/browser/prefs/browser_prefs.h"
48 #include "chrome/browser/prefs/pref_service.h" 48 #include "chrome/browser/prefs/pref_service.h"
49 #include "chrome/browser/prerender/prerender_tracker.h" 49 #include "chrome/browser/prerender/prerender_tracker.h"
50 #include "chrome/browser/printing/background_printing_manager.h" 50 #include "chrome/browser/printing/background_printing_manager.h"
51 #include "chrome/browser/printing/print_job_manager.h" 51 #include "chrome/browser/printing/print_job_manager.h"
52 #include "chrome/browser/printing/print_preview_tab_controller.h" 52 #include "chrome/browser/printing/print_preview_tab_controller.h"
53 #include "chrome/browser/process_singleton.h"
53 #include "chrome/browser/profiles/profile_manager.h" 54 #include "chrome/browser/profiles/profile_manager.h"
54 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 55 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
55 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 56 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
56 #include "chrome/browser/shell_integration.h" 57 #include "chrome/browser/shell_integration.h"
57 #include "chrome/browser/status_icons/status_tray.h" 58 #include "chrome/browser/status_icons/status_tray.h"
58 #include "chrome/browser/tab_closeable_state_watcher.h" 59 #include "chrome/browser/tab_closeable_state_watcher.h"
59 #include "chrome/browser/tab_contents/thumbnail_generator.h" 60 #include "chrome/browser/tab_contents/thumbnail_generator.h"
60 #include "chrome/browser/ui/browser_list.h" 61 #include "chrome/browser/ui/browser_list.h"
61 #include "chrome/common/chrome_constants.h" 62 #include "chrome/common/chrome_constants.h"
62 #include "chrome/common/chrome_content_client.h" 63 #include "chrome/common/chrome_content_client.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Linux. We have a timeout here because we're unable to run the UI messageloop 120 // Linux. We have a timeout here because we're unable to run the UI messageloop
120 // and there's some deadlock risk. Our only option is to exit anyway. 121 // and there's some deadlock risk. Our only option is to exit anyway.
121 static const int kEndSessionTimeoutSeconds = 10; 122 static const int kEndSessionTimeoutSeconds = 10;
122 #endif 123 #endif
123 124
124 using content::BrowserThread; 125 using content::BrowserThread;
125 using content::ChildProcessSecurityPolicy; 126 using content::ChildProcessSecurityPolicy;
126 using content::PluginService; 127 using content::PluginService;
127 using content::ResourceDispatcherHost; 128 using content::ResourceDispatcherHost;
128 129
129 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) 130 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line,
131 ProcessSingleton* process_singleton)
130 : created_metrics_service_(false), 132 : created_metrics_service_(false),
131 created_watchdog_thread_(false), 133 created_watchdog_thread_(false),
132 created_browser_policy_connector_(false), 134 created_browser_policy_connector_(false),
133 created_profile_manager_(false), 135 created_profile_manager_(false),
134 created_local_state_(false), 136 created_local_state_(false),
135 created_icon_manager_(false), 137 created_icon_manager_(false),
136 created_notification_ui_manager_(false), 138 created_notification_ui_manager_(false),
137 created_safe_browsing_service_(false), 139 created_safe_browsing_service_(false),
138 module_ref_count_(0), 140 module_ref_count_(0),
139 did_start_(false), 141 did_start_(false),
140 checked_for_new_frames_(false), 142 checked_for_new_frames_(false),
141 using_new_frames_(false), 143 using_new_frames_(false),
142 thumbnail_generator_(new ThumbnailGenerator), 144 thumbnail_generator_(new ThumbnailGenerator),
143 download_status_updater_(new DownloadStatusUpdater) { 145 download_status_updater_(new DownloadStatusUpdater),
146 process_singleton_(process_singleton) {
147 DCHECK(process_singleton_);
144 g_browser_process = this; 148 g_browser_process = this;
145 clipboard_.reset(new ui::Clipboard); 149 clipboard_.reset(new ui::Clipboard);
146 150
147 #if defined(ENABLE_PRINTING) 151 #if defined(ENABLE_PRINTING)
148 // Must be created after the NotificationService. 152 // Must be created after the NotificationService.
149 print_job_manager_.reset(new printing::PrintJobManager); 153 print_job_manager_.reset(new printing::PrintJobManager);
150 #endif 154 #endif
151 155
152 net_log_.reset(new ChromeNetLog); 156 net_log_.reset(new ChromeNetLog);
153 157
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 343 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
340 base::Bind(PostQuit, MessageLoop::current())); 344 base::Bind(PostQuit, MessageLoop::current()));
341 int quits_received = 0; 345 int quits_received = 0;
342 do { 346 do {
343 MessageLoop::current()->Run(); 347 MessageLoop::current()->Run();
344 ++quits_received; 348 ++quits_received;
345 } while (!g_end_session_file_thread_has_completed); 349 } while (!g_end_session_file_thread_has_completed);
346 // If we did get extra quits, then we should re-post them to the message loop. 350 // If we did get extra quits, then we should re-post them to the message loop.
347 while (--quits_received > 0) 351 while (--quits_received > 0)
348 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 352 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
353
354 // BrowserProcess::EndSession is only called in response to a window message
355 // sent by Windows when the user logs out or shuts down. When this occurs,
356 // all of Chrome is still running, so the pointer to process_singleton_
357 // should still be valid.
358 process_singleton_->UnregisterWindowClass();
349 #else 359 #else
350 NOTIMPLEMENTED(); 360 NOTIMPLEMENTED();
351 #endif 361 #endif
352 } 362 }
353 363
354 MetricsService* BrowserProcessImpl::metrics_service() { 364 MetricsService* BrowserProcessImpl::metrics_service() {
355 DCHECK(CalledOnValidThread()); 365 DCHECK(CalledOnValidThread());
356 if (!created_metrics_service_) 366 if (!created_metrics_service_)
357 CreateMetricsService(); 367 CreateMetricsService();
358 return metrics_service_.get(); 368 return metrics_service_.get();
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 944 }
935 945
936 void BrowserProcessImpl::OnAutoupdateTimer() { 946 void BrowserProcessImpl::OnAutoupdateTimer() {
937 if (CanAutorestartForUpdate()) { 947 if (CanAutorestartForUpdate()) {
938 DLOG(WARNING) << "Detected update. Restarting browser."; 948 DLOG(WARNING) << "Detected update. Restarting browser.";
939 RestartBackgroundInstance(); 949 RestartBackgroundInstance();
940 } 950 }
941 } 951 }
942 952
943 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 953 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698