| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 for (const auto& callback : callbacks) | 385 for (const auto& callback : callbacks) |
| 386 callback.Run(); | 386 callback.Run(); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void ServiceWorkerRegistration::SetTaskRunnerForTest( | 389 void ServiceWorkerRegistration::SetTaskRunnerForTest( |
| 390 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 390 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 391 task_runner_ = task_runner; | 391 task_runner_ = task_runner; |
| 392 } | 392 } |
| 393 | 393 |
| 394 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { | 394 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { |
| 395 if (navigation_preload_state_.enabled == enable) | |
| 396 return; | |
| 397 navigation_preload_state_.enabled = enable; | 395 navigation_preload_state_.enabled = enable; |
| 398 if (active_version_) | 396 if (active_version_) |
| 399 active_version_->SetNavigationPreloadState(navigation_preload_state_); | 397 active_version_->SetNavigationPreloadState(navigation_preload_state_); |
| 400 } | 398 } |
| 401 | 399 |
| 402 void ServiceWorkerRegistration::SetNavigationPreloadHeader( | 400 void ServiceWorkerRegistration::SetNavigationPreloadHeader( |
| 403 const std::string& header) { | 401 const std::string& header) { |
| 404 if (navigation_preload_state_.header == header) | |
| 405 return; | |
| 406 navigation_preload_state_.header = header; | 402 navigation_preload_state_.header = header; |
| 407 if (active_version_) | 403 if (active_version_) |
| 408 active_version_->SetNavigationPreloadState(navigation_preload_state_); | 404 active_version_->SetNavigationPreloadState(navigation_preload_state_); |
| 409 } | 405 } |
| 410 | 406 |
| 411 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( | 407 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( |
| 412 const base::Closure& callback) { | 408 const base::Closure& callback) { |
| 413 // This should only be called if the registration is in progress. | 409 // This should only be called if the registration is in progress. |
| 414 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && | 410 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && |
| 415 !is_uninstalling()); | 411 !is_uninstalling()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (!context_) { | 513 if (!context_) { |
| 518 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 514 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 519 return; | 515 return; |
| 520 } | 516 } |
| 521 context_->storage()->NotifyDoneInstallingRegistration( | 517 context_->storage()->NotifyDoneInstallingRegistration( |
| 522 this, version.get(), status); | 518 this, version.get(), status); |
| 523 callback.Run(status); | 519 callback.Run(status); |
| 524 } | 520 } |
| 525 | 521 |
| 526 } // namespace content | 522 } // namespace content |
| OLD | NEW |