diff options
author | erikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-31 19:02:09 +0000 |
---|---|---|
committer | erikchen@chromium.org <erikchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-31 19:02:09 +0000 |
commit | 88bcc14cd89a644f09a0ec660901c1454a5526c0 (patch) | |
tree | 92d22c761b891111bd7ebefb625d027afbd065b7 | |
parent | e9b84dd07ea9dc15a4315703bd94a0b0d89052f9 (diff) | |
download | chromium_src-88bcc14cd89a644f09a0ec660901c1454a5526c0.zip chromium_src-88bcc14cd89a644f09a0ec660901c1454a5526c0.tar.gz chromium_src-88bcc14cd89a644f09a0ec660901c1454a5526c0.tar.bz2 |
Revert of Add builders for tracing event's structural arguments (https://codereview.chromium.org/380763002/)
Reason for revert:
linux ASAN errors.
http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/4493/steps/base_unittests/logs/stdio
Original issue's description:
> Add builders for tracing event's structural arguments
>
> The new classes allow building JSON-like structural arguments. Current implementation uses base::Value as backing store but that can be replaced in the future with something more efficient without changing client code.
>
> All clients of cc/debug/traced_value.h should eventually switch to use the new builders.
>
> BUG=361045
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=286849
TBR=alph, caseq, dsinclair, nduca, willchan, yurys
NOTREECHECKS=true
NOTRY=true
BUG=361045
Review URL: https://codereview.chromium.org/421183003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286862 0039d316-1c4b-4281-b951-d872f2087c98
111 files changed, 861 insertions, 1329 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn index 9c3ef5b..72cf5be 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -154,8 +154,6 @@ component("base") { "debug/stack_trace_win.cc", "debug/trace_event.h", "debug/trace_event_android.cc", - "debug/trace_event_argument.cc", - "debug/trace_event_argument.h", "debug/trace_event_impl.cc", "debug/trace_event_impl.h", "debug/trace_event_impl_constants.cc", @@ -1072,7 +1070,6 @@ test("base_unittests") { "debug/leak_tracker_unittest.cc", "debug/proc_maps_linux_unittest.cc", "debug/stack_trace_unittest.cc", - "debug/trace_event_argument_unittest.cc", "debug/trace_event_memory_unittest.cc", "debug/trace_event_synthetic_delay_unittest.cc", "debug/trace_event_system_stats_monitor_unittest.cc", diff --git a/base/base.gyp b/base/base.gyp index f934b23..988feee 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -448,7 +448,6 @@ 'debug/leak_tracker_unittest.cc', 'debug/proc_maps_linux_unittest.cc', 'debug/stack_trace_unittest.cc', - 'debug/trace_event_argument_unittest.cc', 'debug/trace_event_memory_unittest.cc', 'debug/trace_event_synthetic_delay_unittest.cc', 'debug/trace_event_system_stats_monitor_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index d5eb0ca..079355e 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -160,8 +160,6 @@ 'debug/stack_trace_win.cc', 'debug/trace_event.h', 'debug/trace_event_android.cc', - 'debug/trace_event_argument.cc', - 'debug/trace_event_argument.h', 'debug/trace_event_impl.cc', 'debug/trace_event_impl.h', 'debug/trace_event_impl_constants.cc', diff --git a/base/debug/trace_event_argument.cc b/base/debug/trace_event_argument.cc deleted file mode 100644 index e4a12f6..0000000 --- a/base/debug/trace_event_argument.cc +++ /dev/null @@ -1,117 +0,0 @@ -// 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. - -#include "base/debug/trace_event_argument.h" - -#include "base/json/json_writer.h" -#include "base/values.h" - -namespace base { -namespace debug { - -TracedValue::TracedValue() { - stack_.push_back(new DictionaryValue()); -} - -TracedValue::~TracedValue() { - DCHECK_EQ(1u, stack_.size()); -} - -void TracedValue::SetInteger(const char* name, int value) { - GetCurrentDictionary()->SetInteger(name, value); -} - -void TracedValue::SetDouble(const char* name, double value) { - GetCurrentDictionary()->SetDouble(name, value); -} - -void TracedValue::SetBoolean(const char* name, bool value) { - GetCurrentDictionary()->SetBoolean(name, value); -} - -void TracedValue::SetString(const char* name, const std::string& value) { - GetCurrentDictionary()->SetString(name, value); -} - -void TracedValue::SetValue(const char* name, Value* value) { - GetCurrentDictionary()->Set(name, value); -} - -void TracedValue::BeginDictionary(const char* name) { - DictionaryValue* dictionary = new DictionaryValue(); - GetCurrentDictionary()->Set(name, dictionary); - stack_.push_back(dictionary); -} - -void TracedValue::BeginArray(const char* name) { - ListValue* array = new ListValue(); - GetCurrentDictionary()->Set(name, array); - stack_.push_back(array); -} - -void TracedValue::EndDictionary() { - DCHECK_GT(stack_.size(), 1u); - DCHECK(GetCurrentDictionary()); - stack_.pop_back(); -} - -void TracedValue::AppendInteger(int value) { - GetCurrentArray()->AppendInteger(value); -} - -void TracedValue::AppendDouble(double value) { - GetCurrentArray()->AppendDouble(value); -} - -void TracedValue::AppendBoolean(bool value) { - GetCurrentArray()->AppendBoolean(value); -} - -void TracedValue::AppendString(const std::string& value) { - GetCurrentArray()->AppendString(value); -} - -void TracedValue::BeginArray() { - ListValue* array = new ListValue(); - GetCurrentArray()->Append(array); - stack_.push_back(array); -} - -void TracedValue::BeginDictionary() { - DictionaryValue* dictionary = new DictionaryValue(); - GetCurrentArray()->Append(dictionary); - stack_.push_back(dictionary); -} - -void TracedValue::EndArray() { - DCHECK_GT(stack_.size(), 1u); - DCHECK(GetCurrentArray()); - stack_.pop_back(); -} - -DictionaryValue* TracedValue::GetCurrentDictionary() { - DCHECK(!stack_.empty()); - DictionaryValue* dictionary = NULL; - stack_.back()->GetAsDictionary(&dictionary); - DCHECK(dictionary); - return dictionary; -} - -ListValue* TracedValue::GetCurrentArray() { - DCHECK(!stack_.empty()); - ListValue* list = NULL; - stack_.back()->GetAsList(&list); - DCHECK(list); - return list; -} - -void TracedValue::AppendAsTraceFormat(std::string* out) const { - std::string tmp; - JSONWriter::Write(stack_.front(), &tmp); - *out += tmp; - DCHECK_EQ(1u, stack_.size()) << tmp; -} - -} // namespace debug -} // namespace base diff --git a/base/debug/trace_event_argument.h b/base/debug/trace_event_argument.h deleted file mode 100644 index ee056c0..0000000 --- a/base/debug/trace_event_argument.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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 BASE_DEBUG_TRACE_EVENT_ARGUMENT_H_ -#define BASE_DEBUG_TRACE_EVENT_ARGUMENT_H_ - -#include <string> -#include <vector> - -#include "base/debug/trace_event.h" - -namespace base { -class DictionaryValue; -class ListValue; -class Value; - -namespace debug { - -class BASE_EXPORT TracedValue : public ConvertableToTraceFormat { - public: - TracedValue(); - - void EndDictionary(); - void EndArray(); - - void SetInteger(const char* name, int value); - void SetDouble(const char* name, double); - void SetBoolean(const char* name, bool value); - void SetString(const char* name, const std::string& value); - void SetValue(const char* name, Value* value); - void BeginDictionary(const char* name); - void BeginArray(const char* name); - - void AppendInteger(int); - void AppendDouble(double); - void AppendBoolean(bool); - void AppendString(const std::string&); - void BeginArray(); - void BeginDictionary(); - - virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; - - private: - virtual ~TracedValue(); - - DictionaryValue* GetCurrentDictionary(); - ListValue* GetCurrentArray(); - - std::vector<Value*> stack_; - DISALLOW_COPY_AND_ASSIGN(TracedValue); -}; - -} // namespace debug -} // namespace base - -#endif // BASE_DEBUG_TRACE_EVENT_ARGUMENT_H_ diff --git a/base/debug/trace_event_argument_unittest.cc b/base/debug/trace_event_argument_unittest.cc deleted file mode 100644 index 3ec3ad4..0000000 --- a/base/debug/trace_event_argument_unittest.cc +++ /dev/null @@ -1,53 +0,0 @@ -// 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. - -#include "base/debug/trace_event_argument.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace base { -namespace debug { - -TEST(TraceEventArgumentTest, FlatDictionary) { - scoped_refptr<TracedValue> value = new TracedValue(); - value->SetInteger("int", 2014); - value->SetDouble("double", 0.0); - value->SetBoolean("bool", true); - value->SetString("string", "string"); - std::string json; - value->AppendAsTraceFormat(&json); - EXPECT_EQ("{\"bool\":true,\"double\":0.0,\"int\":2014,\"string\":\"string\"}", - json); -} - -TEST(TraceEventArgumentTest, Hierarchy) { - scoped_refptr<TracedValue> value = new TracedValue(); - value->SetInteger("i0", 2014); - value->BeginDictionary("dict1"); - value->SetInteger("i1", 2014); - value->BeginDictionary("dict2"); - value->SetBoolean("b2", false); - value->EndDictionary(); - value->SetString("s1", "foo"); - value->EndDictionary(); - value->SetDouble("d0", 0.0); - value->SetBoolean("b0", true); - value->BeginArray("a1"); - value->AppendInteger(1); - value->AppendBoolean(true); - value->BeginDictionary(); - value->SetInteger("i2", 3); - value->EndDictionary(); - value->EndArray(); - value->SetString("s0", "foo"); - std::string json; - value->AppendAsTraceFormat(&json); - EXPECT_EQ( - "{\"a1\":[1,true,{\"i2\":3}],\"b0\":true,\"d0\":0.0,\"dict1\":{\"dict2\":" - "{\"b2\":false},\"i1\":2014,\"s1\":\"foo\"},\"i0\":2014,\"s0\":" - "\"foo\"}", - json); -} - -} // namespace debug -} // namespace base diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h index 146ca8f..7b191b8 100644 --- a/base/debug/trace_event_impl.h +++ b/base/debug/trace_event_impl.h @@ -64,8 +64,7 @@ namespace debug { // For any argument of type TRACE_VALUE_TYPE_CONVERTABLE the provided // class must implement this interface. -class BASE_EXPORT ConvertableToTraceFormat - : public RefCounted<ConvertableToTraceFormat> { +class ConvertableToTraceFormat : public RefCounted<ConvertableToTraceFormat> { public: // Append the class info to the provided |out| string. The appended // data must be a valid JSON object. Strings must be properly quoted, and @@ -73,12 +72,6 @@ class BASE_EXPORT ConvertableToTraceFormat // appended. virtual void AppendAsTraceFormat(std::string* out) const = 0; - std::string ToString() const { - std::string result; - AppendAsTraceFormat(&result); - return result; - } - protected: virtual ~ConvertableToTraceFormat() {} diff --git a/cc/base/math_util.cc b/cc/base/math_util.cc index fd8e796..07ad77b 100644 --- a/cc/base/math_util.cc +++ b/cc/base/math_util.cc @@ -8,7 +8,6 @@ #include <cmath> #include <limits> -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "ui/gfx/quad_f.h" #include "ui/gfx/rect.h" @@ -548,6 +547,13 @@ scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Size& s) { return res.PassAs<base::Value>(); } +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::SizeF& s) { + scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); + res->SetDouble("width", s.width()); + res->SetDouble("height", s.height()); + return res.PassAs<base::Value>(); +} + scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Rect& r) { scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendInteger(r.x()); @@ -585,47 +591,23 @@ scoped_ptr<base::Value> MathUtil::AsValue(const gfx::PointF& pt) { return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::Size& s, - base::debug::TracedValue* res) { - res->SetDouble("width", s.width()); - res->SetDouble("height", s.height()); -} - -void MathUtil::AddToTracedValue(const gfx::SizeF& s, - base::debug::TracedValue* res) { - res->SetDouble("width", s.width()); - res->SetDouble("height", s.height()); -} - -void MathUtil::AddToTracedValue(const gfx::Rect& r, - base::debug::TracedValue* res) { - res->AppendInteger(r.x()); - res->AppendInteger(r.y()); - res->AppendInteger(r.width()); - res->AppendInteger(r.height()); -} - -void MathUtil::AddToTracedValue(const gfx::PointF& pt, - base::debug::TracedValue* res) { - res->AppendDouble(pt.x()); - res->AppendDouble(pt.y()); -} - -void MathUtil::AddToTracedValue(const gfx::Point3F& pt, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Point3F& pt) { + scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendDouble(pt.x()); res->AppendDouble(pt.y()); res->AppendDouble(pt.z()); + return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::Vector2d& v, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Vector2d& v) { + scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendInteger(v.x()); res->AppendInteger(v.y()); + return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::QuadF& q, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::QuadF& q) { + scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendDouble(q.p1().x()); res->AppendDouble(q.p1().y()); res->AppendDouble(q.p2().x()); @@ -634,41 +616,47 @@ void MathUtil::AddToTracedValue(const gfx::QuadF& q, res->AppendDouble(q.p3().y()); res->AppendDouble(q.p4().x()); res->AppendDouble(q.p4().y()); + return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::RectF& rect, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::RectF& rect) { + scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendDouble(rect.x()); res->AppendDouble(rect.y()); res->AppendDouble(rect.width()); res->AppendDouble(rect.height()); + return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::Transform& transform, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Transform& transform) { + scoped_ptr<base::ListValue> res(new base::ListValue()); const SkMatrix44& m = transform.matrix(); for (int row = 0; row < 4; ++row) { for (int col = 0; col < 4; ++col) res->AppendDouble(m.getDouble(row, col)); } + return res.PassAs<base::Value>(); } -void MathUtil::AddToTracedValue(const gfx::BoxF& box, - base::debug::TracedValue* res) { +scoped_ptr<base::Value> MathUtil::AsValue(const gfx::BoxF& box) { + scoped_ptr<base::ListValue> res(new base::ListValue()); res->AppendInteger(box.x()); res->AppendInteger(box.y()); res->AppendInteger(box.z()); res->AppendInteger(box.width()); res->AppendInteger(box.height()); res->AppendInteger(box.depth()); + return res.PassAs<base::Value>(); } -double MathUtil::AsDoubleSafely(double value) { - return std::min(value, std::numeric_limits<double>::max()); +scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) { + return scoped_ptr<base::Value>(new base::FundamentalValue( + std::min(value, std::numeric_limits<double>::max()))); } -float MathUtil::AsFloatSafely(float value) { - return std::min(value, std::numeric_limits<float>::max()); +scoped_ptr<base::Value> MathUtil::AsValueSafely(float value) { + return scoped_ptr<base::Value>(new base::FundamentalValue( + std::min(value, std::numeric_limits<float>::max()))); } } // namespace cc diff --git a/cc/base/math_util.h b/cc/base/math_util.h index 4301add..3af2102 100644 --- a/cc/base/math_util.h +++ b/cc/base/math_util.h @@ -17,12 +17,7 @@ #include "ui/gfx/size.h" #include "ui/gfx/transform.h" -namespace base { -class Value; -namespace debug { -class TracedValue; -} -} +namespace base { class Value; } namespace gfx { class QuadF; @@ -179,35 +174,21 @@ class CC_EXPORT MathUtil { // Conversion to value. static scoped_ptr<base::Value> AsValue(const gfx::Size& s); + static scoped_ptr<base::Value> AsValue(const gfx::SizeF& s); static scoped_ptr<base::Value> AsValue(const gfx::Rect& r); static bool FromValue(const base::Value*, gfx::Rect* out_rect); static scoped_ptr<base::Value> AsValue(const gfx::PointF& q); - - static void AddToTracedValue(const gfx::Size& s, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::SizeF& s, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::Rect& r, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::PointF& q, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::Point3F&, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::Vector2d& v, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::QuadF& q, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::RectF& rect, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::Transform& transform, - base::debug::TracedValue* res); - static void AddToTracedValue(const gfx::BoxF& box, - base::debug::TracedValue* res); + static scoped_ptr<base::Value> AsValue(const gfx::Point3F&); + static scoped_ptr<base::Value> AsValue(const gfx::Vector2d& v); + static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q); + static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect); + static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform); + static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box); // Returns a base::Value representation of the floating point value. // If the value is inf, returns max double/float representation. - static double AsDoubleSafely(double value); - static float AsFloatSafely(float value); + static scoped_ptr<base::Value> AsValueSafely(double value); + static scoped_ptr<base::Value> AsValueSafely(float value); }; } // namespace cc diff --git a/cc/base/region.cc b/cc/base/region.cc index 79c30ec..906bc6e 100644 --- a/cc/base/region.cc +++ b/cc/base/region.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include "cc/base/region.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" namespace cc { @@ -121,16 +120,6 @@ scoped_ptr<base::Value> Region::AsValue() const { return result.PassAs<base::Value>(); } -void Region::AsValueInto(base::debug::TracedValue* result) const { - for (Iterator it(*this); it.has_rect(); it.next()) { - gfx::Rect rect(it.rect()); - result->AppendInteger(rect.x()); - result->AppendInteger(rect.y()); - result->AppendInteger(rect.width()); - result->AppendInteger(rect.height()); - } -} - Region::Iterator::Iterator() { } diff --git a/cc/base/region.h b/cc/base/region.h index 3ef32db..06fe731 100644 --- a/cc/base/region.h +++ b/cc/base/region.h @@ -16,9 +16,6 @@ namespace base { class Value; -namespace debug { -class TracedValue; -} } namespace cc { @@ -62,7 +59,6 @@ class CC_EXPORT Region { std::string ToString() const; scoped_ptr<base::Value> AsValue() const; - void AsValueInto(base::debug::TracedValue* array) const; class CC_EXPORT Iterator { public: diff --git a/cc/debug/frame_viewer_instrumentation.h b/cc/debug/frame_viewer_instrumentation.h index 7d97b52e..16cf433 100644 --- a/cc/debug/frame_viewer_instrumentation.h +++ b/cc/debug/frame_viewer_instrumentation.h @@ -23,18 +23,17 @@ const char kRasterMode[] = "rasterMode"; const char kAnalyzeTask[] = "AnalyzeTask"; const char kRasterTask[] = "RasterTask"; -scoped_refptr<base::debug::ConvertableToTraceFormat> TileDataAsValue( - const void* tile_id, - TileResolution tile_resolution, - int source_frame_number, - int layer_id) { - scoped_refptr<base::debug::TracedValue> res(new base::debug::TracedValue()); - TracedValue::SetIDRef(tile_id, res, internal::kTileId); - res->SetString(internal::kTileResolution, - TileResolutionToString(tile_resolution)); +scoped_ptr<base::Value> TileDataAsValue(const void* tile_id, + TileResolution tile_resolution, + int source_frame_number, + int layer_id) { + scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue); + res->Set(internal::kTileId, TracedValue::CreateIDRef(tile_id).release()); + res->Set(internal::kTileResolution, + TileResolutionAsValue(tile_resolution).release()); res->SetInteger(internal::kSourceFrameNumber, source_frame_number); res->SetInteger(internal::kLayerId, layer_id); - return res; + return res.PassAs<base::Value>(); } } // namespace internal @@ -49,8 +48,10 @@ class ScopedAnalyzeTask { internal::kCategory, internal::kAnalyzeTask, internal::kTileData, - internal::TileDataAsValue( - tile_id, tile_resolution, source_frame_number, layer_id)); + TracedValue::FromValue(internal::TileDataAsValue(tile_id, + tile_resolution, + source_frame_number, + layer_id).release())); } ~ScopedAnalyzeTask() { TRACE_EVENT_END0(internal::kCategory, internal::kAnalyzeTask); @@ -71,10 +72,12 @@ class ScopedRasterTask { internal::kCategory, internal::kRasterTask, internal::kTileData, - internal::TileDataAsValue( - tile_id, tile_resolution, source_frame_number, layer_id), + TracedValue::FromValue(internal::TileDataAsValue(tile_id, + tile_resolution, + source_frame_number, + layer_id).release()), internal::kRasterMode, - RasterModeToString(raster_mode)); + TracedValue::FromValue(RasterModeAsValue(raster_mode).release())); } ~ScopedRasterTask() { TRACE_EVENT_END0(internal::kCategory, internal::kRasterTask); diff --git a/cc/debug/rendering_stats.cc b/cc/debug/rendering_stats.cc index b5989fc..47bc7c7 100644 --- a/cc/debug/rendering_stats.cc +++ b/cc/debug/rendering_stats.cc @@ -16,12 +16,14 @@ void RenderingStats::TimeDeltaList::Append(base::TimeDelta value) { values.push_back(value); } -void RenderingStats::TimeDeltaList::AddToTracedValue( - base::debug::TracedValue* list_value) const { +scoped_ptr<base::ListValue> +RenderingStats::TimeDeltaList::AsListValueInMilliseconds() const { + scoped_ptr<base::ListValue> list_value(new base::ListValue); std::list<base::TimeDelta>::const_iterator iter; for (iter = values.begin(); iter != values.end(); ++iter) { list_value->AppendDouble(iter->InMillisecondsF()); } + return list_value.Pass(); } void RenderingStats::TimeDeltaList::Add(const TimeDeltaList& other) { @@ -37,14 +39,13 @@ RenderingStats::MainThreadRenderingStats::~MainThreadRenderingStats() { scoped_refptr<base::debug::ConvertableToTraceFormat> RenderingStats::MainThreadRenderingStats::AsTraceableData() const { - scoped_refptr<base::debug::TracedValue> record_data = - new base::debug::TracedValue(); + scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); record_data->SetInteger("frame_count", frame_count); record_data->SetDouble("paint_time", paint_time.InSecondsF()); record_data->SetInteger("painted_pixel_count", painted_pixel_count); record_data->SetDouble("record_time", record_time.InSecondsF()); record_data->SetInteger("recorded_pixel_count", recorded_pixel_count); - return record_data; + return TracedValue::FromValue(record_data.release()); } void RenderingStats::MainThreadRenderingStats::Add( @@ -68,39 +69,34 @@ RenderingStats::ImplThreadRenderingStats::~ImplThreadRenderingStats() { scoped_refptr<base::debug::ConvertableToTraceFormat> RenderingStats::ImplThreadRenderingStats::AsTraceableData() const { - scoped_refptr<base::debug::TracedValue> record_data = - new base::debug::TracedValue(); + scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); record_data->SetInteger("frame_count", frame_count); record_data->SetDouble("rasterize_time", rasterize_time.InSecondsF()); record_data->SetInteger("rasterized_pixel_count", rasterized_pixel_count); record_data->SetInteger("visible_content_area", visible_content_area); record_data->SetInteger("approximated_visible_content_area", approximated_visible_content_area); - record_data->BeginArray("draw_duration_ms"); - draw_duration.AddToTracedValue(record_data.get()); - record_data->EndArray(); - - record_data->BeginArray("draw_duration_estimate_ms"); - draw_duration_estimate.AddToTracedValue(record_data.get()); - record_data->EndArray(); - - record_data->BeginArray("begin_main_frame_to_commit_duration_ms"); - begin_main_frame_to_commit_duration.AddToTracedValue(record_data.get()); - record_data->EndArray(); - - record_data->BeginArray("begin_main_frame_to_commit_duration_estimate_ms"); - begin_main_frame_to_commit_duration_estimate.AddToTracedValue( - record_data.get()); - record_data->EndArray(); - - record_data->BeginArray("commit_to_activate_duration_ms"); - commit_to_activate_duration.AddToTracedValue(record_data.get()); - record_data->EndArray(); - - record_data->BeginArray("commit_to_activate_duration_estimate_ms"); - commit_to_activate_duration_estimate.AddToTracedValue(record_data.get()); - record_data->EndArray(); - return record_data; + record_data->Set("draw_duration_ms", + draw_duration.AsListValueInMilliseconds().release()); + record_data->Set( + "draw_duration_estimate_ms", + draw_duration_estimate.AsListValueInMilliseconds().release()); + record_data->Set( + "begin_main_frame_to_commit_duration_ms", + begin_main_frame_to_commit_duration.AsListValueInMilliseconds() + .release()); + record_data->Set( + "begin_main_frame_to_commit_duration_estimate_ms", + begin_main_frame_to_commit_duration_estimate.AsListValueInMilliseconds() + .release()); + record_data->Set( + "commit_to_activate_duration_ms", + commit_to_activate_duration.AsListValueInMilliseconds().release()); + record_data->Set( + "commit_to_activate_duration_estimate_ms", + commit_to_activate_duration_estimate.AsListValueInMilliseconds() + .release()); + return TracedValue::FromValue(record_data.release()); } void RenderingStats::ImplThreadRenderingStats::Add( diff --git a/cc/debug/rendering_stats.h b/cc/debug/rendering_stats.h index 73ca9c4..a6edff1 100644 --- a/cc/debug/rendering_stats.h +++ b/cc/debug/rendering_stats.h @@ -8,7 +8,6 @@ #include <list> #include "base/basictypes.h" -#include "base/debug/trace_event_argument.h" #include "base/time/time.h" #include "base/values.h" #include "cc/base/cc_export.h" @@ -24,8 +23,7 @@ struct CC_EXPORT RenderingStats { ~TimeDeltaList(); void Append(base::TimeDelta value); - void AddToTracedValue(base::debug::TracedValue* list_value) const; - + scoped_ptr<base::ListValue> AsListValueInMilliseconds() const; void Add(const TimeDeltaList& other); private: diff --git a/cc/debug/rendering_stats_unittest.cc b/cc/debug/rendering_stats_unittest.cc index a634093..ea0276c 100644 --- a/cc/debug/rendering_stats_unittest.cc +++ b/cc/debug/rendering_stats_unittest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> - #include "base/time/time.h" #include "base/values.h" #include "cc/debug/rendering_stats.h" @@ -12,18 +10,20 @@ namespace cc { namespace { -static std::string ToString(const RenderingStats::TimeDeltaList& list) { - scoped_refptr<base::debug::TracedValue> value = - new base::debug::TracedValue(); - value->BeginArray("list_value"); - list.AddToTracedValue(value.get()); - value->EndArray(); - return value->ToString(); +void CompareDoubleValue(const base::ListValue& list_value, + int index, + double expected_value) { + double value; + EXPECT_TRUE(list_value.GetDouble(index, &value)); + EXPECT_EQ(expected_value, value); } TEST(RenderingStatsTest, TimeDeltaListEmpty) { RenderingStats::TimeDeltaList time_delta_list; - EXPECT_EQ("{\"list_value\":[]}", ToString(time_delta_list)); + scoped_ptr<base::ListValue> list_value = + time_delta_list.AsListValueInMilliseconds(); + EXPECT_TRUE(list_value->empty()); + EXPECT_EQ(0ul, list_value->GetSize()); } TEST(RenderingStatsTest, TimeDeltaListNonEmpty) { @@ -31,7 +31,13 @@ TEST(RenderingStatsTest, TimeDeltaListNonEmpty) { time_delta_list.Append(base::TimeDelta::FromMilliseconds(234)); time_delta_list.Append(base::TimeDelta::FromMilliseconds(827)); - EXPECT_EQ("{\"list_value\":[234.0,827.0]}", ToString(time_delta_list)); + scoped_ptr<base::ListValue> list_value = + time_delta_list.AsListValueInMilliseconds(); + EXPECT_FALSE(list_value->empty()); + EXPECT_EQ(2ul, list_value->GetSize()); + + CompareDoubleValue(*list_value.get(), 0, 234); + CompareDoubleValue(*list_value.get(), 1, 827); } TEST(RenderingStatsTest, TimeDeltaListAdd) { @@ -45,8 +51,16 @@ TEST(RenderingStatsTest, TimeDeltaListAdd) { time_delta_list_b.Append(base::TimeDelta::FromMilliseconds(2)); time_delta_list_a.Add(time_delta_list_b); - EXPECT_EQ("{\"list_value\":[810.0,32.0,43.0,938.0,2.0]}", - ToString(time_delta_list_a)); + scoped_ptr<base::ListValue> list_value = + time_delta_list_a.AsListValueInMilliseconds(); + EXPECT_FALSE(list_value->empty()); + EXPECT_EQ(5ul, list_value->GetSize()); + + CompareDoubleValue(*list_value.get(), 0, 810); + CompareDoubleValue(*list_value.get(), 1, 32); + CompareDoubleValue(*list_value.get(), 2, 43); + CompareDoubleValue(*list_value.get(), 3, 938); + CompareDoubleValue(*list_value.get(), 4, 2); } } // namespace diff --git a/cc/debug/traced_picture.cc b/cc/debug/traced_picture.cc index 2db5492..89d988f 100644 --- a/cc/debug/traced_picture.cc +++ b/cc/debug/traced_picture.cc @@ -7,6 +7,7 @@ #include "base/json/json_writer.h" #include "base/strings/stringprintf.h" #include "base/values.h" +#include "cc/debug/traced_value.h" namespace cc { diff --git a/cc/debug/traced_value.cc b/cc/debug/traced_value.cc index 5828cb8..3b506ae 100644 --- a/cc/debug/traced_value.cc +++ b/cc/debug/traced_value.cc @@ -4,34 +4,26 @@ #include "cc/debug/traced_value.h" -#include "base/debug/trace_event_argument.h" +#include "base/json/json_writer.h" #include "base/strings/stringprintf.h" +#include "base/values.h" namespace cc { -void TracedValue::AppendIDRef(const void* id, base::debug::TracedValue* state) { - state->BeginDictionary(); - state->SetString("id_ref", base::StringPrintf("%p", id)); - state->EndDictionary(); +scoped_ptr<base::Value> TracedValue::CreateIDRef(const void* id) { + scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); + res->SetString("id_ref", base::StringPrintf("%p", id)); + return res.PassAs<base::Value>(); } -void TracedValue::SetIDRef(const void* id, - base::debug::TracedValue* state, - const char* name) { - state->BeginDictionary(name); - state->SetString("id_ref", base::StringPrintf("%p", id)); - state->EndDictionary(); -} - -void TracedValue::MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict, - const char* object_name, - const void* id) { +void TracedValue::MakeDictIntoImplicitSnapshot( + base::DictionaryValue* dict, const char* object_name, const void* id) { dict->SetString("id", base::StringPrintf("%s/%p", object_name, id)); } void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::debug::TracedValue* dict, + base::DictionaryValue* dict, const char* object_name, const void* id) { dict->SetString("cat", category); @@ -40,7 +32,7 @@ void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::debug::TracedValue* dict, + base::DictionaryValue* dict, const char* object_base_type_name, const char* object_name, const void* id) { @@ -49,4 +41,23 @@ void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( MakeDictIntoImplicitSnapshot(dict, object_name, id); } +scoped_refptr<base::debug::ConvertableToTraceFormat> TracedValue::FromValue( + base::Value* value) { + return scoped_refptr<base::debug::ConvertableToTraceFormat>( + new TracedValue(value)); +} + +TracedValue::TracedValue(base::Value* value) + : value_(value) { +} + +TracedValue::~TracedValue() { +} + +void TracedValue::AppendAsTraceFormat(std::string* out) const { + std::string tmp; + base::JSONWriter::Write(value_.get(), &tmp); + *out += tmp; +} + } // namespace cc diff --git a/cc/debug/traced_value.h b/cc/debug/traced_value.h index c5ea30a..560eaf8 100644 --- a/cc/debug/traced_value.h +++ b/cc/debug/traced_value.h @@ -5,36 +5,58 @@ #ifndef CC_DEBUG_TRACED_VALUE_H_ #define CC_DEBUG_TRACED_VALUE_H_ +#include <string> + +#include "base/debug/trace_event.h" +#include "base/memory/scoped_ptr.h" + namespace base { -namespace debug { -class TracedValue; -} +class DictionaryValue; +class Value; } - namespace cc { -class TracedValue { +class TracedValue : public base::debug::ConvertableToTraceFormat { public: - static void AppendIDRef(const void* id, base::debug::TracedValue* array); - static void SetIDRef(const void* id, - base::debug::TracedValue* dict, - const char* name); - static void MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict, - const char* object_name, - const void* id); + static scoped_ptr<base::Value> CreateIDRef(const void* id); + static void MakeDictIntoImplicitSnapshot( + base::DictionaryValue* dict, const char* object_name, const void* id); static void MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::debug::TracedValue* dict, + base::DictionaryValue* dict, const char* object_name, const void* id); static void MakeDictIntoImplicitSnapshotWithCategory( const char* category, - base::debug::TracedValue* dict, + base::DictionaryValue* dict, const char* object_base_type_name, const char* object_name, const void* id); + static scoped_refptr<base::debug::ConvertableToTraceFormat> FromValue( + 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); }; +template <class T> +static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace(T* t) { + return TracedValue::FromValue(t->AsValue().release()); +} + +template <class T> +static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace( + const T& t) { + return ToTrace(&t); +} + } // namespace cc #endif // CC_DEBUG_TRACED_VALUE_H_ diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 0ccd4ed..c031bd4 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -7,12 +7,11 @@ #include <algorithm> #include <vector> -#include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/strings/stringprintf.h" #include "cc/debug/debug_colors.h" #include "cc/debug/frame_rate_counter.h" #include "cc/debug/paint_time_counter.h" +#include "cc/debug/traced_value.h" #include "cc/output/renderer.h" #include "cc/quads/texture_draw_quad.h" #include "cc/resources/memory_history.h" @@ -762,8 +761,7 @@ const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { return "cc::HeadsUpDisplayLayerImpl"; } -void HeadsUpDisplayLayerImpl::AsValueInto( - base::debug::TracedValue* dict) const { +void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { LayerImpl::AsValueInto(dict); dict->SetString("layer_name", "Heads Up Display Layer"); } diff --git a/cc/layers/heads_up_display_layer_impl.h b/cc/layers/heads_up_display_layer_impl.h index 8ee386c..b5fa355 100644 --- a/cc/layers/heads_up_display_layer_impl.h +++ b/cc/layers/heads_up_display_layer_impl.h @@ -72,7 +72,7 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { virtual const char* LayerTypeAsString() const OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; + virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; void UpdateHudContents(); void DrawHudContents(SkCanvas* canvas); diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index bd9a2d7..7a23e66 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -5,7 +5,6 @@ #include "cc/layers/layer_impl.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/json/json_reader.h" #include "base/strings/stringprintf.h" #include "cc/animation/animation_registrar.h" @@ -1391,7 +1390,7 @@ void LayerImpl::RemoveDependentNeedsPushProperties() { parent_->RemoveDependentNeedsPushProperties(); } -void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { +void LayerImpl::AsValueInto(base::DictionaryValue* state) const { TracedValue::MakeDictIntoImplicitSnapshotWithCategory( TRACE_DISABLED_BY_DEFAULT("cc.debug"), state, @@ -1399,75 +1398,50 @@ void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { LayerTypeAsString(), this); state->SetInteger("layer_id", id()); - state->BeginDictionary("bounds"); - MathUtil::AddToTracedValue(bounds_, state); - state->EndDictionary(); - - state->BeginArray("position"); - MathUtil::AddToTracedValue(position_, state); - state->EndArray(); - + state->Set("bounds", MathUtil::AsValue(bounds_).release()); + state->Set("position", MathUtil::AsValue(position_).release()); state->SetInteger("draws_content", DrawsContent()); state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); - - state->BeginArray("scroll_offset"); - MathUtil::AddToTracedValue(scroll_offset_, state); - state->EndArray(); - - state->BeginArray("transform_origin"); - MathUtil::AddToTracedValue(transform_origin_, state); - state->EndArray(); + state->Set("scroll_offset", MathUtil::AsValue(scroll_offset_).release()); + state->Set("transform_origin", + MathUtil::AsValue(transform_origin_).release()); bool clipped; gfx::QuadF layer_quad = MathUtil::MapQuad( screen_space_transform(), gfx::QuadF(gfx::Rect(content_bounds())), &clipped); - state->BeginArray("layer_quad"); - MathUtil::AddToTracedValue(layer_quad, state); - state->EndArray(); + state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); + if (!touch_event_handler_region_.IsEmpty()) { - state->BeginArray("touch_event_handler_region"); - touch_event_handler_region_.AsValueInto(state); - state->EndArray(); + state->Set("touch_event_handler_region", + touch_event_handler_region_.AsValue().release()); } if (have_wheel_event_handlers_) { gfx::Rect wheel_rect(content_bounds()); Region wheel_region(wheel_rect); - state->BeginArray("wheel_event_handler_region"); - wheel_region.AsValueInto(state); - state->EndArray(); + state->Set("wheel_event_handler_region", + wheel_region.AsValue().release()); } if (have_scroll_event_handlers_) { gfx::Rect scroll_rect(content_bounds()); Region scroll_region(scroll_rect); - state->BeginArray("scroll_event_handler_region"); - scroll_region.AsValueInto(state); - state->EndArray(); + state->Set("scroll_event_handler_region", + scroll_region.AsValue().release()); } if (!non_fast_scrollable_region_.IsEmpty()) { - state->BeginArray("non_fast_scrollable_region"); - non_fast_scrollable_region_.AsValueInto(state); - state->EndArray(); + state->Set("non_fast_scrollable_region", + non_fast_scrollable_region_.AsValue().release()); } - state->BeginArray("children"); - for (size_t i = 0; i < children_.size(); ++i) { - state->BeginDictionary(); - children_[i]->AsValueInto(state); - state->EndDictionary(); - } - state->EndArray(); - if (mask_layer_) { - state->BeginDictionary("mask_layer"); - mask_layer_->AsValueInto(state); - state->EndDictionary(); - } - if (replica_layer_) { - state->BeginDictionary("replica_layer"); - replica_layer_->AsValueInto(state); - state->EndDictionary(); - } + scoped_ptr<base::ListValue> children_list(new base::ListValue()); + for (size_t i = 0; i < children_.size(); ++i) + children_list->Append(children_[i]->AsValue().release()); + state->Set("children", children_list.release()); + if (mask_layer_) + state->Set("mask_layer", mask_layer_->AsValue().release()); + if (replica_layer_) + state->Set("replica_layer", replica_layer_->AsValue().release()); if (scroll_parent_) state->SetInteger("scroll_parent", scroll_parent_->id()); @@ -1483,11 +1457,8 @@ void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { layer_animation_controller()->HasAnimationThatInflatesBounds()); gfx::BoxF box; - if (LayerUtils::GetAnimationBounds(*this, &box)) { - state->BeginArray("animation_bounds"); - MathUtil::AddToTracedValue(box, state); - state->EndArray(); - } + if (LayerUtils::GetAnimationBounds(*this, &box)) + state->Set("animation_bounds", MathUtil::AsValue(box).release()); if (debug_info_.get()) { std::string str; @@ -1500,10 +1471,7 @@ void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { bool converted_to_dictionary = debug_info_value->GetAsDictionary(&dictionary_value); DCHECK(converted_to_dictionary); - for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd(); - it.Advance()) { - state->SetValue(it.key().data(), it.value().DeepCopy()); - } + state->MergeDictionary(dictionary_value); } else { NOTREACHED(); } @@ -1517,6 +1485,12 @@ bool LayerImpl::IsDrawnRenderSurfaceLayerListMember() const { size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } +scoped_ptr<base::Value> LayerImpl::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + AsValueInto(state.get()); + return state.PassAs<base::Value>(); +} + void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { benchmark->RunOnLayer(this); } diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index c1ce9df..979d2e0 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -39,7 +39,6 @@ namespace base { namespace debug { class ConvertableToTraceFormat; -class TracedValue; } class DictionaryValue; @@ -522,8 +521,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); virtual void PushPropertiesTo(LayerImpl* layer); - virtual void AsValueInto(base::debug::TracedValue* dict) const; - + scoped_ptr<base::Value> AsValue() const; virtual size_t GPUMemoryUsageInBytes() const; void SetNeedsPushProperties(); @@ -565,6 +563,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, SkColor color, float width) const; + virtual void AsValueInto(base::DictionaryValue* dict) const; + void NoteLayerPropertyChanged(); void NoteLayerPropertyChangedForSubtree(); diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index c22b082..7bd66cd9 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -7,7 +7,6 @@ #include <algorithm> #include <limits> -#include "base/debug/trace_event_argument.h" #include "base/time/time.h" #include "cc/base/math_util.h" #include "cc/base/util.h" @@ -1336,42 +1335,31 @@ void PictureLayerImpl::GetDebugBorderProperties( *width = DebugColors::TiledContentLayerBorderWidth(layer_tree_impl()); } -void PictureLayerImpl::AsValueInto(base::debug::TracedValue* state) const { +void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { const_cast<PictureLayerImpl*>(this)->DoPostCommitInitializationIfNeeded(); LayerImpl::AsValueInto(state); state->SetDouble("ideal_contents_scale", ideal_contents_scale_); state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); - state->BeginArray("tilings"); - tilings_->AsValueInto(state); - state->EndArray(); + state->Set("tilings", tilings_->AsValue().release()); + state->Set("pictures", pile_->AsValue().release()); + state->Set("invalidation", invalidation_.AsValue().release()); - state->BeginArray("pictures"); - pile_->AsValueInto(state); - state->EndArray(); - - state->BeginArray("invalidation"); - invalidation_.AsValueInto(state); - state->EndArray(); - - state->BeginArray("coverage_tiles"); + scoped_ptr<base::ListValue> coverage_tiles(new base::ListValue); for (PictureLayerTilingSet::CoverageIterator iter(tilings_.get(), contents_scale_x(), gfx::Rect(content_bounds()), ideal_contents_scale_); iter; ++iter) { - state->BeginDictionary(); - - state->BeginArray("geometry_rect"); - MathUtil::AddToTracedValue(iter.geometry_rect(), state); - state->EndArray(); - + scoped_ptr<base::DictionaryValue> tile_data(new base::DictionaryValue); + tile_data->Set("geometry_rect", + MathUtil::AsValue(iter.geometry_rect()).release()); if (*iter) - TracedValue::SetIDRef(*iter, state, "tile"); + tile_data->Set("tile", TracedValue::CreateIDRef(*iter).release()); - state->EndDictionary(); + coverage_tiles->Append(tile_data.release()); } - state->EndArray(); + state->Set("coverage_tiles", coverage_tiles.release()); } size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h index 7309070..3a21ca1 100644 --- a/cc/layers/picture_layer_impl.h +++ b/cc/layers/picture_layer_impl.h @@ -180,7 +180,7 @@ class CC_EXPORT PictureLayerImpl virtual void GetDebugBorderProperties( SkColor* color, float* width) const OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; + virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; virtual void UpdateIdealScales(); float MaximumTilingContentsScale() const; diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc index fb0d2a9..80c6da0 100644 --- a/cc/layers/surface_layer_impl.cc +++ b/cc/layers/surface_layer_impl.cc @@ -4,7 +4,6 @@ #include "cc/layers/surface_layer_impl.h" -#include "base/debug/trace_event_argument.h" #include "cc/debug/debug_colors.h" #include "cc/quads/surface_draw_quad.h" #include "cc/trees/occlusion_tracker.h" @@ -67,7 +66,7 @@ void SurfaceLayerImpl::GetDebugBorderProperties(SkColor* color, *width = DebugColors::SurfaceLayerBorderWidth(layer_tree_impl()); } -void SurfaceLayerImpl::AsValueInto(base::debug::TracedValue* dict) const { +void SurfaceLayerImpl::AsValueInto(base::DictionaryValue* dict) const { LayerImpl::AsValueInto(dict); dict->SetInteger("surface_id", surface_id_.id); } diff --git a/cc/layers/surface_layer_impl.h b/cc/layers/surface_layer_impl.h index 712ea14..65120aa 100644 --- a/cc/layers/surface_layer_impl.h +++ b/cc/layers/surface_layer_impl.h @@ -35,7 +35,7 @@ class CC_EXPORT SurfaceLayerImpl : public LayerImpl { private: virtual void GetDebugBorderProperties(SkColor* color, float* width) const OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; + virtual void AsValueInto(base::DictionaryValue* dict) const OVERRIDE; virtual const char* LayerTypeAsString() const OVERRIDE; SurfaceId surface_id_; diff --git a/cc/layers/tiled_layer_impl.cc b/cc/layers/tiled_layer_impl.cc index 86f90b9..5b932ca 100644 --- a/cc/layers/tiled_layer_impl.cc +++ b/cc/layers/tiled_layer_impl.cc @@ -5,7 +5,6 @@ #include "cc/layers/tiled_layer_impl.h" #include "base/basictypes.h" -#include "base/debug/trace_event_argument.h" #include "base/strings/stringprintf.h" #include "cc/base/math_util.h" #include "cc/debug/debug_colors.h" @@ -100,11 +99,9 @@ scoped_ptr<LayerImpl> TiledLayerImpl::CreateLayerImpl( return TiledLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); } -void TiledLayerImpl::AsValueInto(base::debug::TracedValue* state) const { +void TiledLayerImpl::AsValueInto(base::DictionaryValue* state) const { LayerImpl::AsValueInto(state); - state->BeginArray("invalidation"); - MathUtil::AddToTracedValue(update_rect(), state); - state->EndArray(); + state->Set("invalidation", MathUtil::AsValue(update_rect()).release()); } size_t TiledLayerImpl::GPUMemoryUsageInBytes() const { diff --git a/cc/layers/tiled_layer_impl.h b/cc/layers/tiled_layer_impl.h index e3d38a0..7fc4347 100644 --- a/cc/layers/tiled_layer_impl.h +++ b/cc/layers/tiled_layer_impl.h @@ -58,7 +58,7 @@ class CC_EXPORT TiledLayerImpl : public LayerImpl { virtual void GetDebugBorderProperties(SkColor* color, float* width) const OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; + virtual void AsValueInto(base::DictionaryValue* state) const OVERRIDE; private: virtual const char* LayerTypeAsString() const OVERRIDE; diff --git a/cc/output/begin_frame_args.cc b/cc/output/begin_frame_args.cc index b45eee8..4d1b270 100644 --- a/cc/output/begin_frame_args.cc +++ b/cc/output/begin_frame_args.cc @@ -3,8 +3,6 @@ // found in the LICENSE file. #include "cc/output/begin_frame_args.h" - -#include "base/debug/trace_event_argument.h" #include "ui/gfx/frame_time.h" namespace cc { @@ -29,19 +27,13 @@ BeginFrameArgs BeginFrameArgs::Create(base::TimeTicks frame_time, return BeginFrameArgs(frame_time, deadline, interval); } -scoped_refptr<base::debug::ConvertableToTraceFormat> BeginFrameArgs::AsValue() - const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); - AsValueInto(state.get()); - return state; -} - -void BeginFrameArgs::AsValueInto(base::debug::TracedValue* state) const { +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>(); } BeginFrameArgs BeginFrameArgs::CreateForSynchronousCompositor( diff --git a/cc/output/begin_frame_args.h b/cc/output/begin_frame_args.h index b23a81e..91ad182 100644 --- a/cc/output/begin_frame_args.h +++ b/cc/output/begin_frame_args.h @@ -5,18 +5,10 @@ #ifndef CC_OUTPUT_BEGIN_FRAME_ARGS_H_ #define CC_OUTPUT_BEGIN_FRAME_ARGS_H_ -#include "base/memory/ref_counted.h" #include "base/time/time.h" #include "base/values.h" #include "cc/base/cc_export.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -class TracedValue; -} -} - namespace cc { struct CC_EXPORT BeginFrameArgs { @@ -47,8 +39,7 @@ struct CC_EXPORT BeginFrameArgs { bool IsValid() const { return interval >= base::TimeDelta(); } - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; base::TimeTicks frame_time; base::TimeTicks deadline; diff --git a/cc/output/filter_operation.cc b/cc/output/filter_operation.cc index 173985b..096f6ba 100644 --- a/cc/output/filter_operation.cc +++ b/cc/output/filter_operation.cc @@ -4,7 +4,6 @@ #include <algorithm> -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/output/filter_operation.h" @@ -255,7 +254,8 @@ FilterOperation FilterOperation::Blend(const FilterOperation* from, return blended_filter; } -void FilterOperation::AsValueInto(base::debug::TracedValue* value) const { +scoped_ptr<base::Value> FilterOperation::AsValue() const { + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue); value->SetInteger("type", type_); switch (type_) { case FilterOperation::GRAYSCALE: @@ -272,16 +272,14 @@ void FilterOperation::AsValueInto(base::debug::TracedValue* value) const { break; case FilterOperation::DROP_SHADOW: value->SetDouble("std_deviation", amount_); - value->BeginArray("offset"); - MathUtil::AddToTracedValue(drop_shadow_offset_, value); - value->EndArray(); + value->Set("offset", MathUtil::AsValue(drop_shadow_offset_).release()); value->SetInteger("color", drop_shadow_color_); break; case FilterOperation::COLOR_MATRIX: { - value->BeginArray("matrix"); + scoped_ptr<base::ListValue> matrix(new base::ListValue); for (size_t i = 0; i < arraysize(matrix_); ++i) - value->AppendDouble(matrix_[i]); - value->EndArray(); + matrix->AppendDouble(matrix_[i]); + value->Set("matrix", matrix.release()); break; } case FilterOperation::ZOOM: @@ -304,17 +302,17 @@ void FilterOperation::AsValueInto(base::debug::TracedValue* value) const { value->SetDouble("inner_threshold", amount_); value->SetDouble("outer_threshold", outer_threshold_); scoped_ptr<base::ListValue> region_value(new base::ListValue()); - value->BeginArray("region"); for (SkRegion::Iterator it(region_); !it.done(); it.next()) { - value->AppendInteger(it.rect().x()); - value->AppendInteger(it.rect().y()); - value->AppendInteger(it.rect().width()); - value->AppendInteger(it.rect().height()); + region_value->AppendInteger(it.rect().x()); + region_value->AppendInteger(it.rect().y()); + region_value->AppendInteger(it.rect().width()); + region_value->AppendInteger(it.rect().height()); } - value->EndArray(); + value->Set("region", region_value.release()); } break; } + return value.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/output/filter_operation.h b/cc/output/filter_operation.h index fc14cb1..cfaf529 100644 --- a/cc/output/filter_operation.h +++ b/cc/output/filter_operation.h @@ -16,9 +16,6 @@ #include "ui/gfx/geometry/point.h" namespace base { -namespace debug { -class TracedValue; -} class Value; } @@ -223,7 +220,7 @@ class CC_EXPORT FilterOperation { const FilterOperation* to, double progress); - void AsValueInto(base::debug::TracedValue* value) const; + scoped_ptr<base::Value> AsValue() const; private: FilterOperation(FilterType type, float amount); diff --git a/cc/output/filter_operations.cc b/cc/output/filter_operations.cc index dcdd480..443d7ec 100644 --- a/cc/output/filter_operations.cc +++ b/cc/output/filter_operations.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "cc/output/filter_operations.h" - #include <cmath> -#include "base/debug/trace_event_argument.h" +#include "cc/output/filter_operations.h" + #include "base/values.h" #include "cc/output/filter_operation.h" @@ -197,12 +196,11 @@ FilterOperations FilterOperations::Blend(const FilterOperations& from, return blended_filters; } -void FilterOperations::AsValueInto(base::debug::TracedValue* value) const { - for (size_t i = 0; i < operations_.size(); ++i) { - value->BeginDictionary(); - operations_[i].AsValueInto(value); - value->EndDictionary(); - } +scoped_ptr<base::Value> FilterOperations::AsValue() const { + scoped_ptr<base::ListValue> value(new base::ListValue); + for (size_t i = 0; i < operations_.size(); ++i) + value->Append(operations_[i].AsValue().release()); + return value.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/output/filter_operations.h b/cc/output/filter_operations.h index a8c206e..66f5865 100644 --- a/cc/output/filter_operations.h +++ b/cc/output/filter_operations.h @@ -12,9 +12,6 @@ #include "cc/output/filter_operation.h" namespace base { -namespace debug { -class TracedValue; -} class Value; } @@ -70,7 +67,8 @@ class CC_EXPORT FilterOperations { // a copy of this. FilterOperations Blend(const FilterOperations& from, double progress) const; - void AsValueInto(base::debug::TracedValue* value) const; + + scoped_ptr<base::Value> AsValue() const; private: std::vector<FilterOperation> operations_; diff --git a/cc/quads/checkerboard_draw_quad.cc b/cc/quads/checkerboard_draw_quad.cc index 1451766..b6c5f82 100644 --- a/cc/quads/checkerboard_draw_quad.cc +++ b/cc/quads/checkerboard_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/checkerboard_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" @@ -43,7 +42,7 @@ const CheckerboardDrawQuad* CheckerboardDrawQuad::MaterialCast( return static_cast<const CheckerboardDrawQuad*>(quad); } -void CheckerboardDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void CheckerboardDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("color", color); } diff --git a/cc/quads/checkerboard_draw_quad.h b/cc/quads/checkerboard_draw_quad.h index f99531d..ffbf698 100644 --- a/cc/quads/checkerboard_draw_quad.h +++ b/cc/quads/checkerboard_draw_quad.h @@ -36,7 +36,7 @@ class CC_EXPORT CheckerboardDrawQuad : public DrawQuad { static const CheckerboardDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/content_draw_quad_base.cc b/cc/quads/content_draw_quad_base.cc index fd6e91b..18d3d10 100644 --- a/cc/quads/content_draw_quad_base.cc +++ b/cc/quads/content_draw_quad_base.cc @@ -4,7 +4,6 @@ #include "cc/quads/content_draw_quad_base.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -50,15 +49,9 @@ void ContentDrawQuadBase::SetAll(const SharedQuadState* shared_quad_state, this->swizzle_contents = swizzle_contents; } -void ContentDrawQuadBase::ExtendValue(base::debug::TracedValue* value) const { - value->BeginArray("tex_coord_rect"); - MathUtil::AddToTracedValue(tex_coord_rect, value); - value->EndArray(); - - value->BeginDictionary("texture_size"); - MathUtil::AddToTracedValue(texture_size, value); - value->EndDictionary(); - +void ContentDrawQuadBase::ExtendValue(base::DictionaryValue* value) const { + value->Set("tex_coord_rect", MathUtil::AsValue(tex_coord_rect).release()); + value->Set("texture_size", MathUtil::AsValue(texture_size).release()); value->SetBoolean("swizzle_contents", swizzle_contents); } diff --git a/cc/quads/content_draw_quad_base.h b/cc/quads/content_draw_quad_base.h index 5173d6c..a286e10 100644 --- a/cc/quads/content_draw_quad_base.h +++ b/cc/quads/content_draw_quad_base.h @@ -42,7 +42,7 @@ class CC_EXPORT ContentDrawQuadBase : public DrawQuad { protected: ContentDrawQuadBase(); virtual ~ContentDrawQuadBase(); - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/debug_border_draw_quad.cc b/cc/quads/debug_border_draw_quad.cc index c907be7..4254e02 100644 --- a/cc/quads/debug_border_draw_quad.cc +++ b/cc/quads/debug_border_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/debug_border_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" @@ -50,7 +49,7 @@ const DebugBorderDrawQuad* DebugBorderDrawQuad::MaterialCast( return static_cast<const DebugBorderDrawQuad*>(quad); } -void DebugBorderDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void DebugBorderDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("color", color); value->SetInteger("width", width); } diff --git a/cc/quads/debug_border_draw_quad.h b/cc/quads/debug_border_draw_quad.h index 828d4e0..18dd869 100644 --- a/cc/quads/debug_border_draw_quad.h +++ b/cc/quads/debug_border_draw_quad.h @@ -39,7 +39,7 @@ class CC_EXPORT DebugBorderDrawQuad : public DrawQuad { static const DebugBorderDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/draw_quad.cc b/cc/quads/draw_quad.cc index 38b24b0..b669ad7 100644 --- a/cc/quads/draw_quad.cc +++ b/cc/quads/draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -57,59 +56,48 @@ void DrawQuad::SetAll(const SharedQuadState* shared_quad_state, DrawQuad::~DrawQuad() { } -void DrawQuad::AsValueInto(base::debug::TracedValue* value) const { +scoped_ptr<base::Value> DrawQuad::AsValue() const { + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); value->SetInteger("material", material); - TracedValue::SetIDRef(shared_quad_state, value, "shared_state"); - - value->BeginArray("content_space_rect"); - MathUtil::AddToTracedValue(rect, value); - value->EndArray(); + value->Set("shared_state", + TracedValue::CreateIDRef(shared_quad_state).release()); + value->Set("content_space_rect", MathUtil::AsValue(rect).release()); bool rect_is_clipped; gfx::QuadF rect_as_target_space_quad = MathUtil::MapQuad( shared_quad_state->content_to_target_transform, gfx::QuadF(rect), &rect_is_clipped); - value->BeginArray("rect_as_target_space_quad"); - MathUtil::AddToTracedValue(rect_as_target_space_quad, value); - value->EndArray(); - + value->Set("rect_as_target_space_quad", + MathUtil::AsValue(rect_as_target_space_quad).release()); value->SetBoolean("rect_is_clipped", rect_is_clipped); - value->BeginArray("content_space_opaque_rect"); - MathUtil::AddToTracedValue(opaque_rect, value); - value->EndArray(); - + value->Set("content_space_opaque_rect", + MathUtil::AsValue(opaque_rect).release()); bool opaque_rect_is_clipped; gfx::QuadF opaque_rect_as_target_space_quad = MathUtil::MapQuad( shared_quad_state->content_to_target_transform, gfx::QuadF(opaque_rect), &opaque_rect_is_clipped); - value->BeginArray("opaque_rect_as_target_space_quad"); - MathUtil::AddToTracedValue(opaque_rect_as_target_space_quad, value); - value->EndArray(); - + value->Set("opaque_rect_as_target_space_quad", + MathUtil::AsValue(opaque_rect_as_target_space_quad).release()); value->SetBoolean("opaque_rect_is_clipped", opaque_rect_is_clipped); - value->BeginArray("content_space_visible_rect"); - MathUtil::AddToTracedValue(visible_rect, value); - value->EndArray(); - + value->Set("content_space_visible_rect", + MathUtil::AsValue(visible_rect).release()); bool visible_rect_is_clipped; gfx::QuadF visible_rect_as_target_space_quad = MathUtil::MapQuad( shared_quad_state->content_to_target_transform, gfx::QuadF(visible_rect), &visible_rect_is_clipped); - - value->BeginArray("visible_rect_as_target_space_quad"); - MathUtil::AddToTracedValue(visible_rect_as_target_space_quad, value); - value->EndArray(); - + value->Set("visible_rect_as_target_space_quad", + MathUtil::AsValue(visible_rect_as_target_space_quad).release()); value->SetBoolean("visible_rect_is_clipped", visible_rect_is_clipped); value->SetBoolean("needs_blending", needs_blending); value->SetBoolean("should_draw_with_blending", ShouldDrawWithBlending()); - ExtendValue(value); + ExtendValue(value.get()); + return value.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/quads/draw_quad.h b/cc/quads/draw_quad.h index 61ca358..07193cd 100644 --- a/cc/quads/draw_quad.h +++ b/cc/quads/draw_quad.h @@ -11,9 +11,6 @@ #include "cc/resources/resource_provider.h" namespace base { -namespace debug { -class TracedValue; -} class Value; class DictionaryValue; } @@ -126,7 +123,7 @@ class CC_EXPORT DrawQuad { return IsLeftEdge() || IsTopEdge() || IsRightEdge() || IsBottomEdge(); } - void AsValueInto(base::debug::TracedValue* value) const; + scoped_ptr<base::Value> AsValue() const; protected: DrawQuad(); @@ -137,7 +134,7 @@ class CC_EXPORT DrawQuad { const gfx::Rect& opaque_rect, const gfx::Rect& visible_rect, bool needs_blending); - virtual void ExtendValue(base::debug::TracedValue* value) const = 0; + virtual void ExtendValue(base::DictionaryValue* value) const = 0; }; } // namespace cc diff --git a/cc/quads/io_surface_draw_quad.cc b/cc/quads/io_surface_draw_quad.cc index e565a43..cc3581b 100644 --- a/cc/quads/io_surface_draw_quad.cc +++ b/cc/quads/io_surface_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/io_surface_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -57,11 +56,8 @@ const IOSurfaceDrawQuad* IOSurfaceDrawQuad::MaterialCast( return static_cast<const IOSurfaceDrawQuad*>(quad); } -void IOSurfaceDrawQuad::ExtendValue(base::debug::TracedValue* value) const { - value->BeginDictionary("io_surface_size"); - MathUtil::AddToTracedValue(io_surface_size, value); - value->EndDictionary(); - +void IOSurfaceDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("io_surface_size", MathUtil::AsValue(io_surface_size).release()); value->SetInteger("io_surface_resource_id", io_surface_resource_id); const char* orientation_string = NULL; switch (orientation) { diff --git a/cc/quads/io_surface_draw_quad.h b/cc/quads/io_surface_draw_quad.h index 86b4d52..988afeb 100644 --- a/cc/quads/io_surface_draw_quad.h +++ b/cc/quads/io_surface_draw_quad.h @@ -49,7 +49,7 @@ class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad { static const IOSurfaceDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/picture_draw_quad.cc b/cc/quads/picture_draw_quad.cc index af120a4..cb1c2c1 100644 --- a/cc/quads/picture_draw_quad.cc +++ b/cc/quads/picture_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/picture_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/resources/platform_color.h" @@ -80,11 +79,9 @@ const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast<const PictureDrawQuad*>(quad); } -void PictureDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const { ContentDrawQuadBase::ExtendValue(value); - value->BeginArray("content_rect"); - MathUtil::AddToTracedValue(content_rect, value); - value->EndArray(); + value->Set("content_rect", MathUtil::AsValue(content_rect).release()); value->SetDouble("contents_scale", contents_scale); value->SetInteger("texture_format", texture_format); // TODO(piman): picture_pile? diff --git a/cc/quads/picture_draw_quad.h b/cc/quads/picture_draw_quad.h index 4fb6b4b..944a8fb 100644 --- a/cc/quads/picture_draw_quad.h +++ b/cc/quads/picture_draw_quad.h @@ -56,7 +56,7 @@ class CC_EXPORT PictureDrawQuad : public ContentDrawQuadBase { static const PictureDrawQuad* MaterialCast(const DrawQuad* quad); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc index 43bb7cd..c7f83a3 100644 --- a/cc/quads/render_pass.cc +++ b/cc/quads/render_pass.cc @@ -4,7 +4,6 @@ #include "cc/quads/render_pass.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/debug/traced_value.h" @@ -158,39 +157,27 @@ void RenderPass::SetAll(Id id, DCHECK(shared_quad_state_list.empty()); } -void RenderPass::AsValueInto(base::debug::TracedValue* value) const { - value->BeginArray("output_rect"); - MathUtil::AddToTracedValue(output_rect, value); - value->EndArray(); - - value->BeginArray("damage_rect"); - MathUtil::AddToTracedValue(damage_rect, value); - value->EndArray(); - +scoped_ptr<base::Value> RenderPass::AsValue() const { + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); + value->Set("output_rect", MathUtil::AsValue(output_rect).release()); + value->Set("damage_rect", MathUtil::AsValue(damage_rect).release()); value->SetBoolean("has_transparent_background", has_transparent_background); value->SetInteger("copy_requests", copy_requests.size()); - - value->BeginArray("shared_quad_state_list"); + scoped_ptr<base::ListValue> shared_states_value(new base::ListValue()); for (size_t i = 0; i < shared_quad_state_list.size(); ++i) { - value->BeginDictionary(); - shared_quad_state_list[i]->AsValueInto(value); - value->EndDictionary(); + shared_states_value->Append(shared_quad_state_list[i]->AsValue().release()); } - value->EndArray(); - - value->BeginArray("quad_list"); + value->Set("shared_quad_state_list", shared_states_value.release()); + scoped_ptr<base::ListValue> quad_list_value(new base::ListValue()); for (size_t i = 0; i < quad_list.size(); ++i) { - value->BeginDictionary(); - quad_list[i]->AsValueInto(value); - value->EndDictionary(); + quad_list_value->Append(quad_list[i]->AsValue().release()); } - value->EndArray(); + value->Set("quad_list", quad_list_value.release()); TracedValue::MakeDictIntoImplicitSnapshotWithCategory( TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), - value, - "cc::RenderPass", - id.AsTracingId()); + value.get(), "cc::RenderPass", id.AsTracingId()); + return value.PassAs<base::Value>(); } SharedQuadState* RenderPass::CreateAndAppendSharedQuadState() { diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h index 8d41142..3032f05 100644 --- a/cc/quads/render_pass.h +++ b/cc/quads/render_pass.h @@ -18,9 +18,6 @@ #include "ui/gfx/transform.h" namespace base { -namespace debug { -class TracedValue; -} class Value; }; @@ -90,7 +87,7 @@ class CC_EXPORT RenderPass { const gfx::Transform& transform_to_root_target, bool has_transparent_background); - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; SharedQuadState* CreateAndAppendSharedQuadState(); template <typename DrawQuadType> diff --git a/cc/quads/render_pass_draw_quad.cc b/cc/quads/render_pass_draw_quad.cc index 380f2f6..6259fdf 100644 --- a/cc/quads/render_pass_draw_quad.cc +++ b/cc/quads/render_pass_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/render_pass_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/debug/traced_value.h" @@ -82,24 +81,16 @@ const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast( return static_cast<const RenderPassDrawQuad*>(quad); } -void RenderPassDrawQuad::ExtendValue(base::debug::TracedValue* value) const { - TracedValue::SetIDRef(render_pass_id.AsTracingId(), value, "render_pass_id"); +void RenderPassDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("render_pass_id", + TracedValue::CreateIDRef(render_pass_id.AsTracingId()).release()); value->SetBoolean("is_replica", is_replica); value->SetInteger("mask_resource_id", mask_resource_id); - value->BeginArray("contents_changed_since_last_frame"); - MathUtil::AddToTracedValue(contents_changed_since_last_frame, value); - value->EndArray(); - - value->BeginArray("mask_uv_rect"); - MathUtil::AddToTracedValue(mask_uv_rect, value); - value->EndArray(); - value->BeginDictionary("filters"); - filters.AsValueInto(value); - value->EndDictionary(); - - value->BeginDictionary("background_filters"); - background_filters.AsValueInto(value); - value->EndDictionary(); + value->Set("contents_changed_since_last_frame", + MathUtil::AsValue(contents_changed_since_last_frame).release()); + value->Set("mask_uv_rect", MathUtil::AsValue(mask_uv_rect).release()); + value->Set("filters", filters.AsValue().release()); + value->Set("background_filters", background_filters.AsValue().release()); } } // namespace cc diff --git a/cc/quads/render_pass_draw_quad.h b/cc/quads/render_pass_draw_quad.h index 7237a854..e3d6f14 100644 --- a/cc/quads/render_pass_draw_quad.h +++ b/cc/quads/render_pass_draw_quad.h @@ -63,7 +63,7 @@ class CC_EXPORT RenderPassDrawQuad : public DrawQuad { static const RenderPassDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/shared_quad_state.cc b/cc/quads/shared_quad_state.cc index 83df365..57959e3 100644 --- a/cc/quads/shared_quad_state.cc +++ b/cc/quads/shared_quad_state.cc @@ -4,7 +4,6 @@ #include "cc/quads/shared_quad_state.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/debug/traced_value.h" @@ -46,32 +45,22 @@ void SharedQuadState::SetAll(const gfx::Transform& content_to_target_transform, this->sorting_context_id = sorting_context_id; } -void SharedQuadState::AsValueInto(base::debug::TracedValue* value) const { - value->BeginArray("transform"); - MathUtil::AddToTracedValue(content_to_target_transform, value); - value->EndArray(); - - value->BeginDictionary("layer_content_bounds"); - MathUtil::AddToTracedValue(content_bounds, value); - value->EndDictionary(); - - value->BeginArray("layer_visible_content_rect"); - MathUtil::AddToTracedValue(visible_content_rect, value); - value->EndArray(); - +scoped_ptr<base::Value> SharedQuadState::AsValue() const { + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); + value->Set("transform", + MathUtil::AsValue(content_to_target_transform).release()); + value->Set("layer_content_bounds", + MathUtil::AsValue(content_bounds).release()); + value->Set("layer_visible_content_rect", + MathUtil::AsValue(visible_content_rect).release()); value->SetBoolean("is_clipped", is_clipped); - - value->BeginArray("clip_rect"); - MathUtil::AddToTracedValue(clip_rect, value); - value->EndArray(); - + value->Set("clip_rect", MathUtil::AsValue(clip_rect).release()); value->SetDouble("opacity", opacity); value->SetString("blend_mode", SkXfermode::ModeName(blend_mode)); TracedValue::MakeDictIntoImplicitSnapshotWithCategory( TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), - value, - "cc::SharedQuadState", - this); + value.get(), "cc::SharedQuadState", this); + return value.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/quads/shared_quad_state.h b/cc/quads/shared_quad_state.h index dde87a8..30a1e25 100644 --- a/cc/quads/shared_quad_state.h +++ b/cc/quads/shared_quad_state.h @@ -12,9 +12,6 @@ #include "ui/gfx/transform.h" namespace base { -namespace debug { -class TracedValue; -} class Value; } @@ -40,7 +37,7 @@ class CC_EXPORT SharedQuadState { float opacity, SkXfermode::Mode blend_mode, int sorting_context_id); - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; // Transforms from quad's original content space to its target content space. gfx::Transform content_to_target_transform; diff --git a/cc/quads/solid_color_draw_quad.cc b/cc/quads/solid_color_draw_quad.cc index a11b151..333ee17 100644 --- a/cc/quads/solid_color_draw_quad.cc +++ b/cc/quads/solid_color_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/solid_color_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" @@ -48,7 +47,7 @@ const SolidColorDrawQuad* SolidColorDrawQuad::MaterialCast( return static_cast<const SolidColorDrawQuad*>(quad); } -void SolidColorDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void SolidColorDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("color", color); value->SetBoolean("force_anti_aliasing_off", force_anti_aliasing_off); } diff --git a/cc/quads/solid_color_draw_quad.h b/cc/quads/solid_color_draw_quad.h index bfb6022..1e746e0 100644 --- a/cc/quads/solid_color_draw_quad.h +++ b/cc/quads/solid_color_draw_quad.h @@ -39,7 +39,7 @@ class CC_EXPORT SolidColorDrawQuad : public DrawQuad { static const SolidColorDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/stream_video_draw_quad.cc b/cc/quads/stream_video_draw_quad.cc index 6b5a509..683d4e5 100644 --- a/cc/quads/stream_video_draw_quad.cc +++ b/cc/quads/stream_video_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/stream_video_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -50,11 +49,9 @@ const StreamVideoDrawQuad* StreamVideoDrawQuad::MaterialCast( return static_cast<const StreamVideoDrawQuad*>(quad); } -void StreamVideoDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void StreamVideoDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("resource_id", resource_id); - value->BeginArray("matrix"); - MathUtil::AddToTracedValue(matrix, value); - value->EndArray(); + value->Set("matrix", MathUtil::AsValue(matrix).release()); } } // namespace cc diff --git a/cc/quads/stream_video_draw_quad.h b/cc/quads/stream_video_draw_quad.h index 5db7c3b..0570f31 100644 --- a/cc/quads/stream_video_draw_quad.h +++ b/cc/quads/stream_video_draw_quad.h @@ -40,7 +40,7 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad { static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/surface_draw_quad.cc b/cc/quads/surface_draw_quad.cc index 7ed8f2e..04645da 100644 --- a/cc/quads/surface_draw_quad.cc +++ b/cc/quads/surface_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/surface_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" @@ -43,7 +42,7 @@ const SurfaceDrawQuad* SurfaceDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast<const SurfaceDrawQuad*>(quad); } -void SurfaceDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void SurfaceDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("surface_id", surface_id.id); } diff --git a/cc/quads/surface_draw_quad.h b/cc/quads/surface_draw_quad.h index 91e5668..7b22ed5 100644 --- a/cc/quads/surface_draw_quad.h +++ b/cc/quads/surface_draw_quad.h @@ -36,7 +36,7 @@ class CC_EXPORT SurfaceDrawQuad : public DrawQuad { static const SurfaceDrawQuad* MaterialCast(const DrawQuad* quad); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/texture_draw_quad.cc b/cc/quads/texture_draw_quad.cc index 72435c2..6637e4f 100644 --- a/cc/quads/texture_draw_quad.cc +++ b/cc/quads/texture_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/texture_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -84,24 +83,16 @@ const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast<const TextureDrawQuad*>(quad); } -void TextureDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void TextureDrawQuad::ExtendValue(base::DictionaryValue* value) const { value->SetInteger("resource_id", resource_id); value->SetBoolean("premultiplied_alpha", premultiplied_alpha); - value->BeginArray("uv_top_left"); - MathUtil::AddToTracedValue(uv_top_left, value); - value->EndArray(); - - value->BeginArray("uv_bottom_right"); - MathUtil::AddToTracedValue(uv_bottom_right, value); - value->EndArray(); - + value->Set("uv_top_left", MathUtil::AsValue(uv_top_left).release()); + value->Set("uv_bottom_right", MathUtil::AsValue(uv_bottom_right).release()); value->SetInteger("background_color", background_color); - - value->BeginArray("vertex_opacity"); + scoped_ptr<base::ListValue> vertex_opacity_value(new base::ListValue); for (size_t i = 0; i < 4; ++i) - value->AppendDouble(vertex_opacity[i]); - value->EndArray(); - + vertex_opacity_value->AppendDouble(vertex_opacity[i]); + value->Set("vertex_opacity", vertex_opacity_value.release()); value->SetBoolean("flipped", flipped); } diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h index ef8090c..409679b 100644 --- a/cc/quads/texture_draw_quad.h +++ b/cc/quads/texture_draw_quad.h @@ -55,7 +55,7 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad { static const TextureDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/tile_draw_quad.cc b/cc/quads/tile_draw_quad.cc index ea3a14a..839f0de 100644 --- a/cc/quads/tile_draw_quad.cc +++ b/cc/quads/tile_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/tile_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "third_party/khronos/GLES2/gl2.h" @@ -62,7 +61,7 @@ const TileDrawQuad* TileDrawQuad::MaterialCast(const DrawQuad* quad) { return static_cast<const TileDrawQuad*>(quad); } -void TileDrawQuad::ExtendValue(base::debug::TracedValue* value) const { +void TileDrawQuad::ExtendValue(base::DictionaryValue* value) const { ContentDrawQuadBase::ExtendValue(value); value->SetInteger("resource_id", resource_id); } diff --git a/cc/quads/tile_draw_quad.h b/cc/quads/tile_draw_quad.h index 72e6bba..2d3c2ee 100644 --- a/cc/quads/tile_draw_quad.h +++ b/cc/quads/tile_draw_quad.h @@ -41,7 +41,7 @@ class CC_EXPORT TileDrawQuad : public ContentDrawQuadBase { static const TileDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/quads/yuv_video_draw_quad.cc b/cc/quads/yuv_video_draw_quad.cc index 612362e..d2443ba 100644 --- a/cc/quads/yuv_video_draw_quad.cc +++ b/cc/quads/yuv_video_draw_quad.cc @@ -4,7 +4,6 @@ #include "cc/quads/yuv_video_draw_quad.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -75,10 +74,8 @@ const YUVVideoDrawQuad* YUVVideoDrawQuad::MaterialCast( return static_cast<const YUVVideoDrawQuad*>(quad); } -void YUVVideoDrawQuad::ExtendValue(base::debug::TracedValue* value) const { - value->BeginArray("tex_coord_rect"); - MathUtil::AddToTracedValue(tex_coord_rect, value); - value->EndArray(); +void YUVVideoDrawQuad::ExtendValue(base::DictionaryValue* value) const { + value->Set("tex_coord_rect", MathUtil::AsValue(tex_coord_rect).release()); value->SetInteger("y_plane_resource_id", y_plane_resource_id); value->SetInteger("u_plane_resource_id", u_plane_resource_id); value->SetInteger("v_plane_resource_id", v_plane_resource_id); diff --git a/cc/quads/yuv_video_draw_quad.h b/cc/quads/yuv_video_draw_quad.h index 930c821..93975d7 100644 --- a/cc/quads/yuv_video_draw_quad.h +++ b/cc/quads/yuv_video_draw_quad.h @@ -61,7 +61,7 @@ class CC_EXPORT YUVVideoDrawQuad : public DrawQuad { static const YUVVideoDrawQuad* MaterialCast(const DrawQuad*); private: - virtual void ExtendValue(base::debug::TracedValue* value) const OVERRIDE; + virtual void ExtendValue(base::DictionaryValue* value) const OVERRIDE; }; } // namespace cc diff --git a/cc/resources/image_copy_raster_worker_pool.cc b/cc/resources/image_copy_raster_worker_pool.cc index 2a9b7f1..f3f8884 100644 --- a/cc/resources/image_copy_raster_worker_pool.cc +++ b/cc/resources/image_copy_raster_worker_pool.cc @@ -7,7 +7,6 @@ #include <algorithm> #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "cc/debug/traced_value.h" #include "cc/resources/resource_pool.h" #include "cc/resources/scoped_resource.h" @@ -142,7 +141,12 @@ void ImageCopyRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { resource_pool_->ReduceResourceUsage(); TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + "rasterizing", + "state", + TracedValue::FromValue(StateAsValue().release())); } void ImageCopyRasterWorkerPool::CheckForCompletedTasks() { @@ -219,7 +223,12 @@ void ImageCopyRasterWorkerPool::OnRasterRequiredForActivationFinished() { DCHECK(raster_tasks_required_for_activation_pending_); raster_tasks_required_for_activation_pending_ = false; TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + "rasterizing", + "state", + TracedValue::FromValue(StateAsValue().release())); client_->DidFinishRunningTasksRequiredForActivation(); } @@ -231,22 +240,19 @@ void ImageCopyRasterWorkerPool::FlushCopies() { has_performed_copy_since_last_flush_ = false; } -scoped_refptr<base::debug::ConvertableToTraceFormat> -ImageCopyRasterWorkerPool::StateAsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); +scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StateAsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); state->SetInteger("pending_count", raster_task_states_.size()); state->SetBoolean("tasks_required_for_activation_pending", raster_tasks_required_for_activation_pending_); - state->BeginDictionary("staging_state"); - StagingStateAsValueInto(state.get()); - state->EndDictionary(); + state->Set("staging_state", StagingStateAsValue().release()); - return state; + return state.PassAs<base::Value>(); } -void ImageCopyRasterWorkerPool::StagingStateAsValueInto( - base::debug::TracedValue* staging_state) const { +scoped_ptr<base::Value> ImageCopyRasterWorkerPool::StagingStateAsValue() const { + scoped_ptr<base::DictionaryValue> staging_state(new base::DictionaryValue); + staging_state->SetInteger("staging_resource_count", resource_pool_->total_resource_count()); staging_state->SetInteger("bytes_used_for_staging_resources", @@ -257,6 +263,8 @@ void ImageCopyRasterWorkerPool::StagingStateAsValueInto( staging_state->SetInteger("bytes_pending_copy", resource_pool_->total_memory_usage_bytes() - resource_pool_->acquired_memory_usage_bytes()); + + return staging_state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/resources/image_copy_raster_worker_pool.h b/cc/resources/image_copy_raster_worker_pool.h index 62cf3d0..8f9d678 100644 --- a/cc/resources/image_copy_raster_worker_pool.h +++ b/cc/resources/image_copy_raster_worker_pool.h @@ -13,13 +13,6 @@ #include "cc/resources/raster_worker_pool.h" #include "cc/resources/rasterizer.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -class TracedValue; -} -} - namespace cc { class ResourcePool; class ResourceProvider; @@ -84,8 +77,8 @@ class CC_EXPORT ImageCopyRasterWorkerPool : public RasterWorkerPool, void OnRasterFinished(); void OnRasterRequiredForActivationFinished(); void FlushCopies(); - scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; - void StagingStateAsValueInto(base::debug::TracedValue* staging_state) const; + scoped_ptr<base::Value> StateAsValue() const; + scoped_ptr<base::Value> StagingStateAsValue() const; scoped_refptr<base::SequencedTaskRunner> task_runner_; TaskGraphRunner* task_graph_runner_; diff --git a/cc/resources/image_raster_worker_pool.cc b/cc/resources/image_raster_worker_pool.cc index 8ac59d3..79cfe37 100644 --- a/cc/resources/image_raster_worker_pool.cc +++ b/cc/resources/image_raster_worker_pool.cc @@ -5,7 +5,6 @@ #include "cc/resources/image_raster_worker_pool.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "cc/debug/traced_value.h" #include "cc/resources/resource.h" @@ -119,7 +118,12 @@ void ImageRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { new_raster_required_for_activation_finished_task; TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + "rasterizing", + "state", + TracedValue::FromValue(StateAsValue().release())); } void ImageRasterWorkerPool::CheckForCompletedTasks() { @@ -170,18 +174,21 @@ void ImageRasterWorkerPool::OnRasterRequiredForActivationFinished() { DCHECK(raster_tasks_required_for_activation_pending_); raster_tasks_required_for_activation_pending_ = false; TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, "rasterizing", "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + "rasterizing", + "state", + TracedValue::FromValue(StateAsValue().release())); client_->DidFinishRunningTasksRequiredForActivation(); } -scoped_refptr<base::debug::ConvertableToTraceFormat> -ImageRasterWorkerPool::StateAsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); +scoped_ptr<base::Value> ImageRasterWorkerPool::StateAsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); state->SetBoolean("tasks_required_for_activation_pending", raster_tasks_required_for_activation_pending_); - return state; + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/resources/image_raster_worker_pool.h b/cc/resources/image_raster_worker_pool.h index 39ac723..2e11a22 100644 --- a/cc/resources/image_raster_worker_pool.h +++ b/cc/resources/image_raster_worker_pool.h @@ -10,12 +10,6 @@ #include "cc/resources/raster_worker_pool.h" #include "cc/resources/rasterizer.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -} -} - namespace cc { class ResourceProvider; @@ -51,7 +45,7 @@ class CC_EXPORT ImageRasterWorkerPool : public RasterWorkerPool, private: void OnRasterFinished(); void OnRasterRequiredForActivationFinished(); - scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; + scoped_ptr<base::Value> StateAsValue() const; scoped_refptr<base::SequencedTaskRunner> task_runner_; TaskGraphRunner* task_graph_runner_; diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc index 7109237..c760eb77 100644 --- a/cc/resources/managed_tile_state.cc +++ b/cc/resources/managed_tile_state.cc @@ -5,36 +5,43 @@ #include "cc/resources/managed_tile_state.h" #include <limits> -#include <string> -#include "base/debug/trace_event_argument.h" #include "cc/base/math_util.h" namespace cc { -std::string ManagedTileBinToString(ManagedTileBin bin) { +scoped_ptr<base::Value> ManagedTileBinAsValue(ManagedTileBin bin) { switch (bin) { case NOW_AND_READY_TO_DRAW_BIN: - return "NOW_AND_READY_TO_DRAW_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("NOW_AND_READY_TO_DRAW_BIN")); case NOW_BIN: - return "NOW_BIN"; + return scoped_ptr<base::Value>(new base::StringValue("NOW_BIN")); case SOON_BIN: - return "SOON_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("SOON_BIN")); case EVENTUALLY_AND_ACTIVE_BIN: - return "EVENTUALLY_AND_ACTIVE_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("EVENTUALLY_AND_ACTIVE_BIN")); case EVENTUALLY_BIN: - return "EVENTUALLY_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("EVENTUALLY_BIN")); case AT_LAST_AND_ACTIVE_BIN: - return "AT_LAST_AND_ACTIVE_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("AT_LAST_AND_ACTIVE_BIN")); case AT_LAST_BIN: - return "AT_LAST_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("AT_LAST_BIN")); case NEVER_BIN: - return "NEVER_BIN"; + return scoped_ptr<base::Value>( + new base::StringValue("NEVER_BIN")); case NUM_BINS: NOTREACHED(); - return "Invalid Bin (NUM_BINS)"; + return scoped_ptr<base::Value>( + new base::StringValue("Invalid Bin (NUM_BINS)")); } - return "Invalid Bin (UNKNOWN)"; + return scoped_ptr<base::Value>( + new base::StringValue("Invalid Bin (UNKNOWN)")); } ManagedTileState::ManagedTileState() @@ -73,7 +80,7 @@ size_t ManagedTileState::TileVersion::GPUMemoryUsageInBytes() const { ManagedTileState::~ManagedTileState() {} -void ManagedTileState::AsValueInto(base::debug::TracedValue* state) const { +scoped_ptr<base::Value> ManagedTileState::AsValue() const { bool has_resource = false; bool has_active_task = false; for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { @@ -83,13 +90,14 @@ void ManagedTileState::AsValueInto(base::debug::TracedValue* state) const { bool is_using_gpu_memory = has_resource || has_active_task; + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); state->SetBoolean("has_resource", has_resource); state->SetBoolean("is_using_gpu_memory", is_using_gpu_memory); - state->SetString("bin", ManagedTileBinToString(bin)); - state->SetString("resolution", TileResolutionToString(resolution)); - state->SetString("priority_bin", TilePriorityBinToString(priority_bin)); - state->SetDouble("distance_to_visible", - MathUtil::AsFloatSafely(distance_to_visible)); + state->Set("bin", ManagedTileBinAsValue(bin).release()); + state->Set("resolution", TileResolutionAsValue(resolution).release()); + state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); + state->Set("distance_to_visible", + MathUtil::AsValueSafely(distance_to_visible).release()); state->SetBoolean("required_for_activation", required_for_activation); state->SetBoolean( "is_solid_color", @@ -99,6 +107,7 @@ void ManagedTileState::AsValueInto(base::debug::TracedValue* state) const { tile_versions[raster_mode].mode_ == TileVersion::SOLID_COLOR_MODE && !SkColorGetA(tile_versions[raster_mode].solid_color_)); state->SetInteger("scheduled_priority", scheduled_priority); + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/resources/managed_tile_state.h b/cc/resources/managed_tile_state.h index faa7c63..7224dd6 100644 --- a/cc/resources/managed_tile_state.h +++ b/cc/resources/managed_tile_state.h @@ -104,7 +104,7 @@ class CC_EXPORT ManagedTileState { ManagedTileState(); ~ManagedTileState(); - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; // Persisted state: valid all the time. TileVersion tile_versions[NUM_RASTER_MODES]; diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index e206e8d..959e64c 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -10,7 +10,6 @@ #include "base/base64.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" #include "cc/base/util.h" @@ -587,22 +586,18 @@ Picture::PixelRefIterator& Picture::PixelRefIterator::operator++() { scoped_refptr<base::debug::ConvertableToTraceFormat> Picture::AsTraceableRasterData(float scale) const { - scoped_refptr<base::debug::TracedValue> raster_data = - new base::debug::TracedValue(); - TracedValue::SetIDRef(this, raster_data.get(), "picture_id"); + scoped_ptr<base::DictionaryValue> raster_data(new base::DictionaryValue()); + raster_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); raster_data->SetDouble("scale", scale); - return raster_data; + return TracedValue::FromValue(raster_data.release()); } scoped_refptr<base::debug::ConvertableToTraceFormat> Picture::AsTraceableRecordData() const { - scoped_refptr<base::debug::TracedValue> record_data = - new base::debug::TracedValue(); - TracedValue::SetIDRef(this, record_data.get(), "picture_id"); - record_data->BeginArray("layer_rect"); - MathUtil::AddToTracedValue(layer_rect_, record_data.get()); - record_data->EndArray(); - return record_data; + scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); + record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); + record_data->Set("layer_rect", MathUtil::AsValue(layer_rect_).release()); + return TracedValue::FromValue(record_data.release()); } } // namespace cc diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc index 2809d70..64661c1 100644 --- a/cc/resources/picture_layer_tiling.cc +++ b/cc/resources/picture_layer_tiling.cc @@ -9,7 +9,6 @@ #include <limits> #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "cc/base/math_util.h" #include "cc/resources/tile.h" #include "cc/resources/tile_priority.h" @@ -659,12 +658,12 @@ void PictureLayerTiling::DidBecomeActive() { } } -void PictureLayerTiling::AsValueInto(base::debug::TracedValue* state) const { +scoped_ptr<base::Value> PictureLayerTiling::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); state->SetInteger("num_tiles", tiles_.size()); state->SetDouble("content_scale", contents_scale_); - state->BeginDictionary("tiling_size"); - MathUtil::AddToTracedValue(tiling_size(), state); - state->EndDictionary(); + state->Set("tiling_size", MathUtil::AsValue(tiling_size()).release()); + return state.PassAs<base::Value>(); } size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h index e6a5847..808d575 100644 --- a/cc/resources/picture_layer_tiling.h +++ b/cc/resources/picture_layer_tiling.h @@ -18,12 +18,6 @@ #include "cc/resources/tile_priority.h" #include "ui/gfx/rect.h" -namespace base { -namespace debug { -class TracedValue; -} -} - namespace cc { template <typename LayerType> @@ -248,7 +242,7 @@ class CC_EXPORT PictureLayerTiling { return frame_time_in_seconds != last_impl_frame_time_in_seconds_; } - void AsValueInto(base::debug::TracedValue* array) const; + scoped_ptr<base::Value> AsValue() const; size_t GPUMemoryUsageInBytes() const; struct RectExpansionCache { diff --git a/cc/resources/picture_layer_tiling_set.cc b/cc/resources/picture_layer_tiling_set.cc index c799235..e24fb52 100644 --- a/cc/resources/picture_layer_tiling_set.cc +++ b/cc/resources/picture_layer_tiling_set.cc @@ -317,12 +317,11 @@ void PictureLayerTilingSet::DidBecomeRecycled() { tilings_[i]->DidBecomeRecycled(); } -void PictureLayerTilingSet::AsValueInto(base::debug::TracedValue* state) const { - for (size_t i = 0; i < tilings_.size(); ++i) { - state->BeginDictionary(); - tilings_[i]->AsValueInto(state); - state->EndDictionary(); - } +scoped_ptr<base::Value> PictureLayerTilingSet::AsValue() const { + scoped_ptr<base::ListValue> state(new base::ListValue()); + for (size_t i = 0; i < tilings_.size(); ++i) + state->Append(tilings_[i]->AsValue().release()); + return state.PassAs<base::Value>(); } size_t PictureLayerTilingSet::GPUMemoryUsageInBytes() const { diff --git a/cc/resources/picture_layer_tiling_set.h b/cc/resources/picture_layer_tiling_set.h index f19c1b8..d37d9d5 100644 --- a/cc/resources/picture_layer_tiling_set.h +++ b/cc/resources/picture_layer_tiling_set.h @@ -10,12 +10,6 @@ #include "cc/resources/picture_layer_tiling.h" #include "ui/gfx/size.h" -namespace base { -namespace debug { -class TracedValue; -} -} - namespace cc { class CC_EXPORT PictureLayerTilingSet { @@ -121,7 +115,7 @@ class CC_EXPORT PictureLayerTilingSet { Region::Iterator region_iter_; }; - void AsValueInto(base::debug::TracedValue* array) const; + scoped_ptr<base::Value> AsValue() const; size_t GPUMemoryUsageInBytes() const; TilingRange GetTilingRange(TilingRangeType type) const; diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc index 146c886..55209db 100644 --- a/cc/resources/picture_pile_base.cc +++ b/cc/resources/picture_pile_base.cc @@ -8,7 +8,6 @@ #include <set> #include <vector> -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/values.h" #include "cc/base/math_util.h" @@ -199,7 +198,8 @@ gfx::Rect PicturePileBase::PadRect(const gfx::Rect& rect) { return padded_rect; } -void PicturePileBase::AsValueInto(base::debug::TracedValue* pictures) const { +scoped_ptr<base::Value> PicturePileBase::AsValue() const { + scoped_ptr<base::ListValue> pictures(new base::ListValue()); gfx::Rect tiling_rect(tiling_.tiling_size()); std::set<void*> appended_pictures; bool include_borders = true; @@ -213,9 +213,10 @@ void PicturePileBase::AsValueInto(base::debug::TracedValue* pictures) const { Picture* picture = map_iter->second.GetPicture(); if (picture && (appended_pictures.count(picture) == 0)) { appended_pictures.insert(picture); - TracedValue::AppendIDRef(picture, pictures); + pictures->Append(TracedValue::CreateIDRef(picture).release()); } } + return pictures.PassAs<base::Value>(); } PicturePileBase::PictureInfo::PictureInfo() : last_frame_number_(0) {} diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h index b188df7..f244f8f 100644 --- a/cc/resources/picture_pile_base.h +++ b/cc/resources/picture_pile_base.h @@ -18,9 +18,6 @@ #include "ui/gfx/size.h" namespace base { -namespace debug { -class TracedValue; -} class Value; } @@ -55,7 +52,7 @@ class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> { void SetTileGridSize(const gfx::Size& tile_grid_size); TilingData& tiling() { return tiling_; } - void AsValueInto(base::debug::TracedValue* array) const; + scoped_ptr<base::Value> AsValue() const; protected: class CC_EXPORT PictureInfo { diff --git a/cc/resources/pixel_buffer_raster_worker_pool.cc b/cc/resources/pixel_buffer_raster_worker_pool.cc index d7554736..def15c4 100644 --- a/cc/resources/pixel_buffer_raster_worker_pool.cc +++ b/cc/resources/pixel_buffer_raster_worker_pool.cc @@ -8,7 +8,6 @@ #include "base/containers/stack_container.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "cc/debug/traced_value.h" #include "cc/resources/resource.h" #include "gpu/command_buffer/client/gles2_interface.h" @@ -223,7 +222,12 @@ void PixelBufferRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { check_for_completed_raster_task_notifier_.Schedule(); TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + StateName(), + "state", + TracedValue::FromValue(StateAsValue().release())); } void PixelBufferRasterWorkerPool::CheckForCompletedTasks() { @@ -456,7 +460,12 @@ void PixelBufferRasterWorkerPool::CheckForCompletedRasterTasks() { ScheduleMoreTasks(); TRACE_EVENT_ASYNC_STEP_INTO1( - "cc", "ScheduledTasks", this, StateName(), "state", StateAsValue()); + "cc", + "ScheduledTasks", + this, + StateName(), + "state", + TracedValue::FromValue(StateAsValue().release())); // Schedule another check for completed raster tasks while there are // pending raster tasks or pending uploads. @@ -733,29 +742,29 @@ void PixelBufferRasterWorkerPool::CheckForCompletedRasterizerTasks() { completed_tasks_.clear(); } -scoped_refptr<base::debug::ConvertableToTraceFormat> -PixelBufferRasterWorkerPool::StateAsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); +scoped_ptr<base::Value> PixelBufferRasterWorkerPool::StateAsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); + state->SetInteger("completed_count", completed_raster_tasks_.size()); state->SetInteger("pending_count", raster_task_states_.size()); state->SetInteger("pending_upload_count", raster_tasks_with_pending_upload_.size()); state->SetInteger("pending_required_for_activation_count", raster_tasks_required_for_activation_count_); - state->BeginDictionary("throttle_state"); - ThrottleStateAsValueInto(state.get()); - state->EndDictionary(); - return state; + state->Set("throttle_state", ThrottleStateAsValue().release()); + return state.PassAs<base::Value>(); } -void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( - base::debug::TracedValue* throttle_state) const { +scoped_ptr<base::Value> PixelBufferRasterWorkerPool::ThrottleStateAsValue() + const { + scoped_ptr<base::DictionaryValue> throttle_state(new base::DictionaryValue); + throttle_state->SetInteger("bytes_available_for_upload", max_bytes_pending_upload_ - bytes_pending_upload_); throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); throttle_state->SetInteger("scheduled_raster_task_count", scheduled_raster_task_count_); + return throttle_state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/resources/pixel_buffer_raster_worker_pool.h b/cc/resources/pixel_buffer_raster_worker_pool.h index d4fc088..aa1a345 100644 --- a/cc/resources/pixel_buffer_raster_worker_pool.h +++ b/cc/resources/pixel_buffer_raster_worker_pool.h @@ -15,13 +15,6 @@ #include "cc/resources/raster_worker_pool.h" #include "cc/resources/rasterizer.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -class TracedValue; -} -} - namespace cc { class ResourceProvider; @@ -97,8 +90,8 @@ class CC_EXPORT PixelBufferRasterWorkerPool : public RasterWorkerPool, void CheckForCompletedRasterizerTasks(); const char* StateName() const; - scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const; - void ThrottleStateAsValueInto(base::debug::TracedValue* throttle_state) const; + scoped_ptr<base::Value> StateAsValue() const; + scoped_ptr<base::Value> ThrottleStateAsValue() const; scoped_refptr<base::SequencedTaskRunner> task_runner_; TaskGraphRunner* task_graph_runner_; diff --git a/cc/resources/raster_mode.cc b/cc/resources/raster_mode.cc index d67fdd8..5da8ee7 100644 --- a/cc/resources/raster_mode.cc +++ b/cc/resources/raster_mode.cc @@ -10,15 +10,18 @@ namespace cc { -std::string RasterModeToString(RasterMode raster_mode) { +scoped_ptr<base::Value> RasterModeAsValue(RasterMode raster_mode) { switch (raster_mode) { case HIGH_QUALITY_RASTER_MODE: - return "HIGH_QUALITY_RASTER_MODE"; + return scoped_ptr<base::Value>( + new base::StringValue("HIGH_QUALITY_RASTER_MODE")); case LOW_QUALITY_RASTER_MODE: - return "LOW_QUALITY_RASTER_MODE"; + return scoped_ptr<base::Value>( + new base::StringValue("LOW_QUALITY_RASTER_MODE")); default: NOTREACHED() << "Unrecognized RasterMode value " << raster_mode; - return "<unknown RasterMode value>"; + return scoped_ptr<base::Value>( + new base::StringValue("<unknown RasterMode value>")); } } diff --git a/cc/resources/raster_mode.h b/cc/resources/raster_mode.h index ec9ec27..0a2b4c9 100644 --- a/cc/resources/raster_mode.h +++ b/cc/resources/raster_mode.h @@ -5,8 +5,6 @@ #ifndef CC_RESOURCES_RASTER_MODE_H_ #define CC_RESOURCES_RASTER_MODE_H_ -#include <string> - #include "base/memory/scoped_ptr.h" namespace base { @@ -23,7 +21,7 @@ enum RasterMode { NUM_RASTER_MODES = 2 }; -std::string RasterModeToString(RasterMode mode); +scoped_ptr<base::Value> RasterModeAsValue(RasterMode mode); } // namespace cc diff --git a/cc/resources/tile.cc b/cc/resources/tile.cc index 2725a93..48a10db 100644 --- a/cc/resources/tile.cc +++ b/cc/resources/tile.cc @@ -6,7 +6,6 @@ #include <algorithm> -#include "base/debug/trace_event_argument.h" #include "cc/base/math_util.h" #include "cc/debug/traced_value.h" #include "cc/resources/tile_manager.h" @@ -62,31 +61,20 @@ void Tile::MarkRequiredForActivation() { tile_manager_->DidChangeTilePriority(this); } -void Tile::AsValueInto(base::debug::TracedValue* res) const { +scoped_ptr<base::Value> Tile::AsValue() const { + scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); TracedValue::MakeDictIntoImplicitSnapshotWithCategory( - TRACE_DISABLED_BY_DEFAULT("cc.debug"), res, "cc::Tile", this); - TracedValue::SetIDRef(picture_pile_.get(), res, "picture_pile"); + TRACE_DISABLED_BY_DEFAULT("cc.debug"), res.get(), "cc::Tile", this); + res->Set("picture_pile", + TracedValue::CreateIDRef(picture_pile_.get()).release()); res->SetDouble("contents_scale", contents_scale_); - - res->BeginArray("content_rect"); - MathUtil::AddToTracedValue(content_rect_, res); - res->EndArray(); - + res->Set("content_rect", MathUtil::AsValue(content_rect_).release()); res->SetInteger("layer_id", layer_id_); - - res->BeginDictionary("active_priority"); - priority_[ACTIVE_TREE].AsValueInto(res); - res->EndDictionary(); - - res->BeginDictionary("pending_priority"); - priority_[PENDING_TREE].AsValueInto(res); - res->EndDictionary(); - - res->BeginDictionary("managed_state"); - managed_state_.AsValueInto(res); - res->EndDictionary(); - + res->Set("active_priority", priority_[ACTIVE_TREE].AsValue().release()); + res->Set("pending_priority", priority_[PENDING_TREE].AsValue().release()); + res->Set("managed_state", managed_state_.AsValue().release()); res->SetBoolean("use_picture_analysis", use_picture_analysis()); + return res.PassAs<base::Value>(); } size_t Tile::GPUMemoryUsageInBytes() const { diff --git a/cc/resources/tile.h b/cc/resources/tile.h index 8d91446..9aeabfa 100644 --- a/cc/resources/tile.h +++ b/cc/resources/tile.h @@ -103,7 +103,7 @@ class CC_EXPORT Tile : public RefCountedManaged<Tile> { return false; } - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; inline bool IsReadyToDraw() const { for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index f6405bf..bf10d95 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -9,7 +9,6 @@ #include <string> #include "base/bind.h" -#include "base/debug/trace_event_argument.h" #include "base/json/json_writer.h" #include "base/logging.h" #include "base/metrics/histogram.h" @@ -337,13 +336,12 @@ inline ManagedTileBin BinFromTilePriority(const TilePriority& prio) { RasterTaskCompletionStats::RasterTaskCompletionStats() : completed_count(0u), canceled_count(0u) {} -scoped_refptr<base::debug::ConvertableToTraceFormat> -RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); +scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( + const RasterTaskCompletionStats& stats) { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); state->SetInteger("completed_count", stats.completed_count); state->SetInteger("canceled_count", stats.canceled_count); - return state; + return state.PassAs<base::Value>(); } // static @@ -669,7 +667,7 @@ void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { "DidManage", TRACE_EVENT_SCOPE_THREAD, "state", - BasicStateAsValue()); + TracedValue::FromValue(BasicStateAsValue().release())); TRACE_COUNTER_ID1("cc", "unused_memory_bytes", @@ -689,7 +687,8 @@ bool TileManager::UpdateVisibleTiles() { "DidUpdateVisibleTiles", TRACE_EVENT_SCOPE_THREAD, "stats", - RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); + TracedValue::FromValue(RasterTaskCompletionStatsAsValue( + update_visible_tiles_stats_).release())); update_visible_tiles_stats_ = RasterTaskCompletionStats(); bool did_initialize_visible_tile = did_initialize_visible_tile_; @@ -697,27 +696,19 @@ bool TileManager::UpdateVisibleTiles() { return did_initialize_visible_tile; } -scoped_refptr<base::debug::ConvertableToTraceFormat> -TileManager::BasicStateAsValue() const { - scoped_refptr<base::debug::TracedValue> value = - new base::debug::TracedValue(); - BasicStateAsValueInto(value.get()); - return value; -} - -void TileManager::BasicStateAsValueInto(base::debug::TracedValue* state) const { +scoped_ptr<base::Value> TileManager::BasicStateAsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); state->SetInteger("tile_count", tiles_.size()); - state->BeginDictionary("global_state"); - global_state_.AsValueInto(state); - state->EndDictionary(); + state->Set("global_state", global_state_.AsValue().release()); + return state.PassAs<base::Value>(); } -void TileManager::AllTilesAsValueInto(base::debug::TracedValue* state) const { - for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { - state->BeginDictionary(); - it->second->AsValueInto(state); - state->EndDictionary(); - } +scoped_ptr<base::Value> TileManager::AllTilesAsValue() const { + scoped_ptr<base::ListValue> state(new base::ListValue()); + for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) + state->Append(it->second->AsValue().release()); + + return state.PassAs<base::Value>(); } void TileManager::AssignGpuMemoryToTiles( diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index d4c549c..686d0d0 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -27,13 +27,6 @@ #include "cc/resources/resource_pool.h" #include "cc/resources/tile.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -class TracedValue; -} -} - namespace cc { class PictureLayerImpl; class ResourceProvider; @@ -77,8 +70,8 @@ struct RasterTaskCompletionStats { size_t completed_count; size_t canceled_count; }; -scoped_refptr<base::debug::ConvertableToTraceFormat> - RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); +scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( + const RasterTaskCompletionStats& stats); // This class manages tiles, deciding which should get rasterized and which // should no longer have any memory assigned to them. Tile objects are "owned" @@ -109,10 +102,8 @@ class CC_EXPORT TileManager : public RasterizerClient, int source_frame_number, int flags); - scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() - const; - void BasicStateAsValueInto(base::debug::TracedValue* dict) const; - void AllTilesAsValueInto(base::debug::TracedValue* array) const; + scoped_ptr<base::Value> BasicStateAsValue() const; + scoped_ptr<base::Value> AllTilesAsValue() const; const MemoryHistory::Entry& memory_stats_from_last_assign() const { return memory_stats_from_last_assign_; } diff --git a/cc/resources/tile_priority.cc b/cc/resources/tile_priority.cc index 26826af..18678d2 100644 --- a/cc/resources/tile_priority.cc +++ b/cc/resources/tile_priority.cc @@ -4,95 +4,110 @@ #include "cc/resources/tile_priority.h" -#include "base/debug/trace_event_argument.h" #include "base/values.h" #include "cc/base/math_util.h" namespace cc { -std::string WhichTreeToString(WhichTree tree) { +scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree) { switch (tree) { case ACTIVE_TREE: - return "ACTIVE_TREE"; + return scoped_ptr<base::Value>(new base::StringValue("ACTIVE_TREE")); case PENDING_TREE: - return "PENDING_TREE"; + return scoped_ptr<base::Value>(new base::StringValue("PENDING_TREE")); default: DCHECK(false) << "Unrecognized WhichTree value " << tree; - return "<unknown WhichTree value>"; + return scoped_ptr<base::Value>(new base::StringValue( + "<unknown WhichTree value>")); } } -std::string TileResolutionToString(TileResolution resolution) { +scoped_ptr<base::Value> TileResolutionAsValue( + TileResolution resolution) { switch (resolution) { case LOW_RESOLUTION: - return "LOW_RESOLUTION"; + return scoped_ptr<base::Value>(new base::StringValue("LOW_RESOLUTION")); case HIGH_RESOLUTION: - return "HIGH_RESOLUTION"; + return scoped_ptr<base::Value>(new base::StringValue("HIGH_RESOLUTION")); case NON_IDEAL_RESOLUTION: - return "NON_IDEAL_RESOLUTION"; + return scoped_ptr<base::Value>(new base::StringValue( + "NON_IDEAL_RESOLUTION")); } DCHECK(false) << "Unrecognized TileResolution value " << resolution; - return "<unknown TileResolution value>"; + return scoped_ptr<base::Value>(new base::StringValue( + "<unknown TileResolution value>")); } -std::string TilePriorityBinToString(TilePriority::PriorityBin bin) { +scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin) { switch (bin) { case TilePriority::NOW: - return "NOW"; + return scoped_ptr<base::Value>(new base::StringValue("NOW")); case TilePriority::SOON: - return "SOON"; + return scoped_ptr<base::Value>(new base::StringValue("SOON")); case TilePriority::EVENTUALLY: - return "EVENTUALLY"; + return scoped_ptr<base::Value>(new base::StringValue("EVENTUALLY")); } DCHECK(false) << "Unrecognized TilePriority::PriorityBin value " << bin; - return "<unknown TilePriority::PriorityBin value>"; + return scoped_ptr<base::Value>( + new base::StringValue("<unknown TilePriority::PriorityBin value>")); } -void TilePriority::AsValueInto(base::debug::TracedValue* state) const { - state->SetString("resolution", TileResolutionToString(resolution)); - state->SetString("priority_bin", TilePriorityBinToString(priority_bin)); - state->SetDouble("distance_to_visible", - MathUtil::AsDoubleSafely(distance_to_visible)); +scoped_ptr<base::Value> TilePriority::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + state->Set("resolution", TileResolutionAsValue(resolution).release()); + state->Set("priority_bin", TilePriorityBinAsValue(priority_bin).release()); + state->Set("distance_to_visible", + MathUtil::AsValueSafely(distance_to_visible).release()); + return state.PassAs<base::Value>(); } -std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy) { +scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( + TileMemoryLimitPolicy policy) { switch (policy) { case ALLOW_NOTHING: - return "ALLOW_NOTHING"; + return scoped_ptr<base::Value>(new base::StringValue("ALLOW_NOTHING")); case ALLOW_ABSOLUTE_MINIMUM: - return "ALLOW_ABSOLUTE_MINIMUM"; + return scoped_ptr<base::Value>(new base::StringValue( + "ALLOW_ABSOLUTE_MINIMUM")); case ALLOW_PREPAINT_ONLY: - return "ALLOW_PREPAINT_ONLY"; + return scoped_ptr<base::Value>(new base::StringValue( + "ALLOW_PREPAINT_ONLY")); case ALLOW_ANYTHING: - return "ALLOW_ANYTHING"; + return scoped_ptr<base::Value>(new base::StringValue( + "ALLOW_ANYTHING")); default: DCHECK(false) << "Unrecognized policy value"; - return "<unknown>"; + return scoped_ptr<base::Value>(new base::StringValue( + "<unknown>")); } } -std::string TreePriorityToString(TreePriority prio) { +scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio) { switch (prio) { case SAME_PRIORITY_FOR_BOTH_TREES: - return "SAME_PRIORITY_FOR_BOTH_TREES"; + return scoped_ptr<base::Value>(new base::StringValue( + "SAME_PRIORITY_FOR_BOTH_TREES")); case SMOOTHNESS_TAKES_PRIORITY: - return "SMOOTHNESS_TAKES_PRIORITY"; + return scoped_ptr<base::Value>(new base::StringValue( + "SMOOTHNESS_TAKES_PRIORITY")); case NEW_CONTENT_TAKES_PRIORITY: - return "NEW_CONTENT_TAKES_PRIORITY"; + return scoped_ptr<base::Value>(new base::StringValue( + "NEW_CONTENT_TAKES_PRIORITY")); default: DCHECK(false) << "Unrecognized priority value " << prio; - return "<unknown>"; + return scoped_ptr<base::Value>(new base::StringValue("<unknown>")); } } -void GlobalStateThatImpactsTilePriority::AsValueInto( - base::debug::TracedValue* state) const { - state->SetString("memory_limit_policy", - TileMemoryLimitPolicyToString(memory_limit_policy)); +scoped_ptr<base::Value> GlobalStateThatImpactsTilePriority::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + state->Set("memory_limit_policy", + TileMemoryLimitPolicyAsValue(memory_limit_policy).release()); state->SetInteger("soft_memory_limit_in_bytes", soft_memory_limit_in_bytes); state->SetInteger("hard_memory_limit_in_bytes", hard_memory_limit_in_bytes); state->SetInteger("num_resources_limit", num_resources_limit); - state->SetString("tree_priority", TreePriorityToString(tree_priority)); + state->Set("tree_priority", TreePriorityAsValue(tree_priority).release()); + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/resources/tile_priority.h b/cc/resources/tile_priority.h index 02aadae..a0903f1 100644 --- a/cc/resources/tile_priority.h +++ b/cc/resources/tile_priority.h @@ -7,7 +7,6 @@ #include <algorithm> #include <limits> -#include <string> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -30,14 +29,16 @@ enum WhichTree { NUM_TREES = 2 // Be sure to update WhichTreeAsValue when adding new fields. }; -scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree); +scoped_ptr<base::Value> WhichTreeAsValue( + WhichTree tree); enum TileResolution { LOW_RESOLUTION = 0 , HIGH_RESOLUTION = 1, NON_IDEAL_RESOLUTION = 2, }; -std::string TileResolutionToString(TileResolution resolution); +scoped_ptr<base::Value> TileResolutionAsValue( + TileResolution resolution); struct CC_EXPORT TilePriority { enum PriorityBin { NOW, SOON, EVENTUALLY }; @@ -82,7 +83,7 @@ struct CC_EXPORT TilePriority { } } - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; bool operator ==(const TilePriority& other) const { return resolution == other.resolution && @@ -107,7 +108,7 @@ struct CC_EXPORT TilePriority { float distance_to_visible; }; -std::string TilePriorityBinToString(TilePriority::PriorityBin bin); +scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin); enum TileMemoryLimitPolicy { // Nothing. @@ -127,7 +128,8 @@ enum TileMemoryLimitPolicy { // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding // or reordering fields. }; -std::string TileMemoryLimitPolicyToString(TileMemoryLimitPolicy policy); +scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( + TileMemoryLimitPolicy policy); enum TreePriority { SAME_PRIORITY_FOR_BOTH_TREES, @@ -136,7 +138,7 @@ enum TreePriority { NUM_TREE_PRIORITIES // Be sure to update TreePriorityAsValue when adding new fields. }; -std::string TreePriorityToString(TreePriority prio); +scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio); class GlobalStateThatImpactsTilePriority { public: @@ -166,7 +168,7 @@ class GlobalStateThatImpactsTilePriority { return !(*this == other); } - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; }; } // namespace cc diff --git a/cc/scheduler/delay_based_time_source.cc b/cc/scheduler/delay_based_time_source.cc index cd214fd..2be3d3d 100644 --- a/cc/scheduler/delay_based_time_source.cc +++ b/cc/scheduler/delay_based_time_source.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/location.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" @@ -290,25 +289,31 @@ std::string DelayBasedTimeSourceHighRes::TypeString() const { return "DelayBasedTimeSourceHighRes"; } -void DelayBasedTimeSource::AsValueInto(base::debug::TracedValue* state) const { +scoped_ptr<base::Value> DelayBasedTimeSource::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); state->SetString("type", TypeString()); state->SetDouble("last_tick_time_us", LastTickTime().ToInternalValue()); state->SetDouble("next_tick_time_us", NextTickTime().ToInternalValue()); - state->BeginDictionary("current_parameters"); - state->SetDouble("interval_us", - current_parameters_.interval.InMicroseconds()); - state->SetDouble("tick_target_us", - current_parameters_.tick_target.ToInternalValue()); - state->EndDictionary(); - - state->BeginDictionary("next_parameters"); - state->SetDouble("interval_us", next_parameters_.interval.InMicroseconds()); - state->SetDouble("tick_target_us", - next_parameters_.tick_target.ToInternalValue()); - state->EndDictionary(); + scoped_ptr<base::DictionaryValue> state_current_parameters( + new base::DictionaryValue); + state_current_parameters->SetDouble( + "interval_us", current_parameters_.interval.InMicroseconds()); + state_current_parameters->SetDouble( + "tick_target_us", current_parameters_.tick_target.ToInternalValue()); + state->Set("current_parameters", state_current_parameters.release()); + + scoped_ptr<base::DictionaryValue> state_next_parameters( + new base::DictionaryValue); + state_next_parameters->SetDouble("interval_us", + next_parameters_.interval.InMicroseconds()); + state_next_parameters->SetDouble( + "tick_target_us", next_parameters_.tick_target.ToInternalValue()); + state->Set("next_parameters", state_next_parameters.release()); state->SetBoolean("active", active_); + + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/scheduler/delay_based_time_source.h b/cc/scheduler/delay_based_time_source.h index e503bdf..18c8002 100644 --- a/cc/scheduler/delay_based_time_source.h +++ b/cc/scheduler/delay_based_time_source.h @@ -11,12 +11,7 @@ #include "base/values.h" #include "cc/base/cc_export.h" -namespace base { -namespace debug { -class TracedValue; -} -class SingleThreadTaskRunner; -} +namespace base { class SingleThreadTaskRunner; } namespace cc { @@ -54,7 +49,7 @@ class CC_EXPORT DelayBasedTimeSource // Virtual for testing. virtual base::TimeTicks Now() const; - virtual void AsValueInto(base::debug::TracedValue* dict) const; + virtual scoped_ptr<base::Value> AsValue() const; protected: DelayBasedTimeSource(base::TimeDelta interval, diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc index 1451237..52e0f9e 100644 --- a/cc/scheduler/scheduler.cc +++ b/cc/scheduler/scheduler.cc @@ -7,7 +7,6 @@ #include <algorithm> #include "base/auto_reset.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/logging.h" #include "base/single_thread_task_runner.h" #include "cc/debug/devtools_instrumentation.h" @@ -62,9 +61,8 @@ void Scheduler::SyntheticBeginFrameSource::OnTimerTick() { scheduler_->BeginFrame(begin_frame_args); } -void Scheduler::SyntheticBeginFrameSource::AsValueInto( - base::debug::TracedValue* state) const { - time_source_->AsValueInto(state); +scoped_ptr<base::Value> Scheduler::SyntheticBeginFrameSource::AsValue() const { + return time_source_->AsValue(); } BeginFrameArgs @@ -95,7 +93,7 @@ Scheduler::Scheduler( TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), "Scheduler::Scheduler", "settings", - settings_.AsValue()); + ToTrace(settings_)); DCHECK(client_); DCHECK(!state_machine_.BeginFrameNeeded()); if (settings_.main_frame_before_activation_enabled) { @@ -401,7 +399,7 @@ void Scheduler::SetupPollingMechanisms(bool needs_begin_frame) { // If the scheduler is busy, we queue the BeginFrame to be handled later as // a BeginRetroFrame. void Scheduler::BeginFrame(const BeginFrameArgs& args) { - TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", args.AsValue()); + TRACE_EVENT1("cc", "Scheduler::BeginFrame", "args", ToTrace(args)); DCHECK(settings_.throttle_frame_production); BeginFrameArgs adjusted_args(args); @@ -498,7 +496,7 @@ void Scheduler::PostBeginRetroFrameIfNeeded() { // for a BeginMainFrame+activation to complete before it times out and draws // any asynchronous animation and scroll/pinch updates. void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { - TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", args.AsValue()); + TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", ToTrace(args)); DCHECK(state_machine_.begin_impl_frame_state() == SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); DCHECK(state_machine_.HasInitializedOutputSurface()); @@ -628,7 +626,7 @@ void Scheduler::ProcessScheduledActions() { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), "SchedulerStateMachine", "state", - AsValue()); + ToTrace(this)); state_machine_.UpdateState(action); base::AutoReset<SchedulerStateMachine::Action> mark_inside_action(&inside_action_, action); @@ -682,54 +680,51 @@ bool Scheduler::WillDrawIfNeeded() const { return !state_machine_.PendingDrawsShouldBeAborted(); } -scoped_refptr<base::debug::ConvertableToTraceFormat> Scheduler::AsValue() - const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); - state->BeginDictionary("state_machine"); - state_machine_.AsValueInto(state); - state->EndDictionary(); - if (synthetic_begin_frame_source_) { - state->BeginDictionary("synthetic_begin_frame_source_"); - synthetic_begin_frame_source_->AsValueInto(state); - state->EndDictionary(); - } +scoped_ptr<base::Value> Scheduler::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); + state->Set("state_machine", state_machine_.AsValue().release()); + if (synthetic_begin_frame_source_) + state->Set("synthetic_begin_frame_source_", + synthetic_begin_frame_source_->AsValue().release()); - state->BeginDictionary("scheduler_state"); - state->SetDouble( + scoped_ptr<base::DictionaryValue> scheduler_state(new base::DictionaryValue); + scheduler_state->SetDouble( "time_until_anticipated_draw_time_ms", (AnticipatedDrawTime() - base::TimeTicks::Now()).InMillisecondsF()); - state->SetDouble("vsync_interval_ms", vsync_interval_.InMillisecondsF()); - state->SetDouble("estimated_parent_draw_time_ms", - estimated_parent_draw_time_.InMillisecondsF()); - state->SetBoolean("last_set_needs_begin_frame_", last_set_needs_begin_frame_); - state->SetBoolean("begin_unthrottled_frame_posted_", - begin_unthrottled_frame_posted_); - state->SetBoolean("begin_retro_frame_posted_", begin_retro_frame_posted_); - state->SetInteger("begin_retro_frame_args_", begin_retro_frame_args_.size()); - state->SetBoolean("begin_impl_frame_deadline_task_", - !begin_impl_frame_deadline_task_.IsCancelled()); - state->SetBoolean("poll_for_draw_triggers_task_", - !poll_for_draw_triggers_task_.IsCancelled()); - state->SetBoolean("advance_commit_state_task_", - !advance_commit_state_task_.IsCancelled()); - state->BeginDictionary("begin_impl_frame_args"); - begin_impl_frame_args_.AsValueInto(state); - state->EndDictionary(); - - state->EndDictionary(); - - state->BeginDictionary("client_state"); - state->SetDouble("draw_duration_estimate_ms", - client_->DrawDurationEstimate().InMillisecondsF()); - state->SetDouble( + scheduler_state->SetDouble("vsync_interval_ms", + vsync_interval_.InMillisecondsF()); + scheduler_state->SetDouble("estimated_parent_draw_time_ms", + estimated_parent_draw_time_.InMillisecondsF()); + scheduler_state->SetBoolean("last_set_needs_begin_frame_", + last_set_needs_begin_frame_); + scheduler_state->SetBoolean("begin_unthrottled_frame_posted_", + begin_unthrottled_frame_posted_); + scheduler_state->SetBoolean("begin_retro_frame_posted_", + begin_retro_frame_posted_); + scheduler_state->SetInteger("begin_retro_frame_args_", + begin_retro_frame_args_.size()); + scheduler_state->SetBoolean("begin_impl_frame_deadline_task_", + !begin_impl_frame_deadline_task_.IsCancelled()); + scheduler_state->SetBoolean("poll_for_draw_triggers_task_", + !poll_for_draw_triggers_task_.IsCancelled()); + scheduler_state->SetBoolean("advance_commit_state_task_", + !advance_commit_state_task_.IsCancelled()); + scheduler_state->Set("begin_impl_frame_args", + begin_impl_frame_args_.AsValue().release()); + + state->Set("scheduler_state", scheduler_state.release()); + + scoped_ptr<base::DictionaryValue> client_state(new base::DictionaryValue); + client_state->SetDouble("draw_duration_estimate_ms", + client_->DrawDurationEstimate().InMillisecondsF()); + client_state->SetDouble( "begin_main_frame_to_commit_duration_estimate_ms", client_->BeginMainFrameToCommitDurationEstimate().InMillisecondsF()); - state->SetDouble( + client_state->SetDouble( "commit_to_activate_duration_estimate_ms", client_->CommitToActivateDurationEstimate().InMillisecondsF()); - state->EndDictionary(); - return state; + state->Set("client_state", client_state.release()); + return state.PassAs<base::Value>(); } bool Scheduler::CanCommitAndActivateBeforeDeadline() const { @@ -746,7 +741,7 @@ bool Scheduler::CanCommitAndActivateBeforeDeadline() const { "time_left_after_drawing_ms", (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), "state", - AsValue()); + ToTrace(this)); return estimated_draw_time < begin_impl_frame_args_.deadline; } diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h index afb9e9d..3653c30 100644 --- a/cc/scheduler/scheduler.h +++ b/cc/scheduler/scheduler.h @@ -20,9 +20,6 @@ #include "cc/scheduler/scheduler_state_machine.h" namespace base { -namespace debug { -class ConvertableToTraceFormat; -} class SingleThreadTaskRunner; } @@ -132,7 +129,7 @@ class CC_EXPORT Scheduler { void PollForAnticipatedDrawTriggers(); void PollToAdvanceCommitState(); - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; + scoped_ptr<base::Value> AsValue() const; bool IsInsideAction(SchedulerStateMachine::Action action) { return inside_action_ == action; @@ -164,7 +161,7 @@ class CC_EXPORT Scheduler { // TimeSourceClient implementation of OnTimerTick triggers a BeginFrame. virtual void OnTimerTick() OVERRIDE; - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; private: BeginFrameArgs CreateSyntheticBeginFrameArgs(base::TimeTicks frame_time); diff --git a/cc/scheduler/scheduler_settings.cc b/cc/scheduler/scheduler_settings.cc index ea714e3..f1bf60e 100644 --- a/cc/scheduler/scheduler_settings.cc +++ b/cc/scheduler/scheduler_settings.cc @@ -4,7 +4,6 @@ #include "cc/scheduler/scheduler_settings.h" -#include "base/debug/trace_event_argument.h" #include "cc/trees/layer_tree_settings.h" namespace cc { @@ -37,10 +36,8 @@ SchedulerSettings::SchedulerSettings(const LayerTreeSettings& settings) SchedulerSettings::~SchedulerSettings() {} -scoped_refptr<base::debug::ConvertableToTraceFormat> -SchedulerSettings::AsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); +scoped_ptr<base::Value> SchedulerSettings::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); state->SetBoolean("begin_frame_scheduling_enabled", begin_frame_scheduling_enabled); state->SetBoolean("main_frame_before_draw_enabled", @@ -55,7 +52,7 @@ SchedulerSettings::AsValue() const { state->SetBoolean("using_synchronous_renderer_compositor", using_synchronous_renderer_compositor); state->SetBoolean("throttle_frame_production", throttle_frame_production); - return state; + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/scheduler/scheduler_settings.h b/cc/scheduler/scheduler_settings.h index 65d29c8..c282cf6 100644 --- a/cc/scheduler/scheduler_settings.h +++ b/cc/scheduler/scheduler_settings.h @@ -5,16 +5,10 @@ #ifndef CC_SCHEDULER_SCHEDULER_SETTINGS_H_ #define CC_SCHEDULER_SCHEDULER_SETTINGS_H_ -#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/values.h" #include "cc/base/cc_export.h" -namespace base { -namespace debug { -class ConvertableToTraceFormat; -} -} - namespace cc { class LayerTreeSettings; @@ -33,7 +27,7 @@ class CC_EXPORT SchedulerSettings { bool using_synchronous_renderer_compositor; bool throttle_frame_production; - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; + scoped_ptr<base::Value> AsValue() const; }; } // namespace cc diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc index a37a74a..7070c7a 100644 --- a/cc/scheduler/scheduler_state_machine.cc +++ b/cc/scheduler/scheduler_state_machine.cc @@ -5,7 +5,6 @@ #include "cc/scheduler/scheduler_state_machine.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/format_macros.h" #include "base/logging.h" #include "base/strings/stringprintf.h" @@ -148,96 +147,98 @@ const char* SchedulerStateMachine::ActionToString(Action action) { return "???"; } -scoped_refptr<base::debug::ConvertableToTraceFormat> -SchedulerStateMachine::AsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); - AsValueInto(state); - return state; -} - -void SchedulerStateMachine::AsValueInto(base::debug::TracedValue* state) const { - state->BeginDictionary("major_state"); - state->SetString("next_action", ActionToString(NextAction())); - state->SetString("begin_impl_frame_state", - BeginImplFrameStateToString(begin_impl_frame_state_)); - state->SetString("commit_state", CommitStateToString(commit_state_)); - state->SetString("output_surface_state_", - OutputSurfaceStateToString(output_surface_state_)); - state->SetString("forced_redraw_state", - ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); - state->EndDictionary(); - - state->BeginDictionary("major_timestamps_in_ms"); +scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); + + scoped_ptr<base::DictionaryValue> major_state(new base::DictionaryValue); + major_state->SetString("next_action", ActionToString(NextAction())); + major_state->SetString("begin_impl_frame_state", + BeginImplFrameStateToString(begin_impl_frame_state_)); + major_state->SetString("commit_state", CommitStateToString(commit_state_)); + major_state->SetString("output_surface_state_", + OutputSurfaceStateToString(output_surface_state_)); + major_state->SetString( + "forced_redraw_state", + ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); + state->Set("major_state", major_state.release()); + + scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue); base::TimeTicks now = gfx::FrameTime::Now(); - state->SetDouble("0_interval", - begin_impl_frame_args_.interval.InMicroseconds() / 1000.0L); - state->SetDouble( + timestamps_state->SetDouble( + "0_interval", begin_impl_frame_args_.interval.InMicroseconds() / 1000.0L); + timestamps_state->SetDouble( "1_now_to_deadline", (begin_impl_frame_args_.deadline - now).InMicroseconds() / 1000.0L); - state->SetDouble( + timestamps_state->SetDouble( "2_frame_time_to_now", (now - begin_impl_frame_args_.frame_time).InMicroseconds() / 1000.0L); - state->SetDouble("3_frame_time_to_deadline", - (begin_impl_frame_args_.deadline - - begin_impl_frame_args_.frame_time).InMicroseconds() / - 1000.0L); - state->SetDouble("4_now", - (now - base::TimeTicks()).InMicroseconds() / 1000.0L); - state->SetDouble( + timestamps_state->SetDouble( + "3_frame_time_to_deadline", + (begin_impl_frame_args_.deadline - begin_impl_frame_args_.frame_time) + .InMicroseconds() / + 1000.0L); + timestamps_state->SetDouble( + "4_now", (now - base::TimeTicks()).InMicroseconds() / 1000.0L); + timestamps_state->SetDouble( "5_frame_time", (begin_impl_frame_args_.frame_time - base::TimeTicks()).InMicroseconds() / 1000.0L); - state->SetDouble( + timestamps_state->SetDouble( "6_deadline", (begin_impl_frame_args_.deadline - base::TimeTicks()).InMicroseconds() / 1000.0L); - state->EndDictionary(); - - state->BeginDictionary("minor_state"); - state->SetInteger("commit_count", commit_count_); - state->SetInteger("current_frame_number", current_frame_number_); - - state->SetInteger("last_frame_number_animate_performed", - last_frame_number_animate_performed_); - state->SetInteger("last_frame_number_swap_performed", - last_frame_number_swap_performed_); - state->SetInteger("last_frame_number_swap_requested", - last_frame_number_swap_requested_); - state->SetInteger("last_frame_number_begin_main_frame_sent", - last_frame_number_begin_main_frame_sent_); - state->SetInteger("last_frame_number_update_visible_tiles_was_called", - last_frame_number_update_visible_tiles_was_called_); - - state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); - state->SetInteger("consecutive_checkerboard_animations", - consecutive_checkerboard_animations_); - state->SetInteger("max_pending_swaps_", max_pending_swaps_); - state->SetInteger("pending_swaps_", pending_swaps_); - state->SetBoolean("needs_redraw", needs_redraw_); - state->SetBoolean("needs_animate_", needs_animate_); - state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); - state->SetBoolean("swap_used_incomplete_tile", swap_used_incomplete_tile_); - state->SetBoolean("needs_commit", needs_commit_); - state->SetBoolean("visible", visible_); - state->SetBoolean("can_start", can_start_); - state->SetBoolean("can_draw", can_draw_); - state->SetBoolean("has_pending_tree", has_pending_tree_); - state->SetBoolean("pending_tree_is_ready_for_activation", - pending_tree_is_ready_for_activation_); - state->SetBoolean("active_tree_needs_first_draw", - active_tree_needs_first_draw_); - state->SetBoolean("did_create_and_initialize_first_output_surface", - did_create_and_initialize_first_output_surface_); - state->SetBoolean("smoothness_takes_priority", smoothness_takes_priority_); - state->SetBoolean("main_thread_is_in_high_latency_mode", - MainThreadIsInHighLatencyMode()); - state->SetBoolean("skip_begin_main_frame_to_reduce_latency", - skip_begin_main_frame_to_reduce_latency_); - state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", - skip_next_begin_main_frame_to_reduce_latency_); - state->SetBoolean("continuous_painting", continuous_painting_); - state->EndDictionary(); + state->Set("major_timestamps_in_ms", timestamps_state.release()); + + scoped_ptr<base::DictionaryValue> minor_state(new base::DictionaryValue); + minor_state->SetInteger("commit_count", commit_count_); + minor_state->SetInteger("current_frame_number", current_frame_number_); + + minor_state->SetInteger("last_frame_number_animate_performed", + last_frame_number_animate_performed_); + minor_state->SetInteger("last_frame_number_swap_performed", + last_frame_number_swap_performed_); + minor_state->SetInteger("last_frame_number_swap_requested", + last_frame_number_swap_requested_); + minor_state->SetInteger( + "last_frame_number_begin_main_frame_sent", + last_frame_number_begin_main_frame_sent_); + minor_state->SetInteger( + "last_frame_number_update_visible_tiles_was_called", + last_frame_number_update_visible_tiles_was_called_); + + minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); + minor_state->SetInteger("consecutive_checkerboard_animations", + consecutive_checkerboard_animations_); + minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_); + minor_state->SetInteger("pending_swaps_", pending_swaps_); + minor_state->SetBoolean("needs_redraw", needs_redraw_); + minor_state->SetBoolean("needs_animate_", needs_animate_); + minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); + minor_state->SetBoolean("swap_used_incomplete_tile", + swap_used_incomplete_tile_); + minor_state->SetBoolean("needs_commit", needs_commit_); + minor_state->SetBoolean("visible", visible_); + minor_state->SetBoolean("can_start", can_start_); + minor_state->SetBoolean("can_draw", can_draw_); + minor_state->SetBoolean("has_pending_tree", has_pending_tree_); + minor_state->SetBoolean("pending_tree_is_ready_for_activation", + pending_tree_is_ready_for_activation_); + minor_state->SetBoolean("active_tree_needs_first_draw", + active_tree_needs_first_draw_); + minor_state->SetBoolean("did_create_and_initialize_first_output_surface", + did_create_and_initialize_first_output_surface_); + minor_state->SetBoolean("smoothness_takes_priority", + smoothness_takes_priority_); + minor_state->SetBoolean("main_thread_is_in_high_latency_mode", + MainThreadIsInHighLatencyMode()); + minor_state->SetBoolean("skip_begin_main_frame_to_reduce_latency", + skip_begin_main_frame_to_reduce_latency_); + minor_state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", + skip_next_begin_main_frame_to_reduce_latency_); + minor_state->SetBoolean("continuous_painting", continuous_painting_); + state->Set("minor_state", minor_state.release()); + + return state.PassAs<base::Value>(); } void SchedulerStateMachine::AdvanceCurrentFrameNumber() { @@ -809,27 +810,26 @@ bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) { AdvanceCurrentFrameNumber(); begin_impl_frame_args_ = args; - DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) - << AsValue()->ToString(); + DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) << *AsValue(); begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; } void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() { DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING) - << AsValue()->ToString(); + << *AsValue(); begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; } void SchedulerStateMachine::OnBeginImplFrameDeadline() { DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) - << AsValue()->ToString(); + << *AsValue(); begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; } void SchedulerStateMachine::OnBeginImplFrameIdle() { DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) - << AsValue()->ToString(); + << *AsValue(); begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; } @@ -1009,8 +1009,7 @@ void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } void SchedulerStateMachine::NotifyReadyToCommit() { - DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) - << AsValue()->ToString(); + DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) << *AsValue(); commit_state_ = COMMIT_STATE_READY_TO_COMMIT; } diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h index d92a352f..0fbdf41 100644 --- a/cc/scheduler/scheduler_state_machine.h +++ b/cc/scheduler/scheduler_state_machine.h @@ -16,10 +16,6 @@ #include "cc/scheduler/scheduler_settings.h" namespace base { -namespace debug { -class ConvertableToTraceForamt; -class TracedValue; -} class Value; } @@ -106,8 +102,7 @@ class CC_EXPORT SchedulerStateMachine { }; static const char* ActionToString(Action action); - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; Action NextAction() const; void UpdateState(Action action); diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc index 1dd9788..c89da2f 100644 --- a/cc/scheduler/scheduler_state_machine_unittest.cc +++ b/cc/scheduler/scheduler_state_machine_unittest.cc @@ -4,18 +4,17 @@ #include "cc/scheduler/scheduler_state_machine.h" -#include "base/debug/trace_event.h" #include "cc/scheduler/scheduler.h" #include "cc/test/begin_frame_args_test.h" #include "testing/gtest/include/gtest/gtest.h" #define EXPECT_ACTION_UPDATE_STATE(action) \ - EXPECT_EQ(action, state.NextAction()) << state.AsValue()->ToString(); \ + EXPECT_EQ(action, state.NextAction()) << *state.AsValue(); \ if (action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE || \ action == SchedulerStateMachine::ACTION_DRAW_AND_SWAP_FORCED) { \ EXPECT_EQ(SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, \ state.begin_impl_frame_state()) \ - << state.AsValue()->ToString(); \ + << *state.AsValue(); \ } \ state.UpdateState(action); \ if (action == SchedulerStateMachine::ACTION_NONE) { \ @@ -691,7 +690,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { state.SetNeedsCommit(); EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, state.NextAction()) - << state.AsValue()->ToString(); + << *state.AsValue(); } } @@ -717,18 +716,16 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { } else { expected_action = SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE; EXPECT_EQ(state.NextAction(), SchedulerStateMachine::ACTION_ANIMATE) - << state.AsValue()->ToString(); + << *state.AsValue(); state.UpdateState(state.NextAction()); } // Case 1: needs_commit=false. - EXPECT_EQ(state.NextAction(), expected_action) - << state.AsValue()->ToString(); + EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue(); // Case 2: needs_commit=true. state.SetNeedsCommit(); - EXPECT_EQ(state.NextAction(), expected_action) - << state.AsValue()->ToString(); + EXPECT_EQ(state.NextAction(), expected_action) << *state.AsValue(); } } @@ -760,7 +757,7 @@ TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) { state.SetNeedsCommit(); EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE, state.NextAction()) - << state.AsValue()->ToString(); + << *state.AsValue(); } } } @@ -1658,7 +1655,7 @@ TEST(SchedulerStateMachineTest, TestInitialActionsWhenContextLost) { // main thread will just abort anyway. state.SetVisible(false); EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction()) - << state.AsValue()->ToString(); + << *state.AsValue(); } TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index f416cec..aa61af7 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -6,7 +6,6 @@ #include <string> #include <vector> -#include "base/debug/trace_event.h" #include "base/logging.h" #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" @@ -111,7 +110,7 @@ class FakeSchedulerClient : public SchedulerClient { int num_draws() const { return num_draws_; } int num_actions_() const { return static_cast<int>(actions_.size()); } const char* Action(int i) const { return actions_[i]; } - std::string StateForAction(int i) const { return states_[i]->ToString(); } + base::Value& StateForAction(int i) const { return *states_[i]; } base::TimeTicks posted_begin_impl_frame_deadline() const { return posted_begin_impl_frame_deadline_; } @@ -148,24 +147,24 @@ class FakeSchedulerClient : public SchedulerClient { // SchedulerClient implementation. virtual void SetNeedsBeginFrame(bool enable) OVERRIDE { actions_.push_back("SetNeedsBeginFrame"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); needs_begin_frame_ = enable; } virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE { actions_.push_back("WillBeginImplFrame"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { actions_.push_back("ScheduledActionSendBeginMainFrame"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void ScheduledActionAnimate() OVERRIDE { actions_.push_back("ScheduledActionAnimate"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE { actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); num_draws_++; DrawResult result = draw_will_happen_ ? DRAW_SUCCESS : DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; @@ -187,30 +186,30 @@ class FakeSchedulerClient : public SchedulerClient { } virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE { actions_.push_back("ScheduledActionDrawAndSwapForced"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); return DRAW_SUCCESS; } virtual void ScheduledActionCommit() OVERRIDE { actions_.push_back("ScheduledActionCommit"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE { actions_.push_back("ScheduledActionUpdateVisibleTiles"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); if (redraw_will_happen_if_update_visible_tiles_happens_) scheduler_->SetNeedsRedraw(); } virtual void ScheduledActionActivateSyncTree() OVERRIDE { actions_.push_back("ScheduledActionActivateSyncTree"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { actions_.push_back("ScheduledActionBeginOutputSurfaceCreation"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void ScheduledActionManageTiles() OVERRIDE { actions_.push_back("ScheduledActionManageTiles"); - states_.push_back(scheduler_->AsValue()); + states_.push_back(scheduler_->AsValue().release()); } virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE { if (log_anticipated_draw_time_change_) @@ -239,7 +238,7 @@ class FakeSchedulerClient : public SchedulerClient { bool redraw_will_happen_if_update_visible_tiles_happens_; base::TimeTicks posted_begin_impl_frame_deadline_; std::vector<const char*> actions_; - std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; + ScopedVector<base::Value> states_; scoped_ptr<TestScheduler> scheduler_; scoped_refptr<OrderedSimpleTaskRunner> task_runner_; }; @@ -1168,7 +1167,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { for (int i = 0; i < 3; ++i) { EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), client.task_runner().NextPendingTaskDelay().InMicroseconds()) - << scheduler->AsValue()->ToString(); + << *scheduler->AsValue(); client.task_runner().RunPendingTasks(); EXPECT_GT(client.num_actions_(), actions_so_far); EXPECT_STREQ(client.Action(client.num_actions_() - 1), @@ -1181,7 +1180,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { for (int i = 0; i < 3; ++i) { EXPECT_EQ((frame_args.interval * 2).InMicroseconds(), client.task_runner().NextPendingTaskDelay().InMicroseconds()) - << scheduler->AsValue()->ToString(); + << *scheduler->AsValue(); client.task_runner().RunPendingTasks(); EXPECT_GT(client.num_actions_(), actions_so_far); EXPECT_STREQ(client.Action(client.num_actions_() - 1), diff --git a/cc/test/fake_proxy.cc b/cc/test/fake_proxy.cc index 7d0ad47..facf831 100644 --- a/cc/test/fake_proxy.cc +++ b/cc/test/fake_proxy.cc @@ -36,7 +36,9 @@ bool FakeProxy::SupportsImplScrolling() const { return false; } bool FakeProxy::CommitPendingForTesting() { return false; } -void FakeProxy::AsValueInto(base::debug::TracedValue*) const { +scoped_ptr<base::Value> FakeProxy::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + return state.PassAs<base::Value>(); } } // namespace cc diff --git a/cc/test/fake_proxy.h b/cc/test/fake_proxy.h index dc04c70..2a700906 100644 --- a/cc/test/fake_proxy.h +++ b/cc/test/fake_proxy.h @@ -43,7 +43,7 @@ class FakeProxy : public Proxy { virtual bool SupportsImplScrolling() const OVERRIDE; virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} virtual bool CommitPendingForTesting() OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* state) const OVERRIDE; + virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; virtual RendererCapabilities& GetRendererCapabilities(); void SetMaxPartialTextureUpdates(size_t max); diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index ed7472d..2ef991c 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -12,7 +12,6 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" @@ -1154,10 +1153,10 @@ void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, animate)); } -void LayerTreeHost::AsValueInto(base::debug::TracedValue* state) const { - state->BeginDictionary("proxy"); - proxy_->AsValueInto(state); - state->EndDictionary(); +scoped_ptr<base::Value> LayerTreeHost::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + state->Set("proxy", proxy_->AsValue().release()); + return state.PassAs<base::Value>(); } void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 2fa5b58..d7a618a 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -257,7 +257,7 @@ class CC_EXPORT LayerTreeHost { } // Obtains a thorough dump of the LayerTreeHost as a value. - void AsValueInto(base::debug::TracedValue* value) const; + scoped_ptr<base::Value> AsValue() const; bool in_paint_layer_contents() const { return in_paint_layer_contents_; } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index e155be6..fdf8e5c 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/containers/hash_tables.h" -#include "base/debug/trace_event_argument.h" #include "base/json/json_writer.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" @@ -529,8 +528,8 @@ void LayerTreeHostImpl::TrackDamageForAllSurfaces( } } -void LayerTreeHostImpl::FrameData::AsValueInto( - base::debug::TracedValue* value) const { +scoped_ptr<base::Value> LayerTreeHostImpl::FrameData::AsValue() const { + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); value->SetBoolean("contains_incomplete_tile", contains_incomplete_tile); value->SetBoolean("has_no_damage", has_no_damage); @@ -540,14 +539,12 @@ void LayerTreeHostImpl::FrameData::AsValueInto( TRACE_EVENT_CATEGORY_GROUP_ENABLED( TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); if (quads_enabled) { - value->BeginArray("render_passes"); - for (size_t i = 0; i < render_passes.size(); ++i) { - value->BeginDictionary(); - render_passes[i]->AsValueInto(value); - value->EndDictionary(); - } - value->EndArray(); + scoped_ptr<base::ListValue> render_pass_list(new base::ListValue()); + for (size_t i = 0; i < render_passes.size(); ++i) + render_pass_list->Append(render_passes[i]->AsValue().release()); + value->Set("render_passes", render_pass_list.release()); } + return value.PassAs<base::Value>(); } void LayerTreeHostImpl::FrameData::AppendRenderPass( @@ -1546,7 +1543,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, TRACE_DISABLED_BY_DEFAULT("devtools.timeline.layers"), "cc::LayerTreeHostImpl", id_, - AsValueWithFrame(frame)); + TracedValue::FromValue(AsValueWithFrame(frame).release())); } const DrawMode draw_mode = GetDrawMode(); @@ -3172,66 +3169,29 @@ base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { return gfx::FrameTime::Now(); } -scoped_refptr<base::debug::ConvertableToTraceFormat> -LayerTreeHostImpl::AsValue() const { - return AsValueWithFrame(NULL); -} - -scoped_refptr<base::debug::ConvertableToTraceFormat> -LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); - AsValueWithFrameInto(frame, state.get()); - return state; -} - -void LayerTreeHostImpl::AsValueWithFrameInto( - FrameData* frame, - base::debug::TracedValue* state) const { - if (this->pending_tree_) { - state->BeginDictionary("activation_state"); - ActivationStateAsValueInto(state); - state->EndDictionary(); - } - state->BeginDictionary("device_viewport_size"); - MathUtil::AddToTracedValue(device_viewport_size_, state); - state->EndDictionary(); - if (tile_manager_) { - state->BeginArray("tiles"); - tile_manager_->AllTilesAsValueInto(state); - state->EndArray(); - } - state->BeginDictionary("active_tree"); - active_tree_->AsValueInto(state); - state->EndDictionary(); - if (pending_tree_) { - state->BeginDictionary("pending_tree"); - pending_tree_->AsValueInto(state); - state->EndDictionary(); - } - if (frame) { - state->BeginDictionary("frame"); - frame->AsValueInto(state); - state->EndDictionary(); - } -} - -scoped_refptr<base::debug::ConvertableToTraceFormat> -LayerTreeHostImpl::ActivationStateAsValue() const { - scoped_refptr<base::debug::TracedValue> state = - new base::debug::TracedValue(); - ActivationStateAsValueInto(state.get()); - return state; -} - -void LayerTreeHostImpl::ActivationStateAsValueInto( - base::debug::TracedValue* state) const { - TracedValue::SetIDRef(this, state, "lthi"); - if (tile_manager_) { - state->BeginDictionary("tile_manager"); - tile_manager_->BasicStateAsValueInto(state); - state->EndDictionary(); - } +scoped_ptr<base::Value> LayerTreeHostImpl::AsValueWithFrame( + FrameData* frame) const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + if (this->pending_tree_) + state->Set("activation_state", ActivationStateAsValue().release()); + state->Set("device_viewport_size", + MathUtil::AsValue(device_viewport_size_).release()); + if (tile_manager_) + state->Set("tiles", tile_manager_->AllTilesAsValue().release()); + state->Set("active_tree", active_tree_->AsValue().release()); + if (pending_tree_) + state->Set("pending_tree", pending_tree_->AsValue().release()); + if (frame) + state->Set("frame", frame->AsValue().release()); + return state.PassAs<base::Value>(); +} + +scoped_ptr<base::Value> LayerTreeHostImpl::ActivationStateAsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + state->Set("lthi", TracedValue::CreateIDRef(this).release()); + if (tile_manager_) + state->Set("tile_manager", tile_manager_->BasicStateAsValue().release()); + return state.PassAs<base::Value>(); } void LayerTreeHostImpl::SetDebugState( diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 821028f..7b3c3fd 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -165,7 +165,7 @@ class CC_EXPORT LayerTreeHostImpl struct CC_EXPORT FrameData : public RenderPassSink { FrameData(); virtual ~FrameData(); - void AsValueInto(base::debug::TracedValue* value) const; + scoped_ptr<base::Value> AsValue() const; std::vector<gfx::Rect> occluding_screen_space_rects; std::vector<gfx::Rect> non_occluding_screen_space_rects; @@ -434,17 +434,9 @@ class CC_EXPORT LayerTreeHostImpl return begin_impl_frame_interval_; } - void AsValueInto(base::debug::TracedValue* value) const { - return AsValueWithFrameInto(NULL, value); - } - void AsValueWithFrameInto(FrameData* frame, - base::debug::TracedValue* value) const; - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const; - scoped_refptr<base::debug::ConvertableToTraceFormat> AsValueWithFrame( - FrameData* frame) const; - scoped_refptr<base::debug::ConvertableToTraceFormat> ActivationStateAsValue() - const; - void ActivationStateAsValueInto(base::debug::TracedValue* value) const; + scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); } + scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const; + scoped_ptr<base::Value> ActivationStateAsValue() const; bool page_scale_animation_active() const { return !!page_scale_animation_; } diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index c054b78..4b21b14 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -8,7 +8,6 @@ #include <set> #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "cc/animation/keyframed_animation_curve.h" #include "cc/animation/scrollbar_animation_controller.h" #include "cc/animation/scrollbar_animation_controller_linear_fade.h" @@ -821,23 +820,26 @@ AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { return layer_tree_host_impl_->animation_registrar(); } -void LayerTreeImpl::AsValueInto(base::debug::TracedValue* state) const { - TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); +scoped_ptr<base::Value> LayerTreeImpl::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + TracedValue::MakeDictIntoImplicitSnapshot( + state.get(), "cc::LayerTreeImpl", this); - state->BeginDictionary("root_layer"); - root_layer_->AsValueInto(state); - state->EndDictionary(); + state->Set("root_layer", root_layer_->AsValue().release()); - state->BeginArray("render_surface_layer_list"); + scoped_ptr<base::ListValue> render_surface_layer_list(new base::ListValue()); typedef LayerIterator<LayerImpl> LayerIteratorType; LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); for (LayerIteratorType it = LayerIteratorType::Begin( &render_surface_layer_list_); it != end; ++it) { if (!it.represents_itself()) continue; - TracedValue::AppendIDRef(*it, state); + render_surface_layer_list->Append(TracedValue::CreateIDRef(*it).release()); } - state->EndArray(); + + state->Set("render_surface_layer_list", + render_surface_layer_list.release()); + return state.PassAs<base::Value>(); } void LayerTreeImpl::SetRootLayerScrollOffsetDelegate( diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index fa6d63a..e602872 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -28,12 +28,6 @@ struct hash<cc::LayerImpl*> { } // namespace BASE_HASH_NAMESPACE #endif // COMPILER -namespace base { -namespace debug { -class TracedValue; -} -} - namespace cc { class ContextProvider; @@ -112,7 +106,7 @@ class CC_EXPORT LayerTreeImpl { const LayerTreeDebugState& debug_state() const; float device_scale_factor() const; DebugRectHistory* debug_rect_history() const; - void AsValueInto(base::debug::TracedValue* dict) const; + scoped_ptr<base::Value> AsValue() const; // Other public methods // --------------------------------------------------------------------------- diff --git a/cc/trees/proxy.cc b/cc/trees/proxy.cc index 3136c65..9258355 100644 --- a/cc/trees/proxy.cc +++ b/cc/trees/proxy.cc @@ -83,4 +83,8 @@ Proxy::~Proxy() { DCHECK(IsMainThread()); } +scoped_ptr<base::Value> Proxy::SchedulerAsValueForTesting() { + return make_scoped_ptr(base::Value::CreateNullValue()); +} + } // namespace cc diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index 6100562..7854edc 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -16,12 +16,7 @@ #include "base/values.h" #include "cc/base/cc_export.h" -namespace base { -namespace debug { -class TracedValue; -} -class SingleThreadTaskRunner; -} +namespace base { class SingleThreadTaskRunner; } namespace gfx { class Rect; @@ -96,12 +91,13 @@ class CC_EXPORT Proxy { virtual bool SupportsImplScrolling() const = 0; - virtual void AsValueInto(base::debug::TracedValue* value) const = 0; + virtual scoped_ptr<base::Value> AsValue() const = 0; virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0; // Testing hooks virtual bool CommitPendingForTesting() = 0; + virtual scoped_ptr<base::Value> SchedulerAsValueForTesting(); protected: Proxy(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 2f67740..45dbe89 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -369,15 +369,18 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { } } -void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const { - // The following line casts away const modifiers because it is just - // setting debug state. We still want the AsValue() function and its - // call chain to be const throughout. - DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); - - state->BeginDictionary("layer_tree_host_impl"); - layer_tree_host_impl_->AsValueInto(state); - state->EndDictionary(); +scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + { + // The following line casts away const modifiers because it is just + // setting debug state. We still want the AsValue() function and its + // call chain to be const throughout. + DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); + + state->Set("layer_tree_host_impl", + layer_tree_host_impl_->AsValue().release()); + } + return state.PassAs<base::Value>(); } void SingleThreadProxy::ForceSerializeOnSwapBuffers() { diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 2b70d70..cd593ac 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -49,7 +49,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy, virtual size_t MaxPartialTextureUpdates() const OVERRIDE; virtual void ForceSerializeOnSwapBuffers() OVERRIDE; virtual bool SupportsImplScrolling() const OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* state) const OVERRIDE; + virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; virtual bool CommitPendingForTesting() OVERRIDE; // LayerTreeHostImplClient implementation diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index b18b93a..03e7afc 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -10,7 +10,6 @@ #include "base/auto_reset.h" #include "base/bind.h" #include "base/debug/trace_event.h" -#include "base/debug/trace_event_argument.h" #include "base/debug/trace_event_synthetic_delay.h" #include "cc/base/swap_promise.h" #include "cc/debug/benchmark_instrumentation.h" @@ -1296,27 +1295,28 @@ ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} -void ThreadProxy::AsValueInto(base::debug::TracedValue* state) const { +scoped_ptr<base::Value> ThreadProxy::AsValue() const { + scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); + CompletionEvent completion; { DebugScopedSetMainThreadBlocked main_thread_blocked( const_cast<ThreadProxy*>(this)); - scoped_refptr<base::debug::TracedValue> state_refptr(state); Proxy::ImplThreadTaskRunner()->PostTask( FROM_HERE, base::Bind(&ThreadProxy::AsValueOnImplThread, impl_thread_weak_ptr_, &completion, - state_refptr)); + state.get())); completion.Wait(); } + return state.PassAs<base::Value>(); } void ThreadProxy::AsValueOnImplThread(CompletionEvent* completion, - base::debug::TracedValue* state) const { - state->BeginDictionary("layer_tree_host_impl"); - impl().layer_tree_host_impl->AsValueInto(state); - state->EndDictionary(); + base::DictionaryValue* state) const { + state->Set("layer_tree_host_impl", + impl().layer_tree_host_impl->AsValue().release()); completion->Signal(); } @@ -1345,6 +1345,30 @@ void ThreadProxy::CommitPendingOnImplThreadForTesting( request->completion.Signal(); } +scoped_ptr<base::Value> ThreadProxy::SchedulerAsValueForTesting() { + if (IsImplThread()) + return impl().scheduler->AsValue().Pass(); + + SchedulerStateRequest scheduler_state_request; + { + DebugScopedSetMainThreadBlocked main_thread_blocked(this); + Proxy::ImplThreadTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&ThreadProxy::SchedulerAsValueOnImplThreadForTesting, + impl_thread_weak_ptr_, + &scheduler_state_request)); + scheduler_state_request.completion.Wait(); + } + return scheduler_state_request.state.Pass(); +} + +void ThreadProxy::SchedulerAsValueOnImplThreadForTesting( + SchedulerStateRequest* request) { + DCHECK(IsImplThread()); + request->state = impl().scheduler->AsValue(); + request->completion.Signal(); +} + void ThreadProxy::RenewTreePriority() { DCHECK(IsImplThread()); bool smoothness_takes_priority = diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 1bea3bf..a28068e 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -173,8 +173,9 @@ class CC_EXPORT ThreadProxy : public Proxy, virtual void ForceSerializeOnSwapBuffers() OVERRIDE; virtual bool SupportsImplScrolling() const OVERRIDE; virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE; - virtual void AsValueInto(base::debug::TracedValue* value) const OVERRIDE; + virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; virtual bool CommitPendingForTesting() OVERRIDE; + virtual scoped_ptr<base::Value> SchedulerAsValueForTesting() OVERRIDE; // LayerTreeHostImplClient implementation virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; @@ -276,8 +277,9 @@ class CC_EXPORT ThreadProxy : public Proxy, void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); void CheckOutputSurfaceStatusOnImplThread(); void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); + void SchedulerAsValueOnImplThreadForTesting(SchedulerStateRequest* request); void AsValueOnImplThread(CompletionEvent* completion, - base::debug::TracedValue* state) const; + base::DictionaryValue* state) const; void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile); void MainThreadHasStoppedFlingingOnImplThread(); void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); |