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 } |
| 229 ServiceWorkerRegistrationOptions options( |
| 230 net::SimplifyUrlForRequest(pattern), |
| 231 use_cache ? ServiceWorkerRegistrationOptions::UseCache::Use |
| 232 : ServiceWorkerRegistrationOptions::UseCache::DontUse); |
232 context()->RegisterServiceWorker( | 233 context()->RegisterServiceWorker( |
233 net::SimplifyUrlForRequest(pattern), | 234 net::SimplifyUrlForRequest(script_url), options, NULL /* provider_host */, |
234 net::SimplifyUrlForRequest(script_url), NULL /* provider_host */, | |
235 base::Bind(&FinishRegistrationOnIO, continuation)); | 235 base::Bind(&FinishRegistrationOnIO, continuation)); |
236 } | 236 } |
237 | 237 |
238 static void FinishUnregistrationOnIO( | 238 static void FinishUnregistrationOnIO( |
239 const ServiceWorkerContext::ResultCallback& continuation, | 239 const ServiceWorkerContext::ResultCallback& continuation, |
240 ServiceWorkerStatusCode status) { | 240 ServiceWorkerStatusCode status) { |
241 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 241 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
242 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
243 BrowserThread::UI, | 243 BrowserThread::UI, |
244 FROM_HERE, | 244 FROM_HERE, |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 observer_list_->Notify(FROM_HERE, | 924 observer_list_->Notify(FROM_HERE, |
925 &ServiceWorkerContextObserver::OnStorageWiped); | 925 &ServiceWorkerContextObserver::OnStorageWiped); |
926 } | 926 } |
927 | 927 |
928 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 928 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
929 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 929 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
930 return context_core_.get(); | 930 return context_core_.get(); |
931 } | 931 } |
932 | 932 |
933 } // namespace content | 933 } // namespace content |
OLD | NEW |