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

Side by Side Diff: content/browser/service_worker/service_worker_version.h

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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <functional> 10 #include <functional>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 foreign_fetch_scopes_ = scopes; 163 foreign_fetch_scopes_ = scopes;
164 } 164 }
165 165
166 const std::vector<url::Origin>& foreign_fetch_origins() const { 166 const std::vector<url::Origin>& foreign_fetch_origins() const {
167 return foreign_fetch_origins_; 167 return foreign_fetch_origins_;
168 } 168 }
169 void set_foreign_fetch_origins(const std::vector<url::Origin>& origins) { 169 void set_foreign_fetch_origins(const std::vector<url::Origin>& origins) {
170 foreign_fetch_origins_ = origins; 170 foreign_fetch_origins_ = origins;
171 } 171 }
172 172
173 // Only meaningful if this version is active. 173 // Meaningful only if this version is active.
174 bool navigation_preload_enabled() const { 174 const NavigationPreloadState& navigation_preload_state() const {
175 DCHECK(status_ == ACTIVATING || status_ == ACTIVATED) << status_; 175 DCHECK(status_ == ACTIVATING || status_ == ACTIVATED) << status_;
176 return navigation_preload_enabled_; 176 return navigation_preload_state_;
177 } 177 }
178 // Only intended for use by ServiceWorkerRegistration. Generally use 178 // Only intended for use by ServiceWorkerRegistration. Generally use
179 // ServiceWorkerRegistration::EnableNavigationPreload instead of this 179 // ServiceWorkerRegistration::EnableNavigationPreload or
180 // ServiceWorkerRegistration::SetNavigationPreloadHeader instead of this
180 // function. 181 // function.
181 void set_navigation_preload_enabled(bool enabled) { 182 void SetNavigationPreloadState(const NavigationPreloadState& state);
182 navigation_preload_enabled_ = enabled;
183 }
184 183
185 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; } 184 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; }
186 185
187 // This sets the new status and also run status change callbacks 186 // This sets the new status and also run status change callbacks
188 // if there're any (see RegisterStatusChangeCallback). 187 // if there're any (see RegisterStatusChangeCallback).
189 void SetStatus(Status status); 188 void SetStatus(Status status);
190 189
191 // Registers status change callback. (This is for one-off observation, 190 // Registers status change callback. (This is for one-off observation,
192 // the consumer needs to re-register if it wants to continue observing 191 // the consumer needs to re-register if it wants to continue observing
193 // status changes) 192 // status changes)
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 ServiceWorkerStatusCode status); 728 ServiceWorkerStatusCode status);
730 729
731 const int64_t version_id_; 730 const int64_t version_id_;
732 const int64_t registration_id_; 731 const int64_t registration_id_;
733 const GURL script_url_; 732 const GURL script_url_;
734 const GURL scope_; 733 const GURL scope_;
735 std::vector<GURL> foreign_fetch_scopes_; 734 std::vector<GURL> foreign_fetch_scopes_;
736 std::vector<url::Origin> foreign_fetch_origins_; 735 std::vector<url::Origin> foreign_fetch_origins_;
737 FetchHandlerExistence fetch_handler_existence_; 736 FetchHandlerExistence fetch_handler_existence_;
738 // The source of truth for navigation preload state is the 737 // The source of truth for navigation preload state is the
739 // ServiceWorkerRegistration. |navigation_preload_enabled_| is essentially a 738 // ServiceWorkerRegistration. |navigation_preload_state_| is essentially a
740 // cache for the state because it must be looked up quickly and a live 739 // cached value because it must be looked up quickly and a live registration
741 // registration doesn't necessarily exist whenever there is a live version. 740 // doesn't necessarily exist whenever there is a live version.
742 bool navigation_preload_enabled_ = false; 741 NavigationPreloadState navigation_preload_state_;
743 ServiceWorkerMetrics::Site site_for_uma_; 742 ServiceWorkerMetrics::Site site_for_uma_;
744 743
745 Status status_ = NEW; 744 Status status_ = NEW;
746 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; 745 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_;
747 std::vector<StatusCallback> start_callbacks_; 746 std::vector<StatusCallback> start_callbacks_;
748 std::vector<StatusCallback> stop_callbacks_; 747 std::vector<StatusCallback> stop_callbacks_;
749 std::vector<base::Closure> status_change_callbacks_; 748 std::vector<base::Closure> status_change_callbacks_;
750 749
751 // Holds in-flight requests, including requests due to outstanding push, 750 // Holds in-flight requests, including requests due to outstanding push,
752 // fetch, sync, etc. events. 751 // fetch, sync, etc. events.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 896
898 // At this point |this| can have been deleted, so don't do anything other 897 // At this point |this| can have been deleted, so don't do anything other
899 // than returning. 898 // than returning.
900 899
901 return true; 900 return true;
902 } 901 }
903 902
904 } // namespace content 903 } // namespace content
905 904
906 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 905 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698