| 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 <vector> | 10 #include <vector> |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 const GetUsageInfoCallback& callback) { | 329 const GetUsageInfoCallback& callback) { |
| 330 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 330 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 331 if (!context_core_.get()) { | 331 if (!context_core_.get()) { |
| 332 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; | 332 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; |
| 333 BrowserThread::PostTask( | 333 BrowserThread::PostTask( |
| 334 BrowserThread::IO, | 334 BrowserThread::IO, |
| 335 FROM_HERE, | 335 FROM_HERE, |
| 336 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); | 336 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 context()->storage()->GetAllRegistrations(base::Bind( | 339 context()->storage()->GetAllRegistrationsInfos(base::Bind( |
| 340 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, | 340 &ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins, |
| 341 this, | 341 this, callback)); |
| 342 callback)); | |
| 343 } | 342 } |
| 344 | 343 |
| 345 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins( | 344 void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins( |
| 346 const GetUsageInfoCallback& callback, | 345 const GetUsageInfoCallback& callback, |
| 347 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { | 346 const std::vector<ServiceWorkerRegistrationInfo>& registrations) { |
| 348 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 347 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 349 std::vector<ServiceWorkerUsageInfo> usage_infos; | 348 std::vector<ServiceWorkerUsageInfo> usage_infos; |
| 350 | 349 |
| 351 std::map<GURL, ServiceWorkerUsageInfo> origins; | 350 std::map<GURL, ServiceWorkerUsageInfo> origins; |
| 352 for (const auto& registration_info : registrations) { | 351 for (const auto& registration_info : registrations) { |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 callback); | 514 callback); |
| 516 } | 515 } |
| 517 | 516 |
| 518 void ServiceWorkerContextWrapper::GetAllRegistrations( | 517 void ServiceWorkerContextWrapper::GetAllRegistrations( |
| 519 const GetRegistrationsInfosCallback& callback) { | 518 const GetRegistrationsInfosCallback& callback) { |
| 520 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 519 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 521 if (!context_core_) { | 520 if (!context_core_) { |
| 522 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>())); | 521 RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>())); |
| 523 return; | 522 return; |
| 524 } | 523 } |
| 525 context_core_->storage()->GetAllRegistrations(callback); | 524 context_core_->storage()->GetAllRegistrationsInfos(callback); |
| 526 } | 525 } |
| 527 | 526 |
| 528 void ServiceWorkerContextWrapper::GetRegistrationUserData( | 527 void ServiceWorkerContextWrapper::GetRegistrationUserData( |
| 529 int64_t registration_id, | 528 int64_t registration_id, |
| 530 const std::string& key, | 529 const std::string& key, |
| 531 const GetUserDataCallback& callback) { | 530 const GetUserDataCallback& callback) { |
| 532 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 531 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 533 if (!context_core_) { | 532 if (!context_core_) { |
| 534 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT)); | 533 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT)); |
| 535 return; | 534 return; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 observer_list_->Notify(FROM_HERE, | 639 observer_list_->Notify(FROM_HERE, |
| 641 &ServiceWorkerContextObserver::OnStorageWiped); | 640 &ServiceWorkerContextObserver::OnStorageWiped); |
| 642 } | 641 } |
| 643 | 642 |
| 644 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 643 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 645 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 644 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 646 return context_core_.get(); | 645 return context_core_.get(); |
| 647 } | 646 } |
| 648 | 647 |
| 649 } // namespace content | 648 } // namespace content |
| OLD | NEW |