| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "base/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 | 28 |
| 29 void TracedValue::SetBoolean(const char* name, bool value) { | 29 void TracedValue::SetBoolean(const char* name, bool value) { |
| 30 GetCurrentDictionary()->SetBoolean(name, value); | 30 GetCurrentDictionary()->SetBoolean(name, value); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void TracedValue::SetString(const char* name, const std::string& value) { | 33 void TracedValue::SetString(const char* name, const std::string& value) { |
| 34 GetCurrentDictionary()->SetString(name, value); | 34 GetCurrentDictionary()->SetString(name, value); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void TracedValue::SetValue(const char* name, Value* value) { | 37 void TracedValue::SetValue(const char* name, scoped_ptr<Value> value) { |
| 38 GetCurrentDictionary()->Set(name, value); | 38 GetCurrentDictionary()->Set(name, value.Pass()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void TracedValue::BeginDictionary(const char* name) { | 41 void TracedValue::BeginDictionary(const char* name) { |
| 42 DictionaryValue* dictionary = new DictionaryValue(); | 42 DictionaryValue* dictionary = new DictionaryValue(); |
| 43 GetCurrentDictionary()->Set(name, dictionary); | 43 GetCurrentDictionary()->Set(name, make_scoped_ptr(dictionary)); |
| 44 stack_.push_back(dictionary); | 44 stack_.push_back(dictionary); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void TracedValue::BeginArray(const char* name) { | 47 void TracedValue::BeginArray(const char* name) { |
| 48 ListValue* array = new ListValue(); | 48 ListValue* array = new ListValue(); |
| 49 GetCurrentDictionary()->Set(name, array); | 49 GetCurrentDictionary()->Set(name, make_scoped_ptr(array)); |
| 50 stack_.push_back(array); | 50 stack_.push_back(array); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void TracedValue::EndDictionary() { | 53 void TracedValue::EndDictionary() { |
| 54 DCHECK_GT(stack_.size(), 1u); | 54 DCHECK_GT(stack_.size(), 1u); |
| 55 DCHECK(GetCurrentDictionary()); | 55 DCHECK(GetCurrentDictionary()); |
| 56 stack_.pop_back(); | 56 stack_.pop_back(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void TracedValue::AppendInteger(int value) { | 59 void TracedValue::AppendInteger(int value) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 void TracedValue::AppendAsTraceFormat(std::string* out) const { | 109 void TracedValue::AppendAsTraceFormat(std::string* out) const { |
| 110 std::string tmp; | 110 std::string tmp; |
| 111 JSONWriter::Write(stack_.front(), &tmp); | 111 JSONWriter::Write(stack_.front(), &tmp); |
| 112 *out += tmp; | 112 *out += tmp; |
| 113 DCHECK_EQ(1u, stack_.size()) << tmp; | 113 DCHECK_EQ(1u, stack_.size()) << tmp; |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace trace_event | 116 } // namespace trace_event |
| 117 } // namespace base | 117 } // namespace base |
| OLD | NEW |