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

Side by Side Diff: cc/debug/traced_value.cc

Issue 380763002: Add builders for tracing event's structural arguments (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed memory leak found by Linux ASAN Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/debug/traced_value.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/debug/traced_value.h" 5 #include "cc/debug/traced_value.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/debug/trace_event_argument.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/values.h"
10 9
11 namespace cc { 10 namespace cc {
12 11
13 scoped_ptr<base::Value> TracedValue::CreateIDRef(const void* id) { 12 void TracedValue::AppendIDRef(const void* id, base::debug::TracedValue* state) {
14 scoped_ptr<base::DictionaryValue> res(new base::DictionaryValue()); 13 state->BeginDictionary();
15 res->SetString("id_ref", base::StringPrintf("%p", id)); 14 state->SetString("id_ref", base::StringPrintf("%p", id));
16 return res.PassAs<base::Value>(); 15 state->EndDictionary();
17 } 16 }
18 17
19 void TracedValue::MakeDictIntoImplicitSnapshot( 18 void TracedValue::SetIDRef(const void* id,
20 base::DictionaryValue* dict, const char* object_name, const void* id) { 19 base::debug::TracedValue* state,
20 const char* name) {
21 state->BeginDictionary(name);
22 state->SetString("id_ref", base::StringPrintf("%p", id));
23 state->EndDictionary();
24 }
25
26 void TracedValue::MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict,
27 const char* object_name,
28 const void* id) {
21 dict->SetString("id", base::StringPrintf("%s/%p", object_name, id)); 29 dict->SetString("id", base::StringPrintf("%s/%p", object_name, id));
22 } 30 }
23 31
24 void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( 32 void TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
25 const char* category, 33 const char* category,
26 base::DictionaryValue* dict, 34 base::debug::TracedValue* dict,
27 const char* object_name, 35 const char* object_name,
28 const void* id) { 36 const void* id) {
29 dict->SetString("cat", category); 37 dict->SetString("cat", category);
30 MakeDictIntoImplicitSnapshot(dict, object_name, id); 38 MakeDictIntoImplicitSnapshot(dict, object_name, id);
31 } 39 }
32 40
33 void TracedValue::MakeDictIntoImplicitSnapshotWithCategory( 41 void TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
34 const char* category, 42 const char* category,
35 base::DictionaryValue* dict, 43 base::debug::TracedValue* dict,
36 const char* object_base_type_name, 44 const char* object_base_type_name,
37 const char* object_name, 45 const char* object_name,
38 const void* id) { 46 const void* id) {
39 dict->SetString("cat", category); 47 dict->SetString("cat", category);
40 dict->SetString("base_type", object_base_type_name); 48 dict->SetString("base_type", object_base_type_name);
41 MakeDictIntoImplicitSnapshot(dict, object_name, id); 49 MakeDictIntoImplicitSnapshot(dict, object_name, id);
42 } 50 }
43 51
44 scoped_refptr<base::debug::ConvertableToTraceFormat> TracedValue::FromValue(
45 base::Value* value) {
46 return scoped_refptr<base::debug::ConvertableToTraceFormat>(
47 new TracedValue(value));
48 }
49
50 TracedValue::TracedValue(base::Value* value)
51 : value_(value) {
52 }
53
54 TracedValue::~TracedValue() {
55 }
56
57 void TracedValue::AppendAsTraceFormat(std::string* out) const {
58 std::string tmp;
59 base::JSONWriter::Write(value_.get(), &tmp);
60 *out += tmp;
61 }
62
63 } // namespace cc 52 } // namespace cc
OLDNEW
« no previous file with comments | « cc/debug/traced_value.h ('k') | cc/layers/heads_up_display_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698