| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (!version || version->skip_waiting()) | 298 if (!version || version->skip_waiting()) |
| 299 return; | 299 return; |
| 300 ServiceWorkerRegistration* registration = | 300 ServiceWorkerRegistration* registration = |
| 301 GetLiveRegistration(version->registration_id()); | 301 GetLiveRegistration(version->registration_id()); |
| 302 if (!registration || version != registration->waiting_version()) | 302 if (!registration || version != registration->waiting_version()) |
| 303 return; | 303 return; |
| 304 version->set_skip_waiting(true); | 304 version->set_skip_waiting(true); |
| 305 registration->ActivateWaitingVersionWhenReady(); | 305 registration->ActivateWaitingVersionWhenReady(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void ServiceWorkerContextWrapper::FocusClient(const std::string& client_uuid) { |
| 309 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 310 BrowserThread::PostTask( |
| 311 BrowserThread::IO, FROM_HERE, |
| 312 base::Bind(&ServiceWorkerContextWrapper::FocusClient, this, |
| 313 client_uuid)); |
| 314 return; |
| 315 } |
| 316 if (!context_core_.get()) { |
| 317 LOG(ERROR) << "ServiceWorkerContextCore is no longer alive."; |
| 318 return; |
| 319 } |
| 320 ServiceWorkerProviderHost* provider_host = |
| 321 context_core_->GetProviderHostByClientID(client_uuid); |
| 322 if (!provider_host) { |
| 323 LOG(ERROR) << "ServiceWorkerProviderHost is no longer alive."; |
| 324 return; |
| 325 } |
| 326 provider_host->Focus(base::Bind(&ServiceWorkerUtils::NoOpClientInfoCallback)); |
| 327 } |
| 328 |
| 308 static void DidFindRegistrationForDocument( | 329 static void DidFindRegistrationForDocument( |
| 309 const net::CompletionCallback& callback, | 330 const net::CompletionCallback& callback, |
| 310 ServiceWorkerStatusCode status, | 331 ServiceWorkerStatusCode status, |
| 311 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 332 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| 312 int rv = registration ? net::OK : net::ERR_CACHE_MISS; | 333 int rv = registration ? net::OK : net::ERR_CACHE_MISS; |
| 313 // Use RunSoon here because FindRegistrationForDocument can complete | 334 // Use RunSoon here because FindRegistrationForDocument can complete |
| 314 // immediately but CanHandleMainResourceOffline must be async. | 335 // immediately but CanHandleMainResourceOffline must be async. |
| 315 RunSoon(base::Bind(callback, rv)); | 336 RunSoon(base::Bind(callback, rv)); |
| 316 } | 337 } |
| 317 | 338 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 observer_list_->Notify(FROM_HERE, | 662 observer_list_->Notify(FROM_HERE, |
| 642 &ServiceWorkerContextObserver::OnStorageWiped); | 663 &ServiceWorkerContextObserver::OnStorageWiped); |
| 643 } | 664 } |
| 644 | 665 |
| 645 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { | 666 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { |
| 646 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 667 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 647 return context_core_.get(); | 668 return context_core_.get(); |
| 648 } | 669 } |
| 649 | 670 |
| 650 } // namespace content | 671 } // namespace content |
| OLD | NEW |