| 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 <vector> | 10 #include <vector> |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; | 278 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; |
| 279 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 279 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 280 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); | 280 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 context_core_->storage()->FindRegistrationForPattern( | 283 context_core_->storage()->FindRegistrationForPattern( |
| 284 net::SimplifyUrlForRequest(pattern), | 284 net::SimplifyUrlForRequest(pattern), |
| 285 base::Bind(&StartActiveWorkerOnIO, callback)); | 285 base::Bind(&StartActiveWorkerOnIO, callback)); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void ServiceWorkerContextWrapper::SimulateSkipWaiting(int64_t version_id) { | 288 void ServiceWorkerContextWrapper::SimulateSkipWaiting( |
| 289 std::string version_uuid) { |
| 289 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 290 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 290 BrowserThread::PostTask( | 291 BrowserThread::PostTask( |
| 291 BrowserThread::IO, FROM_HERE, | 292 BrowserThread::IO, FROM_HERE, |
| 292 base::Bind(&ServiceWorkerContextWrapper::SimulateSkipWaiting, this, | 293 base::Bind(&ServiceWorkerContextWrapper::SimulateSkipWaiting, this, |
| 293 version_id)); | 294 version_uuid)); |
| 294 return; | 295 return; |
| 295 } | 296 } |
| 296 if (!context_core_.get()) { | 297 if (!context_core_.get()) { |
| 297 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; | 298 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; |
| 298 return; | 299 return; |
| 299 } | 300 } |
| 300 ServiceWorkerVersion* version = GetLiveVersion(version_id); | 301 ServiceWorkerVersion* version = GetLiveVersion(version_uuid); |
| 301 if (!version || version->skip_waiting()) | 302 if (!version || version->skip_waiting()) |
| 302 return; | 303 return; |
| 303 ServiceWorkerRegistration* registration = | 304 ServiceWorkerRegistration* registration = |
| 304 GetLiveRegistration(version->registration_id()); | 305 GetLiveRegistration(version->registration_id()); |
| 305 if (!registration || version != registration->waiting_version()) | 306 if (!registration || version != registration->waiting_version()) |
| 306 return; | 307 return; |
| 307 version->set_skip_waiting(true); | 308 version->set_skip_waiting(true); |
| 308 registration->ActivateWaitingVersionWhenReady(); | 309 registration->ActivateWaitingVersionWhenReady(); |
| 309 } | 310 } |
| 310 | 311 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 462 |
| 462 ServiceWorkerRegistration* ServiceWorkerContextWrapper::GetLiveRegistration( | 463 ServiceWorkerRegistration* ServiceWorkerContextWrapper::GetLiveRegistration( |
| 463 int64_t registration_id) { | 464 int64_t registration_id) { |
| 464 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 465 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 465 if (!context_core_) | 466 if (!context_core_) |
| 466 return nullptr; | 467 return nullptr; |
| 467 return context_core_->GetLiveRegistration(registration_id); | 468 return context_core_->GetLiveRegistration(registration_id); |
| 468 } | 469 } |
| 469 | 470 |
| 470 ServiceWorkerVersion* ServiceWorkerContextWrapper::GetLiveVersion( | 471 ServiceWorkerVersion* ServiceWorkerContextWrapper::GetLiveVersion( |
| 471 int64_t version_id) { | 472 std::string version_uuid) { |
| 472 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 473 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 473 if (!context_core_) | 474 if (!context_core_) |
| 474 return nullptr; | 475 return nullptr; |
| 475 return context_core_->GetLiveVersion(version_id); | 476 return context_core_->GetLiveVersion(version_uuid); |
| 476 } | 477 } |
| 477 | 478 |
| 478 std::vector<ServiceWorkerRegistrationInfo> | 479 std::vector<ServiceWorkerRegistrationInfo> |
| 479 ServiceWorkerContextWrapper::GetAllLiveRegistrationInfo() { | 480 ServiceWorkerContextWrapper::GetAllLiveRegistrationInfo() { |
| 480 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 481 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 481 if (!context_core_) | 482 if (!context_core_) |
| 482 return std::vector<ServiceWorkerRegistrationInfo>(); | 483 return std::vector<ServiceWorkerRegistrationInfo>(); |
| 483 return context_core_->GetAllLiveRegistrationInfo(); | 484 return context_core_->GetAllLiveRegistrationInfo(); |
| 484 } | 485 } |
| 485 | 486 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 observer_list_->Notify(FROM_HERE, | 644 observer_list_->Notify(FROM_HERE, |
| 644 &ServiceWorkerContextObserver::OnStorageWiped); | 645 &ServiceWorkerContextObserver::OnStorageWiped); |
| 645 } | 646 } |
| 646 | 647 |
| 647 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 648 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 648 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 649 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 649 return context_core_.get(); | 650 return context_core_.get(); |
| 650 } | 651 } |
| 651 | 652 |
| 652 } // namespace content | 653 } // namespace content |
| OLD | NEW |