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

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

Issue 208843004: Add the beginning of a public Service Worker API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix #include guard name Created 6 years, 9 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 e423d70511cdef4a7a6237947f95103f8e0ff33d..0e0ff3db69682dc258326f629270dc8a0f4d699a 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -49,4 +49,81 @@ ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
return context_core_.get();
}
+void ServiceWorkerContextWrapper::RegisterServiceWorker(
+ const GURL& pattern,
+ const GURL& script_url,
+ int source_process_id,
+ const RegistrationCallback& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorkerOnIO,
kinuko 2014/03/26 05:01:34 Instead of having yet another indirection method w
Jeffrey Yasskin 2014/03/26 19:58:52 Sure, done.
+ this,
+ pattern,
+ script_url,
+ source_process_id,
+ continuation));
+}
+
+void ServiceWorkerContextWrapper::RegisterServiceWorkerOnIO(
kinuko 2014/03/26 05:01:34 I know this ordering has some benfits, but can we
Jeffrey Yasskin 2014/03/26 19:58:52 Obsolete now.
+ const GURL& pattern,
+ const GURL& script_url,
+ int source_process_id,
+ const RegistrationCallback& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ context()->RegisterServiceWorker(
+ pattern,
+ script_url,
+ source_process_id,
+ base::Bind(&ServiceWorkerContextWrapper::FinishRegistrationOnIO,
+ this,
+ continuation));
+}
+
+void ServiceWorkerContextWrapper::FinishRegistrationOnIO(
+ const RegistrationCallback& continuation,
+ ServiceWorkerStatusCode status,
+ int64 registration_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE, base::Bind(continuation, status));
+}
+
+void ServiceWorkerContextWrapper::UnregisterServiceWorker(
+ const GURL& pattern,
+ int source_process_id,
+ const UnregistrationCallback& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO,
+ this,
+ pattern,
+ source_process_id,
+ continuation));
+}
+
+void ServiceWorkerContextWrapper::UnregisterServiceWorkerOnIO(
+ const GURL& pattern,
+ int source_process_id,
+ const UnregistrationCallback& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ context()->UnregisterServiceWorker(
+ pattern,
+ source_process_id,
+ base::Bind(&ServiceWorkerContextWrapper::FinishUnregistrationOnIO,
+ this,
+ continuation));
+}
+void ServiceWorkerContextWrapper::FinishUnregistrationOnIO(
+ const RegistrationCallback& continuation,
+ ServiceWorkerStatusCode status) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE, base::Bind(continuation, status));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698