Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3802)

Unified Diff: cc/output/begin_frame_args.cc

Issue 270703004: Making BeginFrameArgs work with TRACE_EVENT system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/begin_frame_args.cc
diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc
index 92901afb1f3d897b37ca374297a8e5bc25463cbc..f74c061fda0500c6a1ae6d911b0bf5d63f12599a 100644
--- a/cc/output/begin_frame_args.cc
+++ b/cc/output/begin_frame_args.cc
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
+#include "base/json/json_writer.h"
#include "cc/output/begin_frame_args.h"
#include "ui/gfx/frame_time.h"
@@ -27,6 +30,58 @@ BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time,
return BeginFrameArgs(frame_time, deadline, interval);
}
+scoped_ptr<base::Value> BeginFrameArgs::AsValue() const {
+ scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
+ state->SetString("type", "BeginFrameArgs");
+ state->SetDouble("frame_time_us", frame_time.ToInternalValue());
+ state->SetDouble("deadline_us", deadline.ToInternalValue());
+ state->SetDouble("interval_us", interval.InMicroseconds());
+ return state.PassAs<base::Value>();
+}
+
+namespace {
+
+// TODO(mithro): This class should be part of base/debug/trace code.
+class TracedValue : public base::debug::ConvertableToTraceFormat {
+ public:
+ static scoped_refptr<base::debug::ConvertableToTraceFormat> FromValue(
+ scoped_ptr<base::Value> value);
+
+ virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE;
+
+ private:
+ explicit TracedValue(base::Value* value);
+ virtual ~TracedValue();
+
+ scoped_ptr<base::Value> value_;
+
+ DISALLOW_COPY_AND_ASSIGN(TracedValue);
+};
+
+scoped_refptr<base::debug::ConvertableToTraceFormat> TracedValue::FromValue(
+ scoped_ptr<base::Value> value) {
+ return scoped_refptr<base::debug::ConvertableToTraceFormat>(
+ new TracedValue(value.release()));
+}
+
+TracedValue::~TracedValue() {
+}
+
+void TracedValue::AppendAsTraceFormat(std::string* out) const {
+ std::string tmp;
+ base::JSONWriter::Write(value_.get(), &tmp);
+ *out += tmp;
+}
+
+TracedValue::TracedValue(base::Value* value) : value_(value) {
+}
+} // namespace
+
+scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsTrace()
+ const {
+ return TracedValue::FromValue(AsValue());
+}
+
BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor() {
// For WebView/SynchronousCompositor, we always want to draw immediately,
// so we set the deadline to 0 and guess that the interval is 16 milliseconds.

Powered by Google App Engine
This is Rietveld 408576698