| 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (!context_core_) { | 590 if (!context_core_) { |
| 591 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, | 591 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, |
| 592 std::vector<ServiceWorkerRegistrationInfo>())); | 592 std::vector<ServiceWorkerRegistrationInfo>())); |
| 593 return; | 593 return; |
| 594 } | 594 } |
| 595 context_core_->storage()->GetAllRegistrationsInfos(callback); | 595 context_core_->storage()->GetAllRegistrationsInfos(callback); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void ServiceWorkerContextWrapper::GetRegistrationUserData( | 598 void ServiceWorkerContextWrapper::GetRegistrationUserData( |
| 599 int64_t registration_id, | 599 int64_t registration_id, |
| 600 const std::string& key, | 600 const std::vector<std::string>& keys, |
| 601 const GetUserDataCallback& callback) { | 601 const GetUserDataCallback& callback) { |
| 602 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 602 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 603 if (!context_core_) { | 603 if (!context_core_) { |
| 604 RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT)); | 604 RunSoon(base::Bind(callback, std::vector<std::string>(), |
| 605 SERVICE_WORKER_ERROR_ABORT)); |
| 605 return; | 606 return; |
| 606 } | 607 } |
| 607 context_core_->storage()->GetUserData(registration_id, key, callback); | 608 context_core_->storage()->GetUserData(registration_id, keys, callback); |
| 608 } | 609 } |
| 609 | 610 |
| 610 void ServiceWorkerContextWrapper::StoreRegistrationUserData( | 611 void ServiceWorkerContextWrapper::StoreRegistrationUserData( |
| 611 int64_t registration_id, | 612 int64_t registration_id, |
| 612 const GURL& origin, | 613 const GURL& origin, |
| 613 const std::string& key, | 614 const std::vector<std::pair<std::string, std::string>>& key_value_pairs, |
| 614 const std::string& data, | |
| 615 const StatusCallback& callback) { | 615 const StatusCallback& callback) { |
| 616 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 616 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 617 if (!context_core_) { | 617 if (!context_core_) { |
| 618 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); | 618 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); |
| 619 return; | 619 return; |
| 620 } | 620 } |
| 621 context_core_->storage()->StoreUserData(registration_id, origin.GetOrigin(), | 621 context_core_->storage()->StoreUserData(registration_id, origin.GetOrigin(), |
| 622 key, data, callback); | 622 key_value_pairs, callback); |
| 623 } | 623 } |
| 624 | 624 |
| 625 void ServiceWorkerContextWrapper::ClearRegistrationUserData( | 625 void ServiceWorkerContextWrapper::ClearRegistrationUserData( |
| 626 int64_t registration_id, | 626 int64_t registration_id, |
| 627 const std::string& key, | 627 const std::vector<std::string>& keys, |
| 628 const StatusCallback& callback) { | 628 const StatusCallback& callback) { |
| 629 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 629 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 630 if (!context_core_) { | 630 if (!context_core_) { |
| 631 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); | 631 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); |
| 632 return; | 632 return; |
| 633 } | 633 } |
| 634 context_core_->storage()->ClearUserData(registration_id, key, callback); | 634 context_core_->storage()->ClearUserData(registration_id, keys, callback); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void ServiceWorkerContextWrapper::GetUserDataForAllRegistrations( | 637 void ServiceWorkerContextWrapper::GetUserDataForAllRegistrations( |
| 638 const std::string& key, | 638 const std::string& key, |
| 639 const GetUserDataForAllRegistrationsCallback& callback) { | 639 const GetUserDataForAllRegistrationsCallback& callback) { |
| 640 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 640 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 641 if (!context_core_) { | 641 if (!context_core_) { |
| 642 RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), | 642 RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), |
| 643 SERVICE_WORKER_ERROR_ABORT)); | 643 SERVICE_WORKER_ERROR_ABORT)); |
| 644 return; | 644 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 observer_list_->Notify(FROM_HERE, | 715 observer_list_->Notify(FROM_HERE, |
| 716 &ServiceWorkerContextObserver::OnStorageWiped); | 716 &ServiceWorkerContextObserver::OnStorageWiped); |
| 717 } | 717 } |
| 718 | 718 |
| 719 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 719 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 720 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 720 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 721 return context_core_.get(); | 721 return context_core_.get(); |
| 722 } | 722 } |
| 723 | 723 |
| 724 } // namespace content | 724 } // namespace content |
| OLD | NEW |