Chromium Code Reviews| 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 ServiceWorkerLifetimeTracker(std::unique_ptr<base::TickClock> tick_clock); | |
| 26 virtual ~ServiceWorkerLifetimeTracker(); | |
| 27 | |
| 28 // Called when the worker started running. | |
| 29 void StartTiming(int64_t version_id); | |
|
nhiroki
2017/02/28 08:50:07
Can you replace version_id with embedded_worker_id
| |
| 30 // Called when the worker stopped running. | |
| 31 void StopTiming(int64_t version_id); | |
| 32 // Called when DevTools was attached to the worker. Forgets the outstanding | |
| 33 // start timing. | |
| 34 void AbortTiming(int64_t version_id); | |
| 35 | |
| 36 private: | |
| 37 friend class ServiceWorkerLifetimeTrackerTest; | |
| 38 | |
| 39 void RecordHistograms(); | |
| 40 | |
| 41 std::unique_ptr<base::TickClock> tick_clock_; | |
| 42 std::map<int64_t /* version_id */, base::TimeTicks /* start_time */> | |
| 43 running_workers_; | |
| 44 base::RepeatingTimer timer_; | |
| 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 |