| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 5 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 205 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 206 BrowserThread::PostTask( | 206 BrowserThread::PostTask( |
| 207 BrowserThread::UI, | 207 BrowserThread::UI, |
| 208 FROM_HERE, | 208 FROM_HERE, |
| 209 base::Bind(continuation, status == SERVICE_WORKER_OK)); | 209 base::Bind(continuation, status == SERVICE_WORKER_OK)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ServiceWorkerContextWrapper::RegisterServiceWorker( | 212 void ServiceWorkerContextWrapper::RegisterServiceWorker( |
| 213 const GURL& pattern, | 213 const GURL& pattern, |
| 214 const GURL& script_url, | 214 const GURL& script_url, |
| 215 bool use_cache, |
| 215 const ResultCallback& continuation) { | 216 const ResultCallback& continuation) { |
| 216 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 217 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 217 BrowserThread::PostTask( | 218 BrowserThread::PostTask( |
| 218 BrowserThread::IO, | 219 BrowserThread::IO, FROM_HERE, |
| 219 FROM_HERE, | 220 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, this, |
| 220 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, | 221 pattern, script_url, use_cache, continuation)); |
| 221 this, | |
| 222 pattern, | |
| 223 script_url, | |
| 224 continuation)); | |
| 225 return; | 222 return; |
| 226 } | 223 } |
| 227 if (!context_core_) { | 224 if (!context_core_) { |
| 228 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 225 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 229 base::Bind(continuation, false)); | 226 base::Bind(continuation, false)); |
| 230 return; | 227 return; |
| 231 } | 228 } |
| 232 context()->RegisterServiceWorker( | 229 context()->RegisterServiceWorker( |
| 233 net::SimplifyUrlForRequest(pattern), | 230 net::SimplifyUrlForRequest(pattern), |
| 234 net::SimplifyUrlForRequest(script_url), NULL /* provider_host */, | 231 net::SimplifyUrlForRequest(script_url), use_cache, |
| 232 NULL /* provider_host */, |
| 235 base::Bind(&FinishRegistrationOnIO, continuation)); | 233 base::Bind(&FinishRegistrationOnIO, continuation)); |
| 236 } | 234 } |
| 237 | 235 |
| 238 static void FinishUnregistrationOnIO( | 236 static void FinishUnregistrationOnIO( |
| 239 const ServiceWorkerContext::ResultCallback& continuation, | 237 const ServiceWorkerContext::ResultCallback& continuation, |
| 240 ServiceWorkerStatusCode status) { | 238 ServiceWorkerStatusCode status) { |
| 241 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 239 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 242 BrowserThread::PostTask( | 240 BrowserThread::PostTask( |
| 243 BrowserThread::UI, | 241 BrowserThread::UI, |
| 244 FROM_HERE, | 242 FROM_HERE, |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 observer_list_->Notify(FROM_HERE, | 922 observer_list_->Notify(FROM_HERE, |
| 925 &ServiceWorkerContextObserver::OnStorageWiped); | 923 &ServiceWorkerContextObserver::OnStorageWiped); |
| 926 } | 924 } |
| 927 | 925 |
| 928 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 926 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 929 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 927 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 930 return context_core_.get(); | 928 return context_core_.get(); |
| 931 } | 929 } |
| 932 | 930 |
| 933 } // namespace content | 931 } // namespace content |
| OLD | NEW |