| 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "content/browser/service_worker/embedded_worker_status.h" | 9 #include "content/browser/service_worker/embedded_worker_status.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 ServiceWorkerRegistration::ServiceWorkerRegistration( | 31 ServiceWorkerRegistration::ServiceWorkerRegistration( |
| 32 const GURL& pattern, | 32 const GURL& pattern, |
| 33 int64_t registration_id, | 33 int64_t registration_id, |
| 34 base::WeakPtr<ServiceWorkerContextCore> context) | 34 base::WeakPtr<ServiceWorkerContextCore> context) |
| 35 : pattern_(pattern), | 35 : pattern_(pattern), |
| 36 registration_id_(registration_id), | 36 registration_id_(registration_id), |
| 37 is_deleted_(false), | 37 is_deleted_(false), |
| 38 is_uninstalling_(false), | 38 is_uninstalling_(false), |
| 39 is_uninstalled_(false), | 39 is_uninstalled_(false), |
| 40 should_activate_when_ready_(false), | 40 should_activate_when_ready_(false), |
| 41 is_navigation_preload_enabled_(false), |
| 41 resources_total_size_bytes_(0), | 42 resources_total_size_bytes_(0), |
| 42 context_(context), | 43 context_(context), |
| 43 task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 44 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 45 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
| 46 DCHECK(context_); | 47 DCHECK(context_); |
| 47 context_->AddLiveRegistration(this); | 48 context_->AddLiveRegistration(this); |
| 48 } | 49 } |
| 49 | 50 |
| 50 ServiceWorkerRegistration::~ServiceWorkerRegistration() { | 51 ServiceWorkerRegistration::~ServiceWorkerRegistration() { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 callbacks.swap(registration_finished_callbacks_); | 388 callbacks.swap(registration_finished_callbacks_); |
| 388 for (const auto& callback : callbacks) | 389 for (const auto& callback : callbacks) |
| 389 callback.Run(); | 390 callback.Run(); |
| 390 } | 391 } |
| 391 | 392 |
| 392 void ServiceWorkerRegistration::SetTaskRunnerForTest( | 393 void ServiceWorkerRegistration::SetTaskRunnerForTest( |
| 393 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 394 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 394 task_runner_ = task_runner; | 395 task_runner_ = task_runner; |
| 395 } | 396 } |
| 396 | 397 |
| 398 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { |
| 399 // TODO(falken): Propagate to current versions and new versions. |
| 400 is_navigation_preload_enabled_ = enable; |
| 401 } |
| 402 |
| 397 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( | 403 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( |
| 398 const base::Closure& callback) { | 404 const base::Closure& callback) { |
| 399 // This should only be called if the registration is in progress. | 405 // This should only be called if the registration is in progress. |
| 400 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && | 406 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && |
| 401 !is_uninstalling()); | 407 !is_uninstalling()); |
| 402 registration_finished_callbacks_.push_back(callback); | 408 registration_finished_callbacks_.push_back(callback); |
| 403 } | 409 } |
| 404 | 410 |
| 405 void ServiceWorkerRegistration::DispatchActivateEvent( | 411 void ServiceWorkerRegistration::DispatchActivateEvent( |
| 406 scoped_refptr<ServiceWorkerVersion> activating_version) { | 412 scoped_refptr<ServiceWorkerVersion> activating_version) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (!context_) { | 509 if (!context_) { |
| 504 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 510 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 505 return; | 511 return; |
| 506 } | 512 } |
| 507 context_->storage()->NotifyDoneInstallingRegistration( | 513 context_->storage()->NotifyDoneInstallingRegistration( |
| 508 this, version.get(), status); | 514 this, version.get(), status); |
| 509 callback.Run(status); | 515 callback.Run(status); |
| 510 } | 516 } |
| 511 | 517 |
| 512 } // namespace content | 518 } // namespace content |
| OLD | NEW |