Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: content/browser/service_worker/service_worker_registration.cc

Issue 2451373003: service worker: Implement NavigationPreloadManager.setHeaderValue (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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),
42 resources_total_size_bytes_(0), 41 resources_total_size_bytes_(0),
43 context_(context), 42 context_(context),
44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { 43 task_runner_(base::ThreadTaskRunnerHandle::Get()) {
45 DCHECK_CURRENTLY_ON(BrowserThread::IO); 44 DCHECK_CURRENTLY_ON(BrowserThread::IO);
46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); 45 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id);
47 DCHECK(context_); 46 DCHECK(context_);
48 context_->AddLiveRegistration(this); 47 context_->AddLiveRegistration(this);
49 } 48 }
50 49
51 ServiceWorkerRegistration::~ServiceWorkerRegistration() { 50 ServiceWorkerRegistration::~ServiceWorkerRegistration() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 should_activate_when_ready_ = false; 115 should_activate_when_ready_ = false;
117 116
118 ChangedVersionAttributesMask mask; 117 ChangedVersionAttributesMask mask;
119 if (version) 118 if (version)
120 UnsetVersionInternal(version.get(), &mask); 119 UnsetVersionInternal(version.get(), &mask);
121 if (active_version_) 120 if (active_version_)
122 active_version_->RemoveListener(this); 121 active_version_->RemoveListener(this);
123 active_version_ = version; 122 active_version_ = version;
124 if (active_version_) { 123 if (active_version_) {
125 active_version_->AddListener(this); 124 active_version_->AddListener(this);
126 active_version_->set_navigation_preload_enabled( 125 active_version_->SetNavigationPreloadState(navigation_preload_state_);
127 is_navigation_preload_enabled_);
128 } 126 }
129 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); 127 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION);
130 128
131 NotifyVersionAttributesChanged(mask); 129 NotifyVersionAttributesChanged(mask);
132 } 130 }
133 131
134 void ServiceWorkerRegistration::SetWaitingVersion( 132 void ServiceWorkerRegistration::SetWaitingVersion(
135 const scoped_refptr<ServiceWorkerVersion>& version) { 133 const scoped_refptr<ServiceWorkerVersion>& version) {
136 if (waiting_version_ == version) 134 if (waiting_version_ == version)
137 return; 135 return;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 for (const auto& callback : callbacks) 390 for (const auto& callback : callbacks)
393 callback.Run(); 391 callback.Run();
394 } 392 }
395 393
396 void ServiceWorkerRegistration::SetTaskRunnerForTest( 394 void ServiceWorkerRegistration::SetTaskRunnerForTest(
397 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { 395 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
398 task_runner_ = task_runner; 396 task_runner_ = task_runner;
399 } 397 }
400 398
401 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) { 399 void ServiceWorkerRegistration::EnableNavigationPreload(bool enable) {
402 if (is_navigation_preload_enabled_ == enable) 400 if (navigation_preload_state_.enabled == enable)
403 return; 401 return;
404 is_navigation_preload_enabled_ = enable; 402 navigation_preload_state_.enabled = enable;
405 if (active_version_) 403 if (active_version_)
406 active_version_->set_navigation_preload_enabled(enable); 404 active_version_->SetNavigationPreloadState(navigation_preload_state_);
405 }
406
407 void ServiceWorkerRegistration::SetNavigationPreloadHeader(
408 const std::string& header) {
409 if (navigation_preload_state_.header == header)
410 return;
411 navigation_preload_state_.header = header;
412 if (active_version_)
413 active_version_->SetNavigationPreloadState(navigation_preload_state_);
407 } 414 }
408 415
409 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( 416 void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback(
410 const base::Closure& callback) { 417 const base::Closure& callback) {
411 // This should only be called if the registration is in progress. 418 // This should only be called if the registration is in progress.
412 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && 419 DCHECK(!active_version() && !waiting_version() && !is_uninstalled() &&
413 !is_uninstalling()); 420 !is_uninstalling());
414 registration_finished_callbacks_.push_back(callback); 421 registration_finished_callbacks_.push_back(callback);
415 } 422 }
416 423
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (!context_) { 522 if (!context_) {
516 callback.Run(SERVICE_WORKER_ERROR_ABORT); 523 callback.Run(SERVICE_WORKER_ERROR_ABORT);
517 return; 524 return;
518 } 525 }
519 context_->storage()->NotifyDoneInstallingRegistration( 526 context_->storage()->NotifyDoneInstallingRegistration(
520 this, version.get(), status); 527 this, version.get(), status);
521 callback.Run(status); 528 callback.Run(status);
522 } 529 }
523 530
524 } // namespace content 531 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698