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

Unified Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 1079923002: ServiceWorker: Stop exposing ServiceWorkerContextCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_wrapper.cc
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
index 0c092519cd722da3b6c7076ae94d4cbc750753a7..db7262236633fd80ad3489a9217ff3a4a778b386 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -147,11 +147,6 @@ void ServiceWorkerContextWrapper::DeleteAndStartOver() {
base::Bind(&ServiceWorkerContextWrapper::DidDeleteAndStartOver, this));
}
-ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- return context_core_.get();
-}
-
StoragePartitionImpl* ServiceWorkerContextWrapper::storage_partition() const {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return storage_partition_;
@@ -432,6 +427,125 @@ void ServiceWorkerContextWrapper::CheckHasServiceWorker(
this, other_url, callback));
}
+ServiceWorkerRegistration* ServiceWorkerContextWrapper::GetLiveRegistration(
+ int64_t registration_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_)
+ return nullptr;
+ return context_core_->GetLiveRegistration(registration_id);
+}
+
+ServiceWorkerVersion* ServiceWorkerContextWrapper::GetLiveVersion(
+ int64_t version_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_)
+ return nullptr;
+ return context_core_->GetLiveVersion(version_id);
+}
+
+std::vector<ServiceWorkerRegistrationInfo>
+ServiceWorkerContextWrapper::GetAllLiveRegistrationInfo() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_)
+ return std::vector<ServiceWorkerRegistrationInfo>();
+ return context_core_->GetAllLiveRegistrationInfo();
+}
+
+std::vector<ServiceWorkerVersionInfo>
+ServiceWorkerContextWrapper::GetAllLiveVersionInfo() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_)
+ return std::vector<ServiceWorkerVersionInfo>();
+ return context_core_->GetAllLiveVersionInfo();
+}
+
+void ServiceWorkerContextWrapper::FindRegistrationForDocument(
+ const GURL& document_url,
+ const FindRegistrationCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ // FindRegistrationForDocument() can run the callback synchronously.
+ callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr);
+ return;
+ }
+ context_core_->storage()->FindRegistrationForDocument(document_url, callback);
+}
+
+void ServiceWorkerContextWrapper::FindRegistrationForId(
+ int64_t registration_id,
+ const GURL& origin,
+ const FindRegistrationCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ // FindRegistrationForId() can run the callback synchronously.
+ callback.Run(SERVICE_WORKER_ERROR_ABORT, nullptr);
+ return;
+ }
+ context_core_->storage()->FindRegistrationForId(registration_id, origin,
+ callback);
+}
+
+void ServiceWorkerContextWrapper::GetAllRegistrations(
+ const GetRegistrationsInfosCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ RunSoon(base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>()));
+ return;
+ }
+ context_core_->storage()->GetAllRegistrations(callback);
+}
+
+void ServiceWorkerContextWrapper::GetRegistrationUserData(
+ int64_t registration_id,
+ const std::string& key,
+ const GetUserDataCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ RunSoon(base::Bind(callback, std::string(), SERVICE_WORKER_ERROR_ABORT));
+ return;
+ }
+ context_core_->storage()->GetUserData(registration_id, key, callback);
+}
+
+void ServiceWorkerContextWrapper::StoreRegistrationUserData(
+ int64_t registration_id,
+ const GURL& origin,
+ const std::string& key,
+ const std::string& data,
+ const StatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
+ return;
+ }
+ context_core_->storage()->StoreUserData(registration_id, origin, key, data,
+ callback);
+}
+
+void ServiceWorkerContextWrapper::ClearRegistrationUserData(
+ int64_t registration_id,
+ const std::string& key,
+ const StatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_ABORT));
+ return;
+ }
+ context_core_->storage()->ClearUserData(registration_id, key, callback);
+}
+
+void ServiceWorkerContextWrapper::GetUserDataForAllRegistrations(
+ const std::string& key,
+ const GetUserDataForAllRegistrationsCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!context_core_) {
+ RunSoon(base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(),
+ SERVICE_WORKER_ERROR_ABORT));
+ return;
+ }
+ context_core_->storage()->GetUserDataForAllRegistrations(key, callback);
+}
+
void ServiceWorkerContextWrapper::AddObserver(
ServiceWorkerContextObserver* observer) {
observer_list_->AddObserver(observer);
@@ -497,4 +611,9 @@ void ServiceWorkerContextWrapper::DidDeleteAndStartOver(
&ServiceWorkerContextObserver::OnStorageWiped);
}
+ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ return context_core_.get();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698