| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 const std::vector<url::Origin>& foreign_fetch_origins() const { | 165 const std::vector<url::Origin>& foreign_fetch_origins() const { |
| 166 return foreign_fetch_origins_; | 166 return foreign_fetch_origins_; |
| 167 } | 167 } |
| 168 void set_foreign_fetch_origins(const std::vector<url::Origin>& origins) { | 168 void set_foreign_fetch_origins(const std::vector<url::Origin>& origins) { |
| 169 foreign_fetch_origins_ = origins; | 169 foreign_fetch_origins_ = origins; |
| 170 } | 170 } |
| 171 | 171 |
| 172 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; } | 172 ServiceWorkerMetrics::Site site_for_uma() const { return site_for_uma_; } |
| 173 | 173 |
| 174 void set_navigation_preload_enabled(bool enabled, const std::string& value) { |
| 175 is_navigation_preload_enabled_ = enabled; |
| 176 if (is_navigation_preload_enabled_) |
| 177 navigation_preload_value_ = value; |
| 178 else |
| 179 navigation_preload_value_ = std::string(); |
| 180 } |
| 181 |
| 182 bool is_navigation_preload_enabled() const { |
| 183 return is_navigation_preload_enabled_; |
| 184 } |
| 185 const std::string& navigation_preload_value() const { |
| 186 DCHECK(is_navigation_preload_enabled_); |
| 187 return navigation_preload_value_; |
| 188 } |
| 189 |
| 174 // This sets the new status and also run status change callbacks | 190 // This sets the new status and also run status change callbacks |
| 175 // if there're any (see RegisterStatusChangeCallback). | 191 // if there're any (see RegisterStatusChangeCallback). |
| 176 void SetStatus(Status status); | 192 void SetStatus(Status status); |
| 177 | 193 |
| 178 // Registers status change callback. (This is for one-off observation, | 194 // Registers status change callback. (This is for one-off observation, |
| 179 // the consumer needs to re-register if it wants to continue observing | 195 // the consumer needs to re-register if it wants to continue observing |
| 180 // status changes) | 196 // status changes) |
| 181 void RegisterStatusChangeCallback(const base::Closure& callback); | 197 void RegisterStatusChangeCallback(const base::Closure& callback); |
| 182 | 198 |
| 183 // Starts an embedded worker for this version. | 199 // Starts an embedded worker for this version. |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 std::unique_ptr<PingController> ping_controller_; | 771 std::unique_ptr<PingController> ping_controller_; |
| 756 std::unique_ptr<Metrics> metrics_; | 772 std::unique_ptr<Metrics> metrics_; |
| 757 const bool should_exclude_from_uma_ = false; | 773 const bool should_exclude_from_uma_ = false; |
| 758 | 774 |
| 759 bool stop_when_devtools_detached_ = false; | 775 bool stop_when_devtools_detached_ = false; |
| 760 | 776 |
| 761 // Keeps the first purpose of starting the worker for UMA. Cleared in | 777 // Keeps the first purpose of starting the worker for UMA. Cleared in |
| 762 // FinishStartWorker(). | 778 // FinishStartWorker(). |
| 763 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; | 779 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; |
| 764 | 780 |
| 781 bool is_navigation_preload_enabled_ = false; |
| 782 std::string navigation_preload_value_; |
| 783 |
| 765 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 784 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
| 766 | 785 |
| 767 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 786 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
| 768 }; | 787 }; |
| 769 | 788 |
| 770 template <typename Interface> | 789 template <typename Interface> |
| 771 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest( | 790 base::WeakPtr<Interface> ServiceWorkerVersion::GetMojoServiceForRequest( |
| 772 int request_id) { | 791 int request_id) { |
| 773 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); | 792 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); |
| 774 PendingRequest* request = pending_requests_.Lookup(request_id); | 793 PendingRequest* request = pending_requests_.Lookup(request_id); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 | 857 |
| 839 // At this point |this| can have been deleted, so don't do anything other | 858 // At this point |this| can have been deleted, so don't do anything other |
| 840 // than returning. | 859 // than returning. |
| 841 | 860 |
| 842 return true; | 861 return true; |
| 843 } | 862 } |
| 844 | 863 |
| 845 } // namespace content | 864 } // namespace content |
| 846 | 865 |
| 847 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 866 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |