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 /base/debug | |
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
Diffstat (limited to 'base/debug')
-rw-r--r-- | base/debug/trace_event_argument.cc | 117 | ||||
-rw-r--r-- | base/debug/trace_event_argument.h | 57 | ||||
-rw-r--r-- | base/debug/trace_event_argument_unittest.cc | 53 | ||||
-rw-r--r-- | base/debug/trace_event_impl.h | 9 |
4 files changed, 1 insertions, 235 deletions
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() {} |