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

Side by Side Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 2575523002: Prerender: Confirm ServiceWorkers are invoked for NoState Prefetch (Closed)
Patch Set: Check that SW runs rather than disabling Created 3 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/service_worker/service_worker_context_wrapper.h" 5 #include "content/browser/service_worker/service_worker_context_wrapper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 case blink::WebNavigationHintType::LinkTapUnconfirmed: 94 case blink::WebNavigationHintType::LinkTapUnconfirmed:
95 return ServiceWorkerMetrics::EventType:: 95 return ServiceWorkerMetrics::EventType::
96 NAVIGATION_HINT_LINK_TAP_UNCONFIRMED; 96 NAVIGATION_HINT_LINK_TAP_UNCONFIRMED;
97 case blink::WebNavigationHintType::LinkTapDown: 97 case blink::WebNavigationHintType::LinkTapDown:
98 return ServiceWorkerMetrics::EventType::NAVIGATION_HINT_LINK_TAP_DOWN; 98 return ServiceWorkerMetrics::EventType::NAVIGATION_HINT_LINK_TAP_DOWN;
99 } 99 }
100 NOTREACHED() << "Unexpected navigation hint" << static_cast<int>(type); 100 NOTREACHED() << "Unexpected navigation hint" << static_cast<int>(type);
101 return ServiceWorkerMetrics::EventType::UNKNOWN; 101 return ServiceWorkerMetrics::EventType::UNKNOWN;
102 } 102 }
103 103
104 void Noop() {}
105
106 void StatusCallbackRunner(const base::Closure& callback,
107 ServiceWorkerStatusCode status) {
108 callback.Run();
109 }
110
104 } // namespace 111 } // namespace
105 112
106 void ServiceWorkerContext::AddExcludedHeadersForFetchEvent( 113 void ServiceWorkerContext::AddExcludedHeadersForFetchEvent(
107 const std::set<std::string>& header_names) { 114 const std::set<std::string>& header_names) {
108 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 115 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
109 tracked_objects::ScopedTracker tracking_profile( 116 tracked_objects::ScopedTracker tracking_profile(
110 FROM_HERE_WITH_EXPLICIT_FUNCTION( 117 FROM_HERE_WITH_EXPLICIT_FUNCTION(
111 "477117 ServiceWorkerContext::AddExcludedHeadersForFetchEvent")); 118 "477117 ServiceWorkerContext::AddExcludedHeadersForFetchEvent"));
112 DCHECK_CURRENTLY_ON(BrowserThread::IO); 119 DCHECK_CURRENTLY_ON(BrowserThread::IO);
113 g_excluded_header_name_set.Get().insert(header_names.begin(), 120 g_excluded_header_name_set.Get().insert(header_names.begin(),
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 const CheckHasServiceWorkerCallback& callback, 490 const CheckHasServiceWorkerCallback& callback,
484 bool has_service_worker) { 491 bool has_service_worker) {
485 DCHECK_CURRENTLY_ON(BrowserThread::IO); 492 DCHECK_CURRENTLY_ON(BrowserThread::IO);
486 493
487 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 494 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
488 base::Bind(callback, has_service_worker)); 495 base::Bind(callback, has_service_worker));
489 } 496 }
490 497
491 void ServiceWorkerContextWrapper::StopAllServiceWorkersForOrigin( 498 void ServiceWorkerContextWrapper::StopAllServiceWorkersForOrigin(
492 const GURL& origin) { 499 const GURL& origin) {
500 StopAllServiceWorkersForOriginWithCallback(origin, base::Bind(&Noop));
pasko 2017/01/02 18:15:36 base::DoNothing
mattcary 2017/01/03 09:00:03 Ah, thanks, I was looking in callback_helpers.h, s
501 }
502
503 void ServiceWorkerContextWrapper::StopAllServiceWorkersForOriginWithCallback(
504 const GURL& origin,
505 const base::Closure& callback) {
493 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 506 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
494 BrowserThread::PostTask( 507 BrowserThread::PostTask(
495 BrowserThread::IO, FROM_HERE, 508 BrowserThread::IO, FROM_HERE,
496 base::Bind(&ServiceWorkerContextWrapper::StopAllServiceWorkersForOrigin, 509 base::Bind(&ServiceWorkerContextWrapper::
497 this, origin)); 510 StopAllServiceWorkersForOriginWithCallback,
511 this, origin, callback));
498 return; 512 return;
499 } 513 }
500 if (!context_core_.get()) { 514 if (!context_core_.get()) {
501 return; 515 return;
502 } 516 }
503 std::vector<ServiceWorkerVersionInfo> live_versions = GetAllLiveVersionInfo(); 517 std::vector<ServiceWorkerVersionInfo> live_versions = GetAllLiveVersionInfo();
504 for (const ServiceWorkerVersionInfo& info : live_versions) { 518 for (const ServiceWorkerVersionInfo& info : live_versions) {
505 ServiceWorkerVersion* version = GetLiveVersion(info.version_id); 519 ServiceWorkerVersion* version = GetLiveVersion(info.version_id);
506 if (version && version->scope().GetOrigin() == origin) 520 if (version && version->scope().GetOrigin() == origin)
507 version->StopWorker(base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 521 version->StopWorker(base::Bind(&StatusCallbackRunner, callback));
508 } 522 }
509 } 523 }
510 524
511 void ServiceWorkerContextWrapper::DidFindRegistrationForUpdate( 525 void ServiceWorkerContextWrapper::DidFindRegistrationForUpdate(
512 ServiceWorkerStatusCode status, 526 ServiceWorkerStatusCode status,
513 scoped_refptr<ServiceWorkerRegistration> registration) { 527 scoped_refptr<ServiceWorkerRegistration> registration) {
514 DCHECK_CURRENTLY_ON(BrowserThread::IO); 528 DCHECK_CURRENTLY_ON(BrowserThread::IO);
515 529
516 if (status != SERVICE_WORKER_OK) 530 if (status != SERVICE_WORKER_OK)
517 return; 531 return;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 observer_list_->Notify(FROM_HERE, 922 observer_list_->Notify(FROM_HERE,
909 &ServiceWorkerContextObserver::OnStorageWiped); 923 &ServiceWorkerContextObserver::OnStorageWiped);
910 } 924 }
911 925
912 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 926 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
913 DCHECK_CURRENTLY_ON(BrowserThread::IO); 927 DCHECK_CURRENTLY_ON(BrowserThread::IO);
914 return context_core_.get(); 928 return context_core_.get();
915 } 929 }
916 930
917 } // namespace content 931 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698