| 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..f441551ae4a426b6341d682097af76dc88e30110 100644
|
| --- a/content/browser/service_worker/service_worker_context_wrapper.cc
|
| +++ b/content/browser/service_worker/service_worker_context_wrapper.cc
|
| @@ -45,8 +45,72 @@ void ServiceWorkerContextWrapper::Shutdown() {
|
| }
|
|
|
| ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| return context_core_.get();
|
| }
|
|
|
| +static void FinishRegistrationOnIO(
|
| + const ServiceWorkerContext::StatusCallback& continuation,
|
| + ServiceWorkerStatusCode status,
|
| + int64 registration_id) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE, base::Bind(continuation, status));
|
| +}
|
| +
|
| +void ServiceWorkerContextWrapper::RegisterServiceWorker(
|
| + const GURL& pattern,
|
| + const GURL& script_url,
|
| + int source_process_id,
|
| + const StatusCallback& continuation) {
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker,
|
| + this,
|
| + pattern,
|
| + script_url,
|
| + source_process_id,
|
| + continuation));
|
| + return;
|
| + }
|
| +
|
| + context()->RegisterServiceWorker(
|
| + pattern,
|
| + script_url,
|
| + source_process_id,
|
| + base::Bind(&FinishRegistrationOnIO, continuation));
|
| +}
|
| +
|
| +static void FinishUnregistrationOnIO(
|
| + const ServiceWorkerContext::StatusCallback& continuation,
|
| + ServiceWorkerStatusCode status) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE, base::Bind(continuation, status));
|
| +}
|
| +
|
| +void ServiceWorkerContextWrapper::UnregisterServiceWorker(
|
| + const GURL& pattern,
|
| + int source_process_id,
|
| + const StatusCallback& continuation) {
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&ServiceWorkerContextWrapper::UnregisterServiceWorker,
|
| + this,
|
| + pattern,
|
| + source_process_id,
|
| + continuation));
|
| + return;
|
| + }
|
| +
|
| + context()->UnregisterServiceWorker(
|
| + pattern,
|
| + source_process_id,
|
| + base::Bind(&FinishUnregistrationOnIO, continuation));
|
| +}
|
| +
|
| } // namespace content
|
|
|