| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_LIFETIME_TRACKER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_LIFETIME_TRACKER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/time/tick_clock.h" |
| 15 #include "base/timer/timer.h" |
| 16 #include "content/common/content_export.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // ServiceWorkerLifetimeTracker tracks how long service workers run, for UMA |
| 21 // purposes. |
| 22 class CONTENT_EXPORT ServiceWorkerLifetimeTracker { |
| 23 public: |
| 24 ServiceWorkerLifetimeTracker(); |
| 25 explicit ServiceWorkerLifetimeTracker( |
| 26 std::unique_ptr<base::TickClock> tick_clock); |
| 27 virtual ~ServiceWorkerLifetimeTracker(); |
| 28 |
| 29 // Called when the worker started running. |
| 30 void StartTiming(int64_t embedded_worker_id); |
| 31 // Called when the worker stopped running. |
| 32 void StopTiming(int64_t embedded_worker_id); |
| 33 // Called when DevTools was attached to the worker. Forgets the outstanding |
| 34 // start timing. |
| 35 void AbortTiming(int64_t embedded_worker_id); |
| 36 |
| 37 private: |
| 38 friend class ServiceWorkerLifetimeTrackerTest; |
| 39 |
| 40 void RecordHistograms(); |
| 41 |
| 42 std::unique_ptr<base::TickClock> tick_clock_; |
| 43 std::map<int64_t /* embedded_worker_id */, base::TimeTicks /* start_time */> |
| 44 running_workers_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerLifetimeTracker); |
| 47 }; |
| 48 |
| 49 } // namespace content |
| 50 |
| 51 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_LIFETIME_TRACKER_H_ |
| OLD | NEW |