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

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

Issue 1146913004: Service Worker: Add ServiceWorkerContainer.getRegistrations() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tools/metrics/histograms/histograms.xml. Created 5 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
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 <vector> 10 #include <vector>
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const GetUsageInfoCallback& callback) { 332 const GetUsageInfoCallback& callback) {
333 DCHECK_CURRENTLY_ON(BrowserThread::IO); 333 DCHECK_CURRENTLY_ON(BrowserThread::IO);
334 if (!context_core_.get()) { 334 if (!context_core_.get()) {
335 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; 335 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive.";
336 BrowserThread::PostTask( 336 BrowserThread::PostTask(
337 BrowserThread::IO, 337 BrowserThread::IO,
338 FROM_HERE, 338 FROM_HERE,
339 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); 339 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>()));
340 return; 340 return;
341 } 341 }
342 context()->storage()->GetAllRegistrations(base::Bind( 342 context()->storage()->GetAllRegistrationsInfos(base::Bind(
343 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, 343 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins,
344 this, 344 this, callback));
345 callback));
346 } 345 }
347 346
348 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins( 347 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins(
349 const GetUsageInfoCallback& callback, 348 const GetUsageInfoCallback& callback,
350 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { 349 const std::vector<ServiceWorkerRegistrationInfo>& registrations) {
351 DCHECK_CURRENTLY_ON(BrowserThread::IO); 350 DCHECK_CURRENTLY_ON(BrowserThread::IO);
352 std::vector<ServiceWorkerUsageInfo> usage_infos; 351 std::vector<ServiceWorkerUsageInfo> usage_infos;
353 352
354 std::map<GURL, ServiceWorkerUsageInfo> origins; 353 std::map<GURL, ServiceWorkerUsageInfo> origins;
355 for (const auto& registration_info : registrations) { 354 for (const auto& registration_info : registrations) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 origin.GetOrigin(), callback); 518 origin.GetOrigin(), callback);
520 } 519 }
521 520
522 void ServiceWorkerContextWrapper::GetAllRegistrations( 521 void ServiceWorkerContextWrapper::GetAllRegistrations(
523 const GetRegistrationsInfosCallback& callback) { 522 const GetRegistrationsInfosCallback& callback) {
524 DCHECK_CURRENTLY_ON(BrowserThread::IO); 523 DCHECK_CURRENTLY_ON(BrowserThread::IO);
525 if (!context_core_) { 524 if (!context_core_) {
526 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>())); 525 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>()));
527 return; 526 return;
528 } 527 }
529 context_core_->storage()->GetAllRegistrations(callback); 528 context_core_->storage()->GetAllRegistrationsInfos(callback);
530 } 529 }
531 530
532 void ServiceWorkerContextWrapper::GetRegistrationUserData( 531 void ServiceWorkerContextWrapper::GetRegistrationUserData(
533 int64_t registration_id, 532 int64_t registration_id,
534 const std::string& key, 533 const std::string& key,
535 const GetUserDataCallback& callback) { 534 const GetUserDataCallback& callback) {
536 DCHECK_CURRENTLY_ON(BrowserThread::IO); 535 DCHECK_CURRENTLY_ON(BrowserThread::IO);
537 if (!context_core_) { 536 if (!context_core_) {
538 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT)); 537 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT));
539 return; 538 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 observer_list_->Notify(FROM_HERE, 643 observer_list_->Notify(FROM_HERE,
645 &ServiceWorkerContextObserver::OnStorageWiped); 644 &ServiceWorkerContextObserver::OnStorageWiped);
646 } 645 }
647 646
648 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 647 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
649 DCHECK_CURRENTLY_ON(BrowserThread::IO); 648 DCHECK_CURRENTLY_ON(BrowserThread::IO);
650 return context_core_.get(); 649 return context_core_.get();
651 } 650 }
652 651
653 } // namespace content 652 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698