Revert of Linux MSan: enable swarming/sharding for browser_tests. (patchset #1 id...
[chromium-blink-merge.git] / cc / output / begin_frame_args.h
blob47430ca9f2963dc15318a65de722d4c39c0e52d0
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_OUTPUT_BEGIN_FRAME_ARGS_H_
6 #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_
8 #include "base/location.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
11 #include "base/values.h"
12 #include "cc/base/cc_export.h"
14 namespace base {
15 namespace trace_event {
16 class ConvertableToTraceFormat;
17 class TracedValue;
20 // TODO(ssid): remove these aliases after the tracing clients are moved to the
21 // new trace_event namespace. See crbug.com/451032. ETA: March 2015
22 namespace debug {
23 using ::base::trace_event::ConvertableToTraceFormat;
24 using ::base::trace_event::TracedValue;
26 } // namespace base
28 /**
29 * In debug builds we trace the creation origin of BeginFrameArgs objects. We
30 * reuse the tracked_objects::Location system to do that.
32 * However, in release builds we don't want this as it doubles the size of the
33 * BeginFrameArgs object. As well it adds a number of largish strings to the
34 * binary. Despite the argument being unused, most compilers are unable to
35 * optimise it away even when unused. Instead we use the BEGINFRAME_FROM_HERE
36 * macro to prevent the data even getting referenced.
38 #ifdef NDEBUG
39 #define BEGINFRAME_FROM_HERE nullptr
40 #else
41 #define BEGINFRAME_FROM_HERE FROM_HERE
42 #endif
44 namespace cc {
46 struct CC_EXPORT BeginFrameArgs {
47 enum BeginFrameArgsType {
48 INVALID,
49 NORMAL,
50 SYNCHRONOUS,
51 MISSED,
52 // Not a real type, but used by the IPC system. Should always remain the
53 // *last* value in this enum.
54 BEGIN_FRAME_ARGS_TYPE_MAX,
56 static const char* TypeToString(BeginFrameArgsType type);
58 // Creates an invalid set of values.
59 BeginFrameArgs();
61 #ifdef NDEBUG
62 typedef const void* CreationLocation;
63 #else
64 typedef const tracked_objects::Location& CreationLocation;
65 tracked_objects::Location created_from;
66 #endif
68 // You should be able to find all instances where a BeginFrame has been
69 // created by searching for "BeginFrameArgs::Create".
70 // The location argument should **always** be BEGINFRAME_FROM_HERE macro.
71 static BeginFrameArgs Create(CreationLocation location,
72 base::TimeTicks frame_time,
73 base::TimeTicks deadline,
74 base::TimeDelta interval,
75 BeginFrameArgsType type);
77 // This is the default delta that will be used to adjust the deadline when
78 // proper draw-time estimations are not yet available.
79 static base::TimeDelta DefaultEstimatedParentDrawTime();
81 // This is the default interval to use to avoid sprinkling the code with
82 // magic numbers.
83 static base::TimeDelta DefaultInterval();
85 bool IsValid() const { return interval >= base::TimeDelta(); }
87 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
88 void AsValueInto(base::debug::TracedValue* dict) const;
90 base::TimeTicks frame_time;
91 base::TimeTicks deadline;
92 base::TimeDelta interval;
93 BeginFrameArgsType type;
95 private:
96 BeginFrameArgs(base::TimeTicks frame_time,
97 base::TimeTicks deadline,
98 base::TimeDelta interval,
99 BeginFrameArgsType type);
102 } // namespace cc
104 #endif // CC_OUTPUT_BEGIN_FRAME_ARGS_H_