Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 base::debug::StackTrace callstack = release_last_reference_callstack_; | 342 base::debug::StackTrace callstack = release_last_reference_callstack_; |
| 343 base::debug::Alias(&callstack); | 343 base::debug::Alias(&callstack); |
| 344 CHECK(false); | 344 CHECK(false); |
| 345 } | 345 } |
| 346 | 346 |
| 347 did_start_ = true; | 347 did_start_ = true; |
| 348 module_ref_count_++; | 348 module_ref_count_++; |
| 349 return module_ref_count_; | 349 return module_ref_count_; |
| 350 } | 350 } |
| 351 | 351 |
| 352 static void ShutdownServiceWorkerContext(content::StoragePartition* partition) { | |
| 353 partition->GetServiceWorkerContext()->Terminate(); | |
|
michaeln
2014/10/21 23:24:13
I was wondering where the Terminate() method came
| |
| 354 } | |
| 355 | |
| 356 unsigned int BrowserProcessImpl::ReleaseModule() { | 352 unsigned int BrowserProcessImpl::ReleaseModule() { |
| 357 DCHECK(CalledOnValidThread()); | 353 DCHECK(CalledOnValidThread()); |
| 358 DCHECK_NE(0u, module_ref_count_); | 354 DCHECK_NE(0u, module_ref_count_); |
| 359 module_ref_count_--; | 355 module_ref_count_--; |
| 360 if (0 == module_ref_count_) { | 356 if (0 == module_ref_count_) { |
| 361 release_last_reference_callstack_ = base::debug::StackTrace(); | 357 release_last_reference_callstack_ = base::debug::StackTrace(); |
| 362 | 358 |
| 363 // Stop service workers | |
| 364 ProfileManager* pm = profile_manager(); | |
| 365 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | |
| 366 for (size_t i = 0; i < profiles.size(); ++i) { | |
| 367 content::BrowserContext::ForEachStoragePartition( | |
| 368 profiles[i], base::Bind(ShutdownServiceWorkerContext)); | |
| 369 } | |
| 370 | |
| 371 #if defined(ENABLE_PRINTING) | 359 #if defined(ENABLE_PRINTING) |
| 372 // Wait for the pending print jobs to finish. Don't do this later, since | 360 // Wait for the pending print jobs to finish. Don't do this later, since |
| 373 // this might cause a nested message loop to run, and we don't want pending | 361 // this might cause a nested message loop to run, and we don't want pending |
| 374 // tasks to run once teardown has started. | 362 // tasks to run once teardown has started. |
| 375 print_job_manager_->Shutdown(); | 363 print_job_manager_->Shutdown(); |
| 376 #endif | 364 #endif |
| 377 | 365 |
| 378 #if defined(LEAK_SANITIZER) | 366 #if defined(LEAK_SANITIZER) |
| 379 // Check for memory leaks now, before we start shutting down threads. Doing | 367 // Check for memory leaks now, before we start shutting down threads. Doing |
| 380 // this early means we won't report any shutdown-only leaks (as they have | 368 // this early means we won't report any shutdown-only leaks (as they have |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1229 } | 1217 } |
| 1230 | 1218 |
| 1231 void BrowserProcessImpl::OnAutoupdateTimer() { | 1219 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1232 if (CanAutorestartForUpdate()) { | 1220 if (CanAutorestartForUpdate()) { |
| 1233 DLOG(WARNING) << "Detected update. Restarting browser."; | 1221 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1234 RestartBackgroundInstance(); | 1222 RestartBackgroundInstance(); |
| 1235 } | 1223 } |
| 1236 } | 1224 } |
| 1237 | 1225 |
| 1238 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1226 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |