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

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

Issue 2873683002: PaymentHandler: Implement GetAllPaymentApps(). (Closed)
Patch Set: installed -> stored in public 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 base::Bind( 793 base::Bind(
794 &ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB, 794 &ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB,
795 database_.get(), 795 database_.get(),
796 base::ThreadTaskRunnerHandle::Get(), 796 base::ThreadTaskRunnerHandle::Get(),
797 key, 797 key,
798 base::Bind(&ServiceWorkerStorage::DidGetUserDataForAllRegistrations, 798 base::Bind(&ServiceWorkerStorage::DidGetUserDataForAllRegistrations,
799 weak_factory_.GetWeakPtr(), 799 weak_factory_.GetWeakPtr(),
800 callback))); 800 callback)));
801 } 801 }
802 802
803 void ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefix(
804 const std::string& key_prefix,
805 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback&
806 callback) {
807 if (!LazyInitialize(base::Bind(
808 &ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefix,
809 weak_factory_.GetWeakPtr(), key_prefix, callback))) {
810 if (state_ != INITIALIZING) {
811 RunSoon(
812 FROM_HERE,
813 base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(),
814 SERVICE_WORKER_ERROR_ABORT));
815 }
816 return;
817 }
818 DCHECK_EQ(INITIALIZED, state_);
819
820 if (key_prefix.empty()) {
821 RunSoon(FROM_HERE,
822 base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(),
823 SERVICE_WORKER_ERROR_FAILED));
824 return;
825 }
826
827 database_task_manager_->GetTaskRunner()->PostTask(
828 FROM_HERE,
829 base::Bind(
830 &ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefixInDB,
831 database_.get(), base::ThreadTaskRunnerHandle::Get(), key_prefix,
832 base::Bind(&ServiceWorkerStorage::DidGetUserDataForAllRegistrations,
833 weak_factory_.GetWeakPtr(), callback)));
834 }
835
803 bool ServiceWorkerStorage::OriginHasForeignFetchRegistrations( 836 bool ServiceWorkerStorage::OriginHasForeignFetchRegistrations(
804 const GURL& origin) { 837 const GURL& origin) {
805 return !IsDisabled() && 838 return !IsDisabled() &&
806 foreign_fetch_origins_.find(origin) != foreign_fetch_origins_.end(); 839 foreign_fetch_origins_.find(origin) != foreign_fetch_origins_.end();
807 } 840 }
808 841
809 void ServiceWorkerStorage::DeleteAndStartOver(const StatusCallback& callback) { 842 void ServiceWorkerStorage::DeleteAndStartOver(const StatusCallback& callback) {
810 Disable(); 843 Disable();
811 844
812 // Delete the database on the database thread. 845 // Delete the database on the database thread.
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 scoped_refptr<base::SequencedTaskRunner> original_task_runner, 1857 scoped_refptr<base::SequencedTaskRunner> original_task_runner,
1825 const std::string& key, 1858 const std::string& key,
1826 const GetUserDataForAllRegistrationsInDBCallback& callback) { 1859 const GetUserDataForAllRegistrationsInDBCallback& callback) {
1827 std::vector<std::pair<int64_t, std::string>> user_data; 1860 std::vector<std::pair<int64_t, std::string>> user_data;
1828 ServiceWorkerDatabase::Status status = 1861 ServiceWorkerDatabase::Status status =
1829 database->ReadUserDataForAllRegistrations(key, &user_data); 1862 database->ReadUserDataForAllRegistrations(key, &user_data);
1830 original_task_runner->PostTask(FROM_HERE, 1863 original_task_runner->PostTask(FROM_HERE,
1831 base::Bind(callback, user_data, status)); 1864 base::Bind(callback, user_data, status));
1832 } 1865 }
1833 1866
1867 void ServiceWorkerStorage::GetUserDataForAllRegistrationsByKeyPrefixInDB(
1868 ServiceWorkerDatabase* database,
1869 scoped_refptr<base::SequencedTaskRunner> original_task_runner,
1870 const std::string& key_prefix,
1871 const GetUserDataForAllRegistrationsInDBCallback& callback) {
1872 std::vector<std::pair<int64_t, std::string>> user_data;
1873 ServiceWorkerDatabase::Status status =
1874 database->ReadUserDataForAllRegistrationsByKeyPrefix(key_prefix,
1875 &user_data);
1876 original_task_runner->PostTask(FROM_HERE,
1877 base::Bind(callback, user_data, status));
1878 }
1879
1834 void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB( 1880 void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB(
1835 ServiceWorkerDatabase* database, 1881 ServiceWorkerDatabase* database,
1836 const std::set<GURL>& origins) { 1882 const std::set<GURL>& origins) {
1837 DCHECK(database); 1883 DCHECK(database);
1838 1884
1839 std::vector<int64_t> newly_purgeable_resources; 1885 std::vector<int64_t> newly_purgeable_resources;
1840 database->DeleteAllDataForOrigins(origins, &newly_purgeable_resources); 1886 database->DeleteAllDataForOrigins(origins, &newly_purgeable_resources);
1841 } 1887 }
1842 1888
1843 bool ServiceWorkerStorage::IsDisabled() const { 1889 bool ServiceWorkerStorage::IsDisabled() const {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1944 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1899 return; 1945 return;
1900 } 1946 }
1901 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1947 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1902 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( 1948 ServiceWorkerMetrics::RecordDeleteAndStartOverResult(
1903 ServiceWorkerMetrics::DELETE_OK); 1949 ServiceWorkerMetrics::DELETE_OK);
1904 callback.Run(SERVICE_WORKER_OK); 1950 callback.Run(SERVICE_WORKER_OK);
1905 } 1951 }
1906 1952
1907 } // namespace content 1953 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_storage.h ('k') | content/public/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698