| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 215 BrowserThread::PostTask( | 215 BrowserThread::PostTask( |
| 216 BrowserThread::UI, | 216 BrowserThread::UI, |
| 217 FROM_HERE, | 217 FROM_HERE, |
| 218 base::Bind(continuation, status == SERVICE_WORKER_OK)); | 218 base::Bind(continuation, status == SERVICE_WORKER_OK)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ServiceWorkerContextWrapper::RegisterServiceWorker( | 221 void ServiceWorkerContextWrapper::RegisterServiceWorker( |
| 222 const GURL& pattern, | 222 const GURL& pattern, |
| 223 const GURL& script_url, | 223 const GURL& script_url, |
| 224 blink::WebServiceWorkerUpdateViaCache update_via_cache, |
| 224 const ResultCallback& continuation) { | 225 const ResultCallback& continuation) { |
| 225 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 226 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 226 BrowserThread::PostTask( | 227 BrowserThread::PostTask( |
| 227 BrowserThread::IO, | 228 BrowserThread::IO, FROM_HERE, |
| 228 FROM_HERE, | 229 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, this, |
| 229 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, | 230 pattern, script_url, update_via_cache, continuation)); |
| 230 this, | |
| 231 pattern, | |
| 232 script_url, | |
| 233 continuation)); | |
| 234 return; | 231 return; |
| 235 } | 232 } |
| 236 if (!context_core_) { | 233 if (!context_core_) { |
| 237 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 234 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 238 base::Bind(continuation, false)); | 235 base::Bind(continuation, false)); |
| 239 return; | 236 return; |
| 240 } | 237 } |
| 238 ServiceWorkerRegistrationOptions options(net::SimplifyUrlForRequest(pattern), |
| 239 update_via_cache); |
| 241 context()->RegisterServiceWorker( | 240 context()->RegisterServiceWorker( |
| 242 net::SimplifyUrlForRequest(pattern), | 241 net::SimplifyUrlForRequest(script_url), options, NULL /* provider_host */, |
| 243 net::SimplifyUrlForRequest(script_url), NULL /* provider_host */, | |
| 244 base::Bind(&FinishRegistrationOnIO, continuation)); | 242 base::Bind(&FinishRegistrationOnIO, continuation)); |
| 245 } | 243 } |
| 246 | 244 |
| 247 static void FinishUnregistrationOnIO( | 245 static void FinishUnregistrationOnIO( |
| 248 const ServiceWorkerContext::ResultCallback& continuation, | 246 const ServiceWorkerContext::ResultCallback& continuation, |
| 249 ServiceWorkerStatusCode status) { | 247 ServiceWorkerStatusCode status) { |
| 250 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 248 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 251 BrowserThread::PostTask( | 249 BrowserThread::PostTask( |
| 252 BrowserThread::UI, | 250 BrowserThread::UI, |
| 253 FROM_HERE, | 251 FROM_HERE, |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 service_worker_provider_id, | 957 service_worker_provider_id, |
| 960 std::move(client_ptr_info)); | 958 std::move(client_ptr_info)); |
| 961 } | 959 } |
| 962 | 960 |
| 963 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 961 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 964 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 962 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 965 return context_core_.get(); | 963 return context_core_.get(); |
| 966 } | 964 } |
| 967 | 965 |
| 968 } // namespace content | 966 } // namespace content |
| OLD | NEW |