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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // methods always return a rejected promise. And FetchEvent's | 459 // methods always return a rejected promise. And FetchEvent's |
460 // preloadResponse attribute returns a promise which always resolve with | 460 // preloadResponse attribute returns a promise which always resolve with |
461 // undefined. | 461 // undefined. |
462 // - C: Navigation Preload related methods and attributes are not available | 462 // - C: Navigation Preload related methods and attributes are not available |
463 // in JS. | 463 // in JS. |
464 // This method returns SUPPORTED only for A case. | 464 // This method returns SUPPORTED only for A case. |
465 // blink::OriginTrials::serviceWorkerNavigationPreloadEnabled() returns true | 465 // blink::OriginTrials::serviceWorkerNavigationPreloadEnabled() returns true |
466 // for both A and B case. So the methods and attributes are available in JS. | 466 // for both A and B case. So the methods and attributes are available in JS. |
467 NavigationPreloadSupportStatus GetNavigationPreloadSupportStatus() const; | 467 NavigationPreloadSupportStatus GetNavigationPreloadSupportStatus() const; |
468 | 468 |
| 469 void CountFeature(uint32_t feature); |
| 470 void set_used_features(const std::set<uint32_t>& used_features) { |
| 471 used_features_ = used_features; |
| 472 } |
| 473 const std::set<uint32_t>& used_features() const { return used_features_; } |
| 474 |
469 private: | 475 private: |
470 friend class base::RefCounted<ServiceWorkerVersion>; | 476 friend class base::RefCounted<ServiceWorkerVersion>; |
471 friend class ServiceWorkerMetrics; | 477 friend class ServiceWorkerMetrics; |
472 friend class ServiceWorkerReadFromCacheJobTest; | 478 friend class ServiceWorkerReadFromCacheJobTest; |
473 friend class ServiceWorkerStallInStoppingTest; | 479 friend class ServiceWorkerStallInStoppingTest; |
474 friend class ServiceWorkerURLRequestJobTest; | 480 friend class ServiceWorkerURLRequestJobTest; |
475 friend class ServiceWorkerVersionBrowserTest; | 481 friend class ServiceWorkerVersionBrowserTest; |
476 friend class ServiceWorkerVersionTest; | 482 friend class ServiceWorkerVersionTest; |
477 | 483 |
478 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 484 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 // while this service worker is running (i.e., after it starts up until it | 843 // while this service worker is running (i.e., after it starts up until it |
838 // stops). | 844 // stops). |
839 std::unique_ptr<ServiceWorkerMetrics::ScopedEventRecorder> event_recorder_; | 845 std::unique_ptr<ServiceWorkerMetrics::ScopedEventRecorder> event_recorder_; |
840 | 846 |
841 bool stop_when_devtools_detached_ = false; | 847 bool stop_when_devtools_detached_ = false; |
842 | 848 |
843 // Keeps the first purpose of starting the worker for UMA. Cleared in | 849 // Keeps the first purpose of starting the worker for UMA. Cleared in |
844 // FinishStartWorker(). | 850 // FinishStartWorker(). |
845 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; | 851 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; |
846 | 852 |
| 853 // This is the set of features that were used up until installation of this |
| 854 // version completed, or used during the lifetime of |this|. The values must |
| 855 // be from blink::UseCounter::Feature enum. |
| 856 std::set<uint32_t> used_features_; |
| 857 |
847 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 858 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
848 | 859 |
849 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 860 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
850 }; | 861 }; |
851 | 862 |
852 template <typename ResponseMessage> | 863 template <typename ResponseMessage> |
853 void ServiceWorkerVersion::DispatchSimpleEvent(int request_id, | 864 void ServiceWorkerVersion::DispatchSimpleEvent(int request_id, |
854 const IPC::Message& message) { | 865 const IPC::Message& message) { |
855 RegisterSimpleRequest<ResponseMessage>(request_id); | 866 RegisterSimpleRequest<ResponseMessage>(request_id); |
856 DispatchEvent({request_id}, message); | 867 DispatchEvent({request_id}, message); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 | 906 |
896 // At this point |this| can have been deleted, so don't do anything other | 907 // At this point |this| can have been deleted, so don't do anything other |
897 // than returning. | 908 // than returning. |
898 | 909 |
899 return true; | 910 return true; |
900 } | 911 } |
901 | 912 |
902 } // namespace content | 913 } // namespace content |
903 | 914 |
904 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 915 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |