| 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <queue> | 13 #include <queue> |
| 14 #include <set> | 14 #include <set> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <utility> | 16 #include <utility> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/callback.h" | 19 #include "base/callback.h" |
| 20 #include "base/gtest_prod_util.h" | 20 #include "base/gtest_prod_util.h" |
| 21 #include "base/id_map.h" | 21 #include "base/id_map.h" |
| 22 #include "base/macros.h" | 22 #include "base/macros.h" |
| 23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
| 24 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 25 #include "base/observer_list.h" | 25 #include "base/observer_list.h" |
| 26 #include "base/optional.h" | |
| 27 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/time/tick_clock.h" | 27 #include "base/time/tick_clock.h" |
| 29 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 30 #include "base/timer/timer.h" | 29 #include "base/timer/timer.h" |
| 31 #include "content/browser/service_worker/embedded_worker_instance.h" | 30 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 32 #include "content/browser/service_worker/embedded_worker_status.h" | 31 #include "content/browser/service_worker/embedded_worker_status.h" |
| 33 #include "content/browser/service_worker/service_worker_context_request_handler.
h" | 32 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
| 34 #include "content/browser/service_worker/service_worker_metrics.h" | 33 #include "content/browser/service_worker/service_worker_metrics.h" |
| 35 #include "content/browser/service_worker/service_worker_script_cache_map.h" | 34 #include "content/browser/service_worker/service_worker_script_cache_map.h" |
| 36 #include "content/common/content_export.h" | 35 #include "content/common/content_export.h" |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 ServiceWorkerStatusCode status, | 753 ServiceWorkerStatusCode status, |
| 755 scoped_refptr<ServiceWorkerRegistration> registration); | 754 scoped_refptr<ServiceWorkerRegistration> registration); |
| 756 | 755 |
| 757 void OnStoppedInternal(EmbeddedWorkerStatus old_status); | 756 void OnStoppedInternal(EmbeddedWorkerStatus old_status); |
| 758 | 757 |
| 759 // Called at the beginning of each Dispatch*Event function: records | 758 // Called at the beginning of each Dispatch*Event function: records |
| 760 // the time elapsed since idle (generally the time since the previous | 759 // the time elapsed since idle (generally the time since the previous |
| 761 // event ended). | 760 // event ended). |
| 762 void OnBeginEvent(); | 761 void OnBeginEvent(); |
| 763 | 762 |
| 764 // Resets |start_worker_first_purpose_| and fires and clears all start | 763 // Fires and clears all start callbacks. |
| 765 // callbacks. | |
| 766 void FinishStartWorker(ServiceWorkerStatusCode status); | 764 void FinishStartWorker(ServiceWorkerStatusCode status); |
| 767 | 765 |
| 768 // Removes any pending external request that has GUID of |request_uuid|. | 766 // Removes any pending external request that has GUID of |request_uuid|. |
| 769 void CleanUpExternalRequest(const std::string& request_uuid, | 767 void CleanUpExternalRequest(const std::string& request_uuid, |
| 770 ServiceWorkerStatusCode status); | 768 ServiceWorkerStatusCode status); |
| 771 | 769 |
| 772 const int64_t version_id_; | 770 const int64_t version_id_; |
| 773 const int64_t registration_id_; | 771 const int64_t registration_id_; |
| 774 const GURL script_url_; | 772 const GURL script_url_; |
| 775 const GURL scope_; | 773 const GURL scope_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 855 |
| 858 std::unique_ptr<PingController> ping_controller_; | 856 std::unique_ptr<PingController> ping_controller_; |
| 859 | 857 |
| 860 // Used for recording worker activities (e.g., a ratio of handled events) | 858 // Used for recording worker activities (e.g., a ratio of handled events) |
| 861 // while this service worker is running (i.e., after it starts up until it | 859 // while this service worker is running (i.e., after it starts up until it |
| 862 // stops). | 860 // stops). |
| 863 std::unique_ptr<ServiceWorkerMetrics::ScopedEventRecorder> event_recorder_; | 861 std::unique_ptr<ServiceWorkerMetrics::ScopedEventRecorder> event_recorder_; |
| 864 | 862 |
| 865 bool stop_when_devtools_detached_ = false; | 863 bool stop_when_devtools_detached_ = false; |
| 866 | 864 |
| 867 // Keeps the first purpose of starting the worker for UMA. Cleared in | |
| 868 // FinishStartWorker(). | |
| 869 base::Optional<ServiceWorkerMetrics::EventType> start_worker_first_purpose_; | |
| 870 | |
| 871 // This is the set of features that were used up until installation of this | 865 // This is the set of features that were used up until installation of this |
| 872 // version completed, or used during the lifetime of |this|. The values must | 866 // version completed, or used during the lifetime of |this|. The values must |
| 873 // be from blink::UseCounter::Feature enum. | 867 // be from blink::UseCounter::Feature enum. |
| 874 std::set<uint32_t> used_features_; | 868 std::set<uint32_t> used_features_; |
| 875 | 869 |
| 876 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 870 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
| 877 | 871 |
| 878 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 872 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
| 879 }; | 873 }; |
| 880 | 874 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 920 |
| 927 // At this point |this| can have been deleted, so don't do anything other | 921 // At this point |this| can have been deleted, so don't do anything other |
| 928 // than returning. | 922 // than returning. |
| 929 | 923 |
| 930 return true; | 924 return true; |
| 931 } | 925 } |
| 932 | 926 |
| 933 } // namespace content | 927 } // namespace content |
| 934 | 928 |
| 935 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 929 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |