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 1836e109bdc3c757e46d05f86c3859fd42b3e331..db75fdc47a81c1d52cc7579b8ce7f66a49a10137 100644 |
--- a/content/browser/service_worker/service_worker_internals_ui.cc |
+++ b/content/browser/service_worker/service_worker_internals_ui.cc |
@@ -49,6 +49,8 @@ class ServiceWorkerInternalsUI::OperationProxy |
const GURL& scope); |
void StopWorkerOnIOThread(scoped_refptr<ServiceWorkerContextWrapper> context, |
const GURL& scope); |
+ void SyncWorkerOnIOThread(scoped_refptr<ServiceWorkerContextWrapper> context, |
kinuko
2014/03/24 05:10:08
(ditto for all these method names)
jkarlin
2014/03/25 18:28:17
Done.
|
+ const GURL& scope); |
private: |
friend class base::RefCountedThreadSafe<OperationProxy>; |
@@ -67,6 +69,10 @@ class ServiceWorkerInternalsUI::OperationProxy |
ServiceWorkerStatusCode status, |
const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ void SyncActiveWorker( |
+ ServiceWorkerStatusCode status, |
+ const scoped_refptr<ServiceWorkerRegistration>& registration); |
+ |
WeakPtr<ServiceWorkerInternalsUI> internals_; |
scoped_ptr<ListValue> original_args_; |
}; |
@@ -103,6 +109,10 @@ ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui) |
"unregister", |
base::Bind(&ServiceWorkerInternalsUI::Unregister, |
base::Unretained(this))); |
+ web_ui->RegisterMessageCallback( |
+ "sync", |
+ base::Bind(&ServiceWorkerInternalsUI::SyncWorker, |
+ base::Unretained(this))); |
} |
ServiceWorkerInternalsUI::~ServiceWorkerInternalsUI() {} |
@@ -176,6 +186,25 @@ bool ServiceWorkerInternalsUI::GetRegistrationInfo( |
return true; |
} |
+void ServiceWorkerInternalsUI::SyncWorker(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::SyncWorkerOnIOThread, |
+ new OperationProxy(AsWeakPtr(), args_copy.Pass()), |
+ context, |
+ scope)); |
+} |
+ |
void ServiceWorkerInternalsUI::Unregister(const ListValue* args) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
base::FilePath partition_path; |
@@ -279,6 +308,16 @@ void ServiceWorkerInternalsUI::OperationProxy::StopWorkerOnIOThread( |
this)); |
} |
+void ServiceWorkerInternalsUI::OperationProxy::SyncWorkerOnIOThread( |
+ scoped_refptr<ServiceWorkerContextWrapper> context, |
+ const GURL& scope) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ context->context()->storage()->FindRegistrationForPattern( |
+ scope, |
+ base::Bind(&ServiceWorkerInternalsUI::OperationProxy::SyncActiveWorker, |
+ this)); |
+} |
+ |
namespace { |
void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, |
DictionaryValue* info) { |
@@ -418,4 +457,17 @@ void ServiceWorkerInternalsUI::OperationProxy::StopActiveWorker( |
OperationComplete(status); |
} |
+void ServiceWorkerInternalsUI::OperationProxy::SyncActiveWorker( |
+ ServiceWorkerStatusCode status, |
+ const scoped_refptr<ServiceWorkerRegistration>& registration) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ if (status == SERVICE_WORKER_OK) { |
+ registration->active_version()->DispatchSyncEvent(base::Bind( |
+ &ServiceWorkerInternalsUI::OperationProxy::OperationComplete, this)); |
+ return; |
+ } |
+ |
+ OperationComplete(status); |
+} |
+ |
} // namespace content |