| Index: cc/debug/worker_thread_cost_tracker.h
|
| diff --git a/cc/debug/worker_thread_cost_tracker.h b/cc/debug/worker_thread_cost_tracker.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b5686c95b4fc24f30fabb3bc0645c9c8f1d2b6da
|
| --- /dev/null
|
| +++ b/cc/debug/worker_thread_cost_tracker.h
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
|
| +#define CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "base/time/time.h"
|
| +
|
| +namespace cc {
|
| +
|
| +class WorkerThreadCostTracker {
|
| + public:
|
| + class Probe {
|
| + public:
|
| + Probe(WorkerThreadCostTracker* tracker, int tracked_source_frame_number);
|
| + ~Probe();
|
| +
|
| + void Start(int source_frame_number);
|
| + void Stop();
|
| +
|
| + private:
|
| + WorkerThreadCostTracker* tracker_;
|
| + int tracked_source_frame_number_;
|
| + base::PlatformThreadId tracker_thread_id_;
|
| +
|
| + bool started_;
|
| + base::TimeTicks start_;
|
| + base::TimeDelta cost_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| + };
|
| +
|
| + WorkerThreadCostTracker();
|
| + ~WorkerThreadCostTracker();
|
| +
|
| + void set_source_frame_to_track(int source_frame_number) {
|
| + source_frame_number_ = source_frame_number;
|
| + }
|
| + void reset_cost() { cost_ = base::TimeDelta(); }
|
| + base::TimeDelta get_cost() { return cost_; }
|
| +
|
| + scoped_ptr<Probe> CreateProbe();
|
| +
|
| + private:
|
| + friend class Probe;
|
| +
|
| + void add_cost(const base::TimeDelta& cost) { cost_ += cost; }
|
| +
|
| + int source_frame_number_;
|
| + base::TimeDelta cost_;
|
| +};
|
| +
|
| +} // namespace cc
|
| +
|
| +#endif // CC_DEBUG_WORKER_THREAD_COST_TRACKER_H_
|
|
|