OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_ |
| 6 #define CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/threading/thread_checker.h" |
| 10 #include "base/time/time.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 class WorkerThreadCostTracker { |
| 15 public: |
| 16 class Probe { |
| 17 public: |
| 18 Probe(WorkerThreadCostTracker* tracker, int tracked_source_frame_number); |
| 19 ~Probe(); |
| 20 |
| 21 void Start(int source_frame_number); |
| 22 void Stop(); |
| 23 |
| 24 private: |
| 25 WorkerThreadCostTracker* tracker_; |
| 26 int tracked_source_frame_number_; |
| 27 base::PlatformThreadId tracker_thread_id_; |
| 28 |
| 29 bool started_; |
| 30 base::TimeTicks start_; |
| 31 base::TimeDelta cost_; |
| 32 |
| 33 base::ThreadChecker thread_checker_; |
| 34 }; |
| 35 |
| 36 WorkerThreadCostTracker(); |
| 37 ~WorkerThreadCostTracker(); |
| 38 |
| 39 void set_source_frame_to_track(int source_frame_number) { |
| 40 source_frame_number_ = source_frame_number; |
| 41 } |
| 42 void reset_cost() { cost_ = base::TimeDelta(); } |
| 43 base::TimeDelta get_cost() { return cost_; } |
| 44 |
| 45 scoped_ptr<Probe> CreateProbe(); |
| 46 |
| 47 private: |
| 48 friend class Probe; |
| 49 |
| 50 void add_cost(const base::TimeDelta& cost) { cost_ += cost; } |
| 51 |
| 52 int source_frame_number_; |
| 53 base::TimeDelta cost_; |
| 54 }; |
| 55 |
| 56 } // namespace cc |
| 57 |
| 58 #endif // CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_ |
OLD | NEW |