| 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 #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 Loading... |
| 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 bool navigation_preload_enabled() const { | 174 bool navigation_preload_enabled() const { |
| 175 DCHECK(status_ == ACTIVATING || status_ == ACTIVATED) << status_; |
| 174 return navigation_preload_enabled_; | 176 return navigation_preload_enabled_; |
| 175 } | 177 } |
| 178 // Only intended for use by ServiceWorkerRegistration. Generally use |
| 179 // ServiceWorkerRegistration::EnableNavigationPreload instead of this |
| 180 // function. |
| 176 void set_navigation_preload_enabled(bool enabled) { | 181 void set_navigation_preload_enabled(bool enabled) { |
| 177 navigation_preload_enabled_ = enabled; | 182 navigation_preload_enabled_ = enabled; |
| 178 } | 183 } |
| 179 | 184 |
| 180 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; } | 185 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; } |
| 181 | 186 |
| 182 // This sets the new status and also run status change callbacks | 187 // This sets the new status and also run status change callbacks |
| 183 // if there're any (see RegisterStatusChangeCallback). | 188 // if there're any (see RegisterStatusChangeCallback). |
| 184 void SetStatus(Status status); | 189 void SetStatus(Status status); |
| 185 | 190 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 void CleanUpExternalRequest(const std::string& request_uuid, | 728 void CleanUpExternalRequest(const std::string& request_uuid, |
| 724 ServiceWorkerStatusCode status); | 729 ServiceWorkerStatusCode status); |
| 725 | 730 |
| 726 const int64_t version_id_; | 731 const int64_t version_id_; |
| 727 const int64_t registration_id_; | 732 const int64_t registration_id_; |
| 728 const GURL script_url_; | 733 const GURL script_url_; |
| 729 const GURL scope_; | 734 const GURL scope_; |
| 730 std::vector<GURL> foreign_fetch_scopes_; | 735 std::vector<GURL> foreign_fetch_scopes_; |
| 731 std::vector<url::Origin> foreign_fetch_origins_; | 736 std::vector<url::Origin> foreign_fetch_origins_; |
| 732 FetchHandlerExistence fetch_handler_existence_; | 737 FetchHandlerExistence fetch_handler_existence_; |
| 738 // The source of truth for navigation preload state is the |
| 739 // ServiceWorkerRegistration. |navigation_preload_enabled_| is essentially a |
| 740 // cache for the state because it must be looked up quickly and a live |
| 741 // registration doesn't necessarily exist whenever there is a live version. |
| 733 bool navigation_preload_enabled_ = false; | 742 bool navigation_preload_enabled_ = false; |
| 734 ServiceWorkerMetrics::Site site_for_uma_; | 743 ServiceWorkerMetrics::Site site_for_uma_; |
| 735 | 744 |
| 736 Status status_ = NEW; | 745 Status status_ = NEW; |
| 737 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; | 746 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; |
| 738 std::vector<StatusCallback> start_callbacks_; | 747 std::vector<StatusCallback> start_callbacks_; |
| 739 std::vector<StatusCallback> stop_callbacks_; | 748 std::vector<StatusCallback> stop_callbacks_; |
| 740 std::vector<base::Closure> status_change_callbacks_; | 749 std::vector<base::Closure> status_change_callbacks_; |
| 741 | 750 |
| 742 // Holds in-flight requests, including requests due to outstanding push, | 751 // Holds in-flight requests, including requests due to outstanding push, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 897 |
| 889 // At this point |this| can have been deleted, so don't do anything other | 898 // At this point |this| can have been deleted, so don't do anything other |
| 890 // than returning. | 899 // than returning. |
| 891 | 900 |
| 892 return true; | 901 return true; |
| 893 } | 902 } |
| 894 | 903 |
| 895 } // namespace content | 904 } // namespace content |
| 896 | 905 |
| 897 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 906 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |