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

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

Issue 1940993002: DevTools: simplify Service Workers panel UI, remove non-actionable data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // |registration| is 1, it will be deleted after WorkerStarted is called. 63 // |registration| is 1, it will be deleted after WorkerStarted is called.
64 registration->active_version()->StartWorker( 64 registration->active_version()->StartWorker(
65 ServiceWorkerMetrics::EventType::UNKNOWN, 65 ServiceWorkerMetrics::EventType::UNKNOWN,
66 base::Bind(WorkerStarted, callback)); 66 base::Bind(WorkerStarted, callback));
67 return; 67 return;
68 } 68 }
69 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 69 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
70 base::Bind(callback, SERVICE_WORKER_ERROR_NOT_FOUND)); 70 base::Bind(callback, SERVICE_WORKER_ERROR_NOT_FOUND));
71 } 71 }
72 72
73 void SkipWaitingWorkerOnIO(
74 ServiceWorkerStatusCode status,
75 const scoped_refptr<ServiceWorkerRegistration>& registration) {
76 DCHECK_CURRENTLY_ON(BrowserThread::IO);
77 if (status == SERVICE_WORKER_OK) {
78 if (registration->waiting_version()) {
caseq 2016/05/05 01:09:21 nit: if (status != SERVICE_WORKER_ON || !registrat
pfeldman 2016/05/05 02:21:41 Done.
79 registration->waiting_version()->set_skip_waiting(true);
80 registration->ActivateWaitingVersionWhenReady();
81 }
82 }
83 }
84
73 } // namespace 85 } // namespace
74 86
75 void ServiceWorkerContext::AddExcludedHeadersForFetchEvent( 87 void ServiceWorkerContext::AddExcludedHeadersForFetchEvent(
76 const std::set<std::string>& header_names) { 88 const std::set<std::string>& header_names) {
77 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 89 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
78 tracked_objects::ScopedTracker tracking_profile( 90 tracked_objects::ScopedTracker tracking_profile(
79 FROM_HERE_WITH_EXPLICIT_FUNCTION( 91 FROM_HERE_WITH_EXPLICIT_FUNCTION(
80 "477117 ServiceWorkerContext::AddExcludedHeadersForFetchEvent")); 92 "477117 ServiceWorkerContext::AddExcludedHeadersForFetchEvent"));
81 DCHECK_CURRENTLY_ON(BrowserThread::IO); 93 DCHECK_CURRENTLY_ON(BrowserThread::IO);
82 g_excluded_header_name_set.Get().insert(header_names.begin(), 94 g_excluded_header_name_set.Get().insert(header_names.begin(),
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (!context_core_) { 296 if (!context_core_) {
285 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 297 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
286 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); 298 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
287 return; 299 return;
288 } 300 }
289 context_core_->storage()->FindRegistrationForPattern( 301 context_core_->storage()->FindRegistrationForPattern(
290 net::SimplifyUrlForRequest(pattern), 302 net::SimplifyUrlForRequest(pattern),
291 base::Bind(&StartActiveWorkerOnIO, callback)); 303 base::Bind(&StartActiveWorkerOnIO, callback));
292 } 304 }
293 305
306 void ServiceWorkerContextWrapper::SkipWaitingWorker(const GURL& pattern) {
307 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
308 BrowserThread::PostTask(
309 BrowserThread::IO, FROM_HERE,
310 base::Bind(&ServiceWorkerContextWrapper::SkipWaitingWorker, this,
311 pattern));
312 return;
313 }
314 if (!context_core_)
315 return;
316 context_core_->storage()->FindRegistrationForPattern(
caseq 2016/05/05 01:09:21 Let's extract something like dispatchOnRegistratio
pfeldman 2016/05/05 02:21:41 It is a common pattern that SW uses to hop between
317 net::SimplifyUrlForRequest(pattern), base::Bind(&SkipWaitingWorkerOnIO));
318 }
319
294 void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad( 320 void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad(
295 bool force_update_on_page_load) { 321 bool force_update_on_page_load) {
296 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 322 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
297 BrowserThread::PostTask( 323 BrowserThread::PostTask(
298 BrowserThread::IO, FROM_HERE, 324 BrowserThread::IO, FROM_HERE,
299 base::Bind(&ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad, this, 325 base::Bind(&ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad, this,
300 force_update_on_page_load)); 326 force_update_on_page_load));
301 return; 327 return;
302 } 328 }
303 if (!context_core_) 329 if (!context_core_)
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 observer_list_->Notify(FROM_HERE, 741 observer_list_->Notify(FROM_HERE,
716 &ServiceWorkerContextObserver::OnStorageWiped); 742 &ServiceWorkerContextObserver::OnStorageWiped);
717 } 743 }
718 744
719 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 745 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
720 DCHECK_CURRENTLY_ON(BrowserThread::IO); 746 DCHECK_CURRENTLY_ON(BrowserThread::IO);
721 return context_core_.get(); 747 return context_core_.get();
722 } 748 }
723 749
724 } // namespace content 750 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698