Commit 685de6b1 authored by vollick@chromium.org's avatar vollick@chromium.org

Prepare for including compositing reasons in GraphicsLayerDebugInfo

Currently, the debug info is assumed to include only layout rects.
This is a bummer. This CL allows for blink to return an arbitrary JSON
object that will simply be merged into the base::DictionaryValue
we populate for about::tracing. This will allow us to return
arbitrary debug info for tracing from blink.

BUG=None

Review URL: https://codereview.chromium.org/128303003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243865 0039d316-1c4b-4281-b951-d872f2087c98
parent 93caf451
...@@ -1381,13 +1381,30 @@ void LayerImpl::AsValueInto(base::DictionaryValue* state) const { ...@@ -1381,13 +1381,30 @@ void LayerImpl::AsValueInto(base::DictionaryValue* state) const {
std::string str; std::string str;
debug_info_->AppendAsTraceFormat(&str); debug_info_->AppendAsTraceFormat(&str);
base::JSONReader json_reader; base::JSONReader json_reader;
// Parsing the JSON and re-encoding it is not very efficient, scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
// but it's the simplest way to achieve the desired effect, which
// is to output: // TODO(vollick): The TYPE_LIST code below is brittle; it assumes the only
// {..., layout_rects: [{geometry_rect: ...}, ...], ...} // debug info is the layout rects. In future, this will be generalized, and
// rather than: // debug info will return a dictionary to be merged into state. Until then,
// {layout_rects: "[{geometry_rect: ...}, ...]", ...} // we unfortunately have to support both situations. Once we've migrated,
state->Set("layout_rects", json_reader.ReadToValue(str)); // the TYPE_LIST branch will be deleted.
if (debug_info_value->IsType(base::Value::TYPE_LIST)) {
// Parsing the JSON and re-encoding it is not very efficient,
// but it's the simplest way to achieve the desired effect, which
// is to output:
// {..., layout_rects: [{geometry_rect: ...}, ...], ...}
// rather than:
// {layout_rects: "[{geometry_rect: ...}, ...]", ...}
state->Set("layout_rects", debug_info_value.release());
} else if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
base::DictionaryValue* dictionary_value = NULL;
bool converted_to_dictionary =
debug_info_value->GetAsDictionary(&dictionary_value);
DCHECK(converted_to_dictionary);
state->MergeDictionary(dictionary_value);
} else {
NOTREACHED();
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment