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

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

Issue 305723003: Shut down the ServiceWorker system as the browser's shutting down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a redundant clear() Created 6 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
« no previous file with comments | « no previous file | chrome/browser/chrome_service_worker_browsertest.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) 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "chrome/installer/util/google_update_settings.h" 79 #include "chrome/installer/util/google_update_settings.h"
80 #include "components/policy/core/common/policy_service.h" 80 #include "components/policy/core/common/policy_service.h"
81 #include "components/signin/core/common/profile_management_switches.h" 81 #include "components/signin/core/common/profile_management_switches.h"
82 #include "components/translate/core/browser/translate_download_manager.h" 82 #include "components/translate/core/browser/translate_download_manager.h"
83 #include "content/public/browser/browser_thread.h" 83 #include "content/public/browser/browser_thread.h"
84 #include "content/public/browser/child_process_security_policy.h" 84 #include "content/public/browser/child_process_security_policy.h"
85 #include "content/public/browser/notification_details.h" 85 #include "content/public/browser/notification_details.h"
86 #include "content/public/browser/plugin_service.h" 86 #include "content/public/browser/plugin_service.h"
87 #include "content/public/browser/render_process_host.h" 87 #include "content/public/browser/render_process_host.h"
88 #include "content/public/browser/resource_dispatcher_host.h" 88 #include "content/public/browser/resource_dispatcher_host.h"
89 #include "content/public/browser/service_worker_context.h"
90 #include "content/public/browser/storage_partition.h"
89 #include "extensions/common/constants.h" 91 #include "extensions/common/constants.h"
90 #include "extensions/common/extension_l10n_util.h" 92 #include "extensions/common/extension_l10n_util.h"
91 #include "net/socket/client_socket_pool_manager.h" 93 #include "net/socket/client_socket_pool_manager.h"
92 #include "net/url_request/url_request_context_getter.h" 94 #include "net/url_request/url_request_context_getter.h"
93 #include "ui/base/l10n/l10n_util.h" 95 #include "ui/base/l10n/l10n_util.h"
94 #include "ui/message_center/message_center.h" 96 #include "ui/message_center/message_center.h"
95 97
96 #if defined(ENABLE_CONFIGURATION_POLICY) 98 #if defined(ENABLE_CONFIGURATION_POLICY)
97 #include "components/policy/core/browser/browser_policy_connector.h" 99 #include "components/policy/core/browser/browser_policy_connector.h"
98 #else 100 #else
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 base::debug::StackTrace callstack = release_last_reference_callstack_; 320 base::debug::StackTrace callstack = release_last_reference_callstack_;
319 base::debug::Alias(&callstack); 321 base::debug::Alias(&callstack);
320 CHECK(false); 322 CHECK(false);
321 } 323 }
322 324
323 did_start_ = true; 325 did_start_ = true;
324 module_ref_count_++; 326 module_ref_count_++;
325 return module_ref_count_; 327 return module_ref_count_;
326 } 328 }
327 329
330 static void ShutdownServiceWorkerContext(content::StoragePartition* partition) {
331 partition->GetServiceWorkerContext()->Terminate();
332 }
333
328 unsigned int BrowserProcessImpl::ReleaseModule() { 334 unsigned int BrowserProcessImpl::ReleaseModule() {
329 DCHECK(CalledOnValidThread()); 335 DCHECK(CalledOnValidThread());
330 DCHECK_NE(0u, module_ref_count_); 336 DCHECK_NE(0u, module_ref_count_);
331 module_ref_count_--; 337 module_ref_count_--;
332 if (0 == module_ref_count_) { 338 if (0 == module_ref_count_) {
333 release_last_reference_callstack_ = base::debug::StackTrace(); 339 release_last_reference_callstack_ = base::debug::StackTrace();
334 340
341 // Stop service workers
342 ProfileManager* pm = profile_manager();
343 std::vector<Profile*> profiles(pm->GetLoadedProfiles());
344 for (size_t i = 0; i < profiles.size(); ++i) {
345 content::BrowserContext::ForEachStoragePartition(
346 profiles[i], base::Bind(ShutdownServiceWorkerContext));
347 }
348
335 #if defined(ENABLE_PRINTING) 349 #if defined(ENABLE_PRINTING)
336 // Wait for the pending print jobs to finish. Don't do this later, since 350 // Wait for the pending print jobs to finish. Don't do this later, since
337 // this might cause a nested message loop to run, and we don't want pending 351 // this might cause a nested message loop to run, and we don't want pending
338 // tasks to run once teardown has started. 352 // tasks to run once teardown has started.
339 print_job_manager_->Shutdown(); 353 print_job_manager_->Shutdown();
340 #endif 354 #endif
341 355
342 #if defined(LEAK_SANITIZER) 356 #if defined(LEAK_SANITIZER)
343 // Check for memory leaks now, before we start shutting down threads. Doing 357 // Check for memory leaks now, before we start shutting down threads. Doing
344 // this early means we won't report any shutdown-only leaks (as they have 358 // this early means we won't report any shutdown-only leaks (as they have
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 } 1063 }
1050 1064
1051 void BrowserProcessImpl::OnAutoupdateTimer() { 1065 void BrowserProcessImpl::OnAutoupdateTimer() {
1052 if (CanAutorestartForUpdate()) { 1066 if (CanAutorestartForUpdate()) {
1053 DLOG(WARNING) << "Detected update. Restarting browser."; 1067 DLOG(WARNING) << "Detected update. Restarting browser.";
1054 RestartBackgroundInstance(); 1068 RestartBackgroundInstance();
1055 } 1069 }
1056 } 1070 }
1057 1071
1058 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1072 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_service_worker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698