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

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

Issue 2858773002: Revert of PaymentHandler: Implement PaymentInstruments.keys(). (Closed)
Patch Set: Created 3 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_storage.h" 5 #include "content/browser/service_worker/service_worker_storage.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 686 }
687 687
688 database_task_manager_->GetTaskRunner()->PostTask( 688 database_task_manager_->GetTaskRunner()->PostTask(
689 FROM_HERE, 689 FROM_HERE,
690 base::Bind(&ServiceWorkerStorage::GetUserDataInDB, database_.get(), 690 base::Bind(&ServiceWorkerStorage::GetUserDataInDB, database_.get(),
691 base::ThreadTaskRunnerHandle::Get(), registration_id, keys, 691 base::ThreadTaskRunnerHandle::Get(), registration_id, keys,
692 base::Bind(&ServiceWorkerStorage::DidGetUserData, 692 base::Bind(&ServiceWorkerStorage::DidGetUserData,
693 weak_factory_.GetWeakPtr(), callback))); 693 weak_factory_.GetWeakPtr(), callback)));
694 } 694 }
695 695
696 void ServiceWorkerStorage::GetUserDataByKeyPrefix(
697 int64_t registration_id,
698 const std::string& key_prefix,
699 const GetUserDataCallback& callback) {
700 if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::GetUserDataByKeyPrefix,
701 weak_factory_.GetWeakPtr(), registration_id,
702 key_prefix, callback))) {
703 if (state_ != INITIALIZING) {
704 RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
705 SERVICE_WORKER_ERROR_ABORT));
706 }
707 return;
708 }
709 DCHECK_EQ(INITIALIZED, state_);
710
711 if (registration_id == kInvalidServiceWorkerRegistrationId) {
712 RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
713 SERVICE_WORKER_ERROR_FAILED));
714 return;
715 }
716 if (key_prefix.empty()) {
717 RunSoon(FROM_HERE, base::Bind(callback, std::vector<std::string>(),
718 SERVICE_WORKER_ERROR_FAILED));
719 return;
720 }
721
722 database_task_manager_->GetTaskRunner()->PostTask(
723 FROM_HERE,
724 base::Bind(&ServiceWorkerStorage::GetUserDataByKeyPrefixInDB,
725 database_.get(), base::ThreadTaskRunnerHandle::Get(),
726 registration_id, key_prefix,
727 base::Bind(&ServiceWorkerStorage::DidGetUserData,
728 weak_factory_.GetWeakPtr(), callback)));
729 }
730
731 void ServiceWorkerStorage::ClearUserData(int64_t registration_id, 696 void ServiceWorkerStorage::ClearUserData(int64_t registration_id,
732 const std::vector<std::string>& keys, 697 const std::vector<std::string>& keys,
733 const StatusCallback& callback) { 698 const StatusCallback& callback) {
734 if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::ClearUserData, 699 if (!LazyInitialize(base::Bind(&ServiceWorkerStorage::ClearUserData,
735 weak_factory_.GetWeakPtr(), registration_id, 700 weak_factory_.GetWeakPtr(), registration_id,
736 keys, callback))) { 701 keys, callback))) {
737 if (state_ != INITIALIZING) 702 if (state_ != INITIALIZING)
738 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); 703 RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
739 return; 704 return;
740 } 705 }
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 int64_t registration_id, 1764 int64_t registration_id,
1800 const std::vector<std::string>& keys, 1765 const std::vector<std::string>& keys,
1801 const GetUserDataInDBCallback& callback) { 1766 const GetUserDataInDBCallback& callback) {
1802 std::vector<std::string> values; 1767 std::vector<std::string> values;
1803 ServiceWorkerDatabase::Status status = 1768 ServiceWorkerDatabase::Status status =
1804 database->ReadUserData(registration_id, keys, &values); 1769 database->ReadUserData(registration_id, keys, &values);
1805 original_task_runner->PostTask(FROM_HERE, 1770 original_task_runner->PostTask(FROM_HERE,
1806 base::Bind(callback, values, status)); 1771 base::Bind(callback, values, status));
1807 } 1772 }
1808 1773
1809 void ServiceWorkerStorage::GetUserDataByKeyPrefixInDB(
1810 ServiceWorkerDatabase* database,
1811 scoped_refptr<base::SequencedTaskRunner> original_task_runner,
1812 int64_t registration_id,
1813 const std::string& key_prefix,
1814 const GetUserDataInDBCallback& callback) {
1815 std::vector<std::string> values;
1816 ServiceWorkerDatabase::Status status =
1817 database->ReadUserDataByKeyPrefix(registration_id, key_prefix, &values);
1818 original_task_runner->PostTask(FROM_HERE,
1819 base::Bind(callback, values, status));
1820 }
1821
1822 void ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB( 1774 void ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB(
1823 ServiceWorkerDatabase* database, 1775 ServiceWorkerDatabase* database,
1824 scoped_refptr<base::SequencedTaskRunner> original_task_runner, 1776 scoped_refptr<base::SequencedTaskRunner> original_task_runner,
1825 const std::string& key, 1777 const std::string& key,
1826 const GetUserDataForAllRegistrationsInDBCallback& callback) { 1778 const GetUserDataForAllRegistrationsInDBCallback& callback) {
1827 std::vector<std::pair<int64_t, std::string>> user_data; 1779 std::vector<std::pair<int64_t, std::string>> user_data;
1828 ServiceWorkerDatabase::Status status = 1780 ServiceWorkerDatabase::Status status =
1829 database->ReadUserDataForAllRegistrations(key, &user_data); 1781 database->ReadUserDataForAllRegistrations(key, &user_data);
1830 original_task_runner->PostTask(FROM_HERE, 1782 original_task_runner->PostTask(FROM_HERE,
1831 base::Bind(callback, user_data, status)); 1783 base::Bind(callback, user_data, status));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1850 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1899 return; 1851 return;
1900 } 1852 }
1901 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1853 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1902 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1854 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1903 ServiceWorkerMetrics::DELETE_OK); 1855 ServiceWorkerMetrics::DELETE_OK);
1904 callback.Run(SERVICE_WORKER_OK); 1856 callback.Run(SERVICE_WORKER_OK);
1905 } 1857 }
1906 1858
1907 } // namespace content 1859 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698