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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 int64_t version_id() const { return version_id_; } | 128 int64_t version_id() const { return version_id_; } |
129 int64_t registration_id() const { return registration_id_; } | 129 int64_t registration_id() const { return registration_id_; } |
130 const GURL& script_url() const { return script_url_; } | 130 const GURL& script_url() const { return script_url_; } |
131 const GURL& scope() const { return scope_; } | 131 const GURL& scope() const { return scope_; } |
132 EmbeddedWorkerStatus running_status() const { | 132 EmbeddedWorkerStatus running_status() const { |
133 return embedded_worker_->status(); | 133 return embedded_worker_->status(); |
134 } | 134 } |
135 ServiceWorkerVersionInfo GetInfo(); | 135 ServiceWorkerVersionInfo GetInfo(); |
136 Status status() const { return status_; } | 136 Status status() const { return status_; } |
137 bool has_fetch_handler() const { return has_fetch_handler_; } | 137 |
| 138 // This flag is set when the install event has been executed in a new version |
| 139 // or when an installed version is loaded from the storage. When a new version |
| 140 // is not installed yet, returns base::nullopt. |
| 141 base::Optional<bool> has_fetch_handler() const { return has_fetch_handler_; } |
138 void set_has_fetch_handler(bool has_fetch_handler) { | 142 void set_has_fetch_handler(bool has_fetch_handler) { |
| 143 DCHECK(!has_fetch_handler_); |
139 has_fetch_handler_ = has_fetch_handler; | 144 has_fetch_handler_ = has_fetch_handler; |
140 } | 145 } |
141 | 146 |
142 const std::vector<GURL>& foreign_fetch_scopes() const { | 147 const std::vector<GURL>& foreign_fetch_scopes() const { |
143 return foreign_fetch_scopes_; | 148 return foreign_fetch_scopes_; |
144 } | 149 } |
145 void set_foreign_fetch_scopes(const std::vector<GURL>& scopes) { | 150 void set_foreign_fetch_scopes(const std::vector<GURL>& scopes) { |
146 foreign_fetch_scopes_ = scopes; | 151 foreign_fetch_scopes_ = scopes; |
147 } | 152 } |
148 | 153 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // Resets |start_worker_first_purpose_| and fires and clears all start | 661 // Resets |start_worker_first_purpose_| and fires and clears all start |
657 // callbacks. | 662 // callbacks. |
658 void FinishStartWorker(ServiceWorkerStatusCode status); | 663 void FinishStartWorker(ServiceWorkerStatusCode status); |
659 | 664 |
660 const int64_t version_id_; | 665 const int64_t version_id_; |
661 const int64_t registration_id_; | 666 const int64_t registration_id_; |
662 const GURL script_url_; | 667 const GURL script_url_; |
663 const GURL scope_; | 668 const GURL scope_; |
664 std::vector<GURL> foreign_fetch_scopes_; | 669 std::vector<GURL> foreign_fetch_scopes_; |
665 std::vector<url::Origin> foreign_fetch_origins_; | 670 std::vector<url::Origin> foreign_fetch_origins_; |
666 bool has_fetch_handler_ = true; | 671 base::Optional<bool> has_fetch_handler_; |
667 | 672 |
668 Status status_ = NEW; | 673 Status status_ = NEW; |
669 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; | 674 std::unique_ptr<EmbeddedWorkerInstance> embedded_worker_; |
670 std::vector<StatusCallback> start_callbacks_; | 675 std::vector<StatusCallback> start_callbacks_; |
671 std::vector<StatusCallback> stop_callbacks_; | 676 std::vector<StatusCallback> stop_callbacks_; |
672 std::vector<base::Closure> status_change_callbacks_; | 677 std::vector<base::Closure> status_change_callbacks_; |
673 | 678 |
674 // Holds in-flight requests, including requests due to outstanding push, | 679 // Holds in-flight requests, including requests due to outstanding push, |
675 // fetch, sync, etc. events. | 680 // fetch, sync, etc. events. |
676 IDMap<PendingRequest, IDMapOwnPointer> pending_requests_; | 681 IDMap<PendingRequest, IDMapOwnPointer> pending_requests_; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 | 818 |
814 // At this point |this| can have been deleted, so don't do anything other | 819 // At this point |this| can have been deleted, so don't do anything other |
815 // than returning. | 820 // than returning. |
816 | 821 |
817 return true; | 822 return true; |
818 } | 823 } |
819 | 824 |
820 } // namespace content | 825 } // namespace content |
821 | 826 |
822 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 827 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |