Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / cc / debug / rendering_stats_instrumentation.h
blob477968877881442b5d337008b37af9a2f4a4c07b
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
3 // found in the LICENSE file.
5 #ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
6 #define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h"
10 #include "cc/debug/rendering_stats.h"
12 namespace cc {
14 // RenderingStatsInstrumentation is shared among threads and manages conditional
15 // recording of rendering stats into a private RenderingStats instance.
16 class CC_EXPORT RenderingStatsInstrumentation {
17 public:
18 static scoped_ptr<RenderingStatsInstrumentation> Create();
19 virtual ~RenderingStatsInstrumentation();
21 // Return copy of current impl thread rendering stats.
22 RenderingStats impl_thread_rendering_stats();
24 // Return the accumulated, combined rendering stats.
25 RenderingStats GetRenderingStats();
27 // Add current impl thread rendering stats to accumulator and
28 // clear current stats.
29 void AccumulateAndClearImplThreadStats();
31 // Read and write access to the record_rendering_stats_ flag is not locked to
32 // improve performance. The flag is commonly turned off and hardly changes
33 // it's value during runtime.
34 bool record_rendering_stats() const { return record_rendering_stats_; }
35 void set_record_rendering_stats(bool record_rendering_stats) {
36 if (record_rendering_stats_ != record_rendering_stats)
37 record_rendering_stats_ = record_rendering_stats;
40 base::TimeDelta StartRecording() const;
41 base::TimeDelta EndRecording(base::TimeDelta start_time) const;
43 void IncrementFrameCount(int64 count);
44 void AddVisibleContentArea(int64 area);
45 void AddApproximatedVisibleContentArea(int64 area);
46 void AddCheckerboardedVisibleContentArea(int64 area);
47 void AddDrawDuration(base::TimeDelta draw_duration,
48 base::TimeDelta draw_duration_estimate);
49 void AddBeginMainFrameToCommitDuration(
50 base::TimeDelta begin_main_frame_to_commit_duration,
51 base::TimeDelta begin_main_frame_to_commit_duration_estimate);
52 void AddCommitToActivateDuration(
53 base::TimeDelta commit_to_activate_duration,
54 base::TimeDelta commit_to_activate_duration_estimate);
56 protected:
57 RenderingStatsInstrumentation();
59 private:
60 RenderingStats impl_thread_rendering_stats_;
61 RenderingStats impl_thread_rendering_stats_accu_;
63 bool record_rendering_stats_;
65 base::Lock lock_;
67 DISALLOW_COPY_AND_ASSIGN(RenderingStatsInstrumentation);
70 } // namespace cc
72 #endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_