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 f69132f0fb8dbd913294803ec91eae6da4db803b..1a86f3efdfe959aaeb6747b89a591b4fac915d67 100644 |
--- a/content/browser/service_worker/service_worker_internals_ui.cc |
+++ b/content/browser/service_worker/service_worker_internals_ui.cc |
@@ -57,6 +57,9 @@ class ServiceWorkerInternalsUI::OperationProxy |
void DispatchSyncEventToWorkerOnIOThread( |
scoped_refptr<ServiceWorkerContextWrapper> context, |
const GURL& scope); |
+ void DispatchPushEventToWorkerOnIOThread( |
+ scoped_refptr<ServiceWorkerContextWrapper> context, |
+ const GURL& scope); |
void InspectWorkerOnIOThread( |
scoped_refptr<ServiceWorkerContextWrapper> context, |
const GURL& scope); |
@@ -83,6 +86,10 @@ class ServiceWorkerInternalsUI::OperationProxy |
ServiceWorkerStatusCode status, |
const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ void DispatchPushEventToActiveWorker( |
+ ServiceWorkerStatusCode status, |
+ const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ |
void InspectActiveWorker( |
const ServiceWorkerContextCore* const service_worker_context, |
ServiceWorkerStatusCode status, |
@@ -224,6 +231,10 @@ ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui) |
base::Bind(&ServiceWorkerInternalsUI::DispatchSyncEventToWorker, |
base::Unretained(this))); |
web_ui->RegisterMessageCallback( |
+ "push", |
+ base::Bind(&ServiceWorkerInternalsUI::DispatchPushEventToWorker, |
+ base::Unretained(this))); |
+ web_ui->RegisterMessageCallback( |
"inspect", |
base::Bind(&ServiceWorkerInternalsUI::InspectWorker, |
base::Unretained(this))); |
@@ -355,6 +366,26 @@ void ServiceWorkerInternalsUI::DispatchSyncEventToWorker( |
scope)); |
} |
+void ServiceWorkerInternalsUI::DispatchPushEventToWorker( |
+ const ListValue* args) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ base::FilePath partition_path; |
+ GURL scope; |
+ scoped_refptr<ServiceWorkerContextWrapper> context; |
+ if (!GetRegistrationInfo(args, &partition_path, &scope, &context)) |
+ return; |
+ |
+ scoped_ptr<ListValue> args_copy(args->DeepCopy()); |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind(&ServiceWorkerInternalsUI::OperationProxy:: |
+ DispatchPushEventToWorkerOnIOThread, |
+ new OperationProxy(AsWeakPtr(), args_copy.Pass()), |
+ context, |
+ scope)); |
+} |
+ |
void ServiceWorkerInternalsUI::InspectWorker(const ListValue* args) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
base::FilePath partition_path; |
@@ -489,6 +520,18 @@ ServiceWorkerInternalsUI::OperationProxy::DispatchSyncEventToWorkerOnIOThread( |
this)); |
} |
+void |
+ServiceWorkerInternalsUI::OperationProxy::DispatchPushEventToWorkerOnIOThread( |
+ scoped_refptr<ServiceWorkerContextWrapper> context, |
+ const GURL& scope) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ context->context()->storage()->FindRegistrationForPattern( |
+ scope, |
+ base::Bind(&ServiceWorkerInternalsUI::OperationProxy:: |
+ DispatchPushEventToActiveWorker, |
+ this)); |
+} |
+ |
void ServiceWorkerInternalsUI::OperationProxy::InspectWorkerOnIOThread( |
scoped_refptr<ServiceWorkerContextWrapper> context, |
const GURL& scope) { |
@@ -657,6 +700,21 @@ void ServiceWorkerInternalsUI::OperationProxy::DispatchSyncEventToActiveWorker( |
OperationComplete(SERVICE_WORKER_ERROR_FAILED); |
} |
+void ServiceWorkerInternalsUI::OperationProxy::DispatchPushEventToActiveWorker( |
+ ServiceWorkerStatusCode status, |
+ const scoped_refptr<ServiceWorkerRegistration>& registration) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ if (status == SERVICE_WORKER_OK && registration->active_version() && |
+ registration->active_version()->status() == |
+ ServiceWorkerVersion::ACTIVE) { |
+ registration->active_version()->DispatchPushEvent(base::Bind( |
+ &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); |
+ return; |
+ } |
+ |
+ OperationComplete(SERVICE_WORKER_ERROR_FAILED); |
+} |
+ |
void ServiceWorkerInternalsUI::OperationProxy::InspectActiveWorker( |
const ServiceWorkerContextCore* const service_worker_context, |
ServiceWorkerStatusCode status, |