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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return; | 114 return; |
115 | 115 |
116 should_activate_when_ready_ = false; | 116 should_activate_when_ready_ = false; |
117 | 117 |
118 ChangedVersionAttributesMask mask; | 118 ChangedVersionAttributesMask mask; |
119 if (version) | 119 if (version) |
120 UnsetVersionInternal(version.get(), &mask); | 120 UnsetVersionInternal(version.get(), &mask); |
121 if (active_version_) | 121 if (active_version_) |
122 active_version_->RemoveListener(this); | 122 active_version_->RemoveListener(this); |
123 active_version_ = version; | 123 active_version_ = version; |
124 if (active_version_) | 124 if (active_version_) { |
125 active_version_->AddListener(this); | 125 active_version_->AddListener(this); |
| 126 active_version_->set_navigation_preload_enabled( |
| 127 is_navigation_preload_enabled_); |
| 128 } |
126 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); | 129 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); |
127 | 130 |
128 NotifyVersionAttributesChanged(mask); | 131 NotifyVersionAttributesChanged(mask); |
129 } | 132 } |
130 | 133 |
131 void ServiceWorkerRegistration::SetWaitingVersion( | 134 void ServiceWorkerRegistration::SetWaitingVersion( |
132 const scoped_refptr<ServiceWorkerVersion>& version) { | 135 const scoped_refptr<ServiceWorkerVersion>& version) { |
133 if (waiting_version_ == version) | 136 if (waiting_version_ == version) |
134 return; | 137 return; |
135 | 138 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 for (const auto& callback : callbacks) | 392 for (const auto& callback : callbacks) |
390 callback.Run(); | 393 callback.Run(); |
391 } | 394 } |
392 | 395 |
393 void ServiceWorkerRegistration::SetTaskRunnerForTest( | 396 void ServiceWorkerRegistration::SetTaskRunnerForTest( |
394 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 397 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
395 task_runner_ = task_runner; | 398 task_runner_ = task_runner; |
396 } | 399 } |
397 | 400 |
398 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { | 401 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { |
399 // TODO(falken): Propagate to current versions and new versions. | 402 if (is_navigation_preload_enabled_ == enable) |
| 403 return; |
400 is_navigation_preload_enabled_ = enable; | 404 is_navigation_preload_enabled_ = enable; |
| 405 if (active_version_) |
| 406 active_version_->set_navigation_preload_enabled(enable); |
401 } | 407 } |
402 | 408 |
403 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( | 409 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( |
404 const base::Closure& callback) { | 410 const base::Closure& callback) { |
405 // This should only be called if the registration is in progress. | 411 // This should only be called if the registration is in progress. |
406 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && | 412 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && |
407 !is_uninstalling()); | 413 !is_uninstalling()); |
408 registration_finished_callbacks_.push_back(callback); | 414 registration_finished_callbacks_.push_back(callback); |
409 } | 415 } |
410 | 416 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 if (!context_) { | 515 if (!context_) { |
510 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 516 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
511 return; | 517 return; |
512 } | 518 } |
513 context_->storage()->NotifyDoneInstallingRegistration( | 519 context_->storage()->NotifyDoneInstallingRegistration( |
514 this, version.get(), status); | 520 this, version.get(), status); |
515 callback.Run(status); | 521 callback.Run(status); |
516 } | 522 } |
517 | 523 |
518 } // namespace content | 524 } // namespace content |
OLD | NEW |