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

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

Issue 10383254: At browser exit, wait for pending print jobs before starting shutdown. This is to avoid a nested me… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/printing/print_job.h » ('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) 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( 150 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
151 chrome::kExtensionScheme); 151 chrome::kExtensionScheme);
152 152
153 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; 153 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder;
154 154
155 ExtensionTabIdMap::GetInstance()->Init(); 155 ExtensionTabIdMap::GetInstance()->Init();
156 } 156 }
157 157
158 BrowserProcessImpl::~BrowserProcessImpl() { 158 BrowserProcessImpl::~BrowserProcessImpl() {
159 #if !defined(OS_ANDROID)
160 // Wait for the pending print jobs to finish.
161 print_job_manager_->OnQuit();
162 print_job_manager_.reset();
163 #endif
164
165 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); 159 tracked_objects::ThreadData::EnsureCleanupWasCalled(4);
166 160
167 g_browser_process = NULL; 161 g_browser_process = NULL;
168 } 162 }
169 163
170 void BrowserProcessImpl::StartTearDown() { 164 void BrowserProcessImpl::StartTearDown() {
171 #if defined(ENABLE_AUTOMATION) 165 #if defined(ENABLE_AUTOMATION)
172 // Delete the AutomationProviderList before NotificationService, 166 // Delete the AutomationProviderList before NotificationService,
173 // since it may try to unregister notifications 167 // since it may try to unregister notifications
174 // Both NotificationService and AutomationProvider are singleton instances in 168 // Both NotificationService and AutomationProvider are singleton instances in
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return module_ref_count_; 268 return module_ref_count_;
275 } 269 }
276 270
277 unsigned int BrowserProcessImpl::ReleaseModule() { 271 unsigned int BrowserProcessImpl::ReleaseModule() {
278 DCHECK(CalledOnValidThread()); 272 DCHECK(CalledOnValidThread());
279 DCHECK_NE(0u, module_ref_count_); 273 DCHECK_NE(0u, module_ref_count_);
280 module_ref_count_--; 274 module_ref_count_--;
281 if (0 == module_ref_count_) { 275 if (0 == module_ref_count_) {
282 release_last_reference_callstack_ = base::debug::StackTrace(); 276 release_last_reference_callstack_ = base::debug::StackTrace();
283 277
278 #if !defined(OS_ANDROID)
279 // Wait for the pending print jobs to finish. Don't do this later, since
280 // this might cause a nested message loop to run, and we don't want pending
281 // tasks to run once teardown has started.
282 print_job_manager_->OnQuit();
283 print_job_manager_.reset();
284 #endif
285
284 CHECK(MessageLoop::current()->is_running()); 286 CHECK(MessageLoop::current()->is_running());
285 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot 287 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot
286 // of it on shutdown for valid reasons. 288 // of it on shutdown for valid reasons.
287 base::ThreadRestrictions::SetIOAllowed(true); 289 base::ThreadRestrictions::SetIOAllowed(true);
288 CHECK(!BrowserList::GetLastActive()); 290 CHECK(!BrowserList::GetLastActive());
289 BrowserThread::PostTask( 291 BrowserThread::PostTask(
290 BrowserThread::IO, 292 BrowserThread::IO,
291 FROM_HERE, 293 FROM_HERE,
292 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), 294 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed),
293 true)); 295 true));
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 } 927 }
926 928
927 void BrowserProcessImpl::OnAutoupdateTimer() { 929 void BrowserProcessImpl::OnAutoupdateTimer() {
928 if (CanAutorestartForUpdate()) { 930 if (CanAutorestartForUpdate()) {
929 DLOG(WARNING) << "Detected update. Restarting browser."; 931 DLOG(WARNING) << "Detected update. Restarting browser.";
930 RestartBackgroundInstance(); 932 RestartBackgroundInstance();
931 } 933 }
932 } 934 }
933 935
934 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 936 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.mm ('k') | chrome/browser/printing/print_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698