| OLD | NEW |
| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); | 302 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); |
| 303 return; | 303 return; |
| 304 } | 304 } |
| 305 context()->storage()->GetAllRegistrationsInfos(base::Bind( | 305 context()->storage()->GetAllRegistrationsInfos(base::Bind( |
| 306 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, | 306 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, |
| 307 this, callback)); | 307 this, callback)); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins( | 310 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins( |
| 311 const GetUsageInfoCallback& callback, | 311 const GetUsageInfoCallback& callback, |
| 312 ServiceWorkerStatusCode status, |
| 312 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 313 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 313 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 314 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 314 std::vector<ServiceWorkerUsageInfo> usage_infos; | 315 std::vector<ServiceWorkerUsageInfo> usage_infos; |
| 315 | 316 |
| 316 std::map<GURL, ServiceWorkerUsageInfo> origins; | 317 std::map<GURL, ServiceWorkerUsageInfo> origins; |
| 317 for (const auto& registration_info : registrations) { | 318 for (const auto& registration_info : registrations) { |
| 318 GURL origin = registration_info.pattern.GetOrigin(); | 319 GURL origin = registration_info.pattern.GetOrigin(); |
| 319 | 320 |
| 320 ServiceWorkerUsageInfo& usage_info = origins[origin]; | 321 ServiceWorkerUsageInfo& usage_info = origins[origin]; |
| 321 if (usage_info.origin.is_empty()) | 322 if (usage_info.origin.is_empty()) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); | 568 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr); |
| 568 return; | 569 return; |
| 569 } | 570 } |
| 570 callback.Run(SERVICE_WORKER_OK, registration); | 571 callback.Run(SERVICE_WORKER_OK, registration); |
| 571 } | 572 } |
| 572 | 573 |
| 573 void ServiceWorkerContextWrapper::GetAllRegistrations( | 574 void ServiceWorkerContextWrapper::GetAllRegistrations( |
| 574 const GetRegistrationsInfosCallback& callback) { | 575 const GetRegistrationsInfosCallback& callback) { |
| 575 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 576 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 576 if (!context_core_) { | 577 if (!context_core_) { |
| 577 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>())); | 578 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, |
| 579 std::vector<ServiceWorkerRegistrationInfo>())); |
| 578 return; | 580 return; |
| 579 } | 581 } |
| 580 context_core_->storage()->GetAllRegistrationsInfos(callback); | 582 context_core_->storage()->GetAllRegistrationsInfos(callback); |
| 581 } | 583 } |
| 582 | 584 |
| 583 void ServiceWorkerContextWrapper::GetRegistrationUserData( | 585 void ServiceWorkerContextWrapper::GetRegistrationUserData( |
| 584 int64_t registration_id, | 586 int64_t registration_id, |
| 585 const std::string& key, | 587 const std::string& key, |
| 586 const GetUserDataCallback& callback) { | 588 const GetUserDataCallback& callback) { |
| 587 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 589 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 observer_list_->Notify(FROM_HERE, | 702 observer_list_->Notify(FROM_HERE, |
| 701 &ServiceWorkerContextObserver::OnStorageWiped); | 703 &ServiceWorkerContextObserver::OnStorageWiped); |
| 702 } | 704 } |
| 703 | 705 |
| 704 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 706 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 705 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 707 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 706 return context_core_.get(); | 708 return context_core_.get(); |
| 707 } | 709 } |
| 708 | 710 |
| 709 } // namespace content | 711 } // namespace content |
| OLD | NEW |