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

Unified Diff: content/browser/service_worker/service_worker_internals_ui.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_internals_ui.cc
diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc
index 0a0df729c797cffd1b037e85696ce1fbe29c3792..2176eb75946b79d9357034e99dc6cec3c62cc055 100644
--- a/content/browser/service_worker/service_worker_internals_ui.cc
+++ b/content/browser/service_worker/service_worker_internals_ui.cc
@@ -78,13 +78,8 @@ void CallServiceWorkerVersionMethodWithVersionID(
return;
}
- if (!context->context()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
-
scoped_refptr<ServiceWorkerVersion> version =
- context->context()->GetLiveVersion(version_id);
+ context->GetLiveVersion(version_id);
if (!version.get()) {
callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
return;
@@ -107,13 +102,8 @@ void DispatchPushEventWithVersionID(
return;
}
- if (!context->context()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
-
scoped_refptr<ServiceWorkerVersion> version =
- context->context()->GetLiveVersion(version_id);
+ context->GetLiveVersion(version_id);
if (!version.get()) {
callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
return;
@@ -122,45 +112,6 @@ void DispatchPushEventWithVersionID(
version->DispatchPushEvent(callback, data);
}
-void UnregisterWithScope(
- scoped_refptr<ServiceWorkerContextWrapper> context,
- const GURL& scope,
- const ServiceWorkerInternalsUI::StatusCallback& callback) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(UnregisterWithScope, context, scope, callback));
- return;
- }
-
- if (!context->context()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
- context->context()->UnregisterServiceWorker(scope, callback);
-}
-
-void FindRegistrationForPattern(
- scoped_refptr<ServiceWorkerContextWrapper> context,
- const GURL& scope,
- const ServiceWorkerStorage::FindRegistrationCallback callback) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(FindRegistrationForPattern, context, scope, callback));
- return;
- }
-
- if (!context->context()) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT,
- scoped_refptr<ServiceWorkerRegistration>());
- return;
- }
- context->context()->storage()->FindRegistrationForPattern(scope, callback);
-}
-
void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
DictionaryValue* info) {
switch (version.running_status) {
@@ -256,37 +207,17 @@ void DidGetStoredRegistrationsOnIOThread(
const GetRegistrationsCallback& callback,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (!context->context()) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>(),
- std::vector<ServiceWorkerVersionInfo>(),
- std::vector<ServiceWorkerRegistrationInfo>()));
- return;
- }
-
BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(callback,
- context->context()->GetAllLiveRegistrationInfo(),
- context->context()->GetAllLiveVersionInfo(),
- stored_registrations));
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, context->GetAllLiveRegistrationInfo(),
+ context->GetAllLiveVersionInfo(), stored_registrations));
}
void GetRegistrationsOnIOThread(
scoped_refptr<ServiceWorkerContextWrapper> context,
const GetRegistrationsCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (!context->context()) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(callback, std::vector<ServiceWorkerRegistrationInfo>(),
- std::vector<ServiceWorkerVersionInfo>(),
- std::vector<ServiceWorkerRegistrationInfo>()));
- return;
- }
- context->context()->storage()->GetAllRegistrations(
+ context->GetAllRegistrations(
base::Bind(DidGetStoredRegistrationsOnIOThread, context, callback));
}
@@ -669,4 +600,26 @@ void ServiceWorkerInternalsUI::StartWorker(const ListValue* args) {
context->StartServiceWorker(GURL(scope_string), callback);
}
+void ServiceWorkerInternalsUI::UnregisterWithScope(
+ scoped_refptr<ServiceWorkerContextWrapper> context,
+ const GURL& scope,
+ const ServiceWorkerInternalsUI::StatusCallback& callback) const {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ServiceWorkerInternalsUI::UnregisterWithScope,
+ base::Unretained(this), context, scope, callback));
+ return;
+ }
+
+ if (!context->context()) {
+ callback.Run(SERVICE_WORKER_ERROR_ABORT);
+ return;
+ }
+
+ // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
+ // because that reduces a status code to boolean.
+ context->context()->UnregisterServiceWorker(scope, callback);
+}
+
} // namespace content
« no previous file with comments | « content/browser/service_worker/service_worker_internals_ui.h ('k') | content/public/browser/push_messaging_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698