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

Side by Side Diff: third_party/WebKit/Source/platform/TracedValue.cpp

Issue 2346663004: Moving platform tracing things into platform/tracing. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/TracedValue.h"
6
7 #include "base/trace_event/trace_event_argument.h"
8 #include "wtf/PtrUtil.h"
9 #include "wtf/text/StringUTF8Adaptor.h"
10 #include <memory>
11
12 namespace blink {
13
14 std::unique_ptr<TracedValue> TracedValue::create()
15 {
16 return wrapUnique(new TracedValue());
17 }
18
19 TracedValue::TracedValue()
20 : m_tracedValue(new base::trace_event::TracedValue)
21 {
22 }
23
24 TracedValue::~TracedValue()
25 {
26 }
27
28 void TracedValue::setInteger(const char* name, int value)
29 {
30 ASSERT(m_tracedValue.get());
31 m_tracedValue->SetIntegerWithCopiedName(name, value);
32 }
33
34 void TracedValue::setDouble(const char* name, double value)
35 {
36 ASSERT(m_tracedValue.get());
37 m_tracedValue->SetDoubleWithCopiedName(name, value);
38 }
39
40 void TracedValue::setBoolean(const char* name, bool value)
41 {
42 ASSERT(m_tracedValue.get());
43 m_tracedValue->SetBooleanWithCopiedName(name, value);
44 }
45
46 void TracedValue::setString(const char* name, const String& value)
47 {
48 ASSERT(m_tracedValue.get());
49 StringUTF8Adaptor adaptor(value);
50 m_tracedValue->SetStringWithCopiedName(name, adaptor.asStringPiece());
51 }
52
53 void TracedValue::beginDictionary(const char* name)
54 {
55 ASSERT(m_tracedValue.get());
56 m_tracedValue->BeginDictionaryWithCopiedName(name);
57 }
58
59 void TracedValue::beginArray(const char* name)
60 {
61 ASSERT(m_tracedValue.get());
62 m_tracedValue->BeginArrayWithCopiedName(name);
63 }
64
65 void TracedValue::endDictionary()
66 {
67 ASSERT(m_tracedValue.get());
68 m_tracedValue->EndDictionary();
69 }
70
71 void TracedValue::pushInteger(int value)
72 {
73 ASSERT(m_tracedValue.get());
74 m_tracedValue->AppendInteger(value);
75 }
76
77 void TracedValue::pushDouble(double value)
78 {
79 ASSERT(m_tracedValue.get());
80 m_tracedValue->AppendDouble(value);
81 }
82
83 void TracedValue::pushBoolean(bool value)
84 {
85 ASSERT(m_tracedValue.get());
86 m_tracedValue->AppendBoolean(value);
87 }
88
89 void TracedValue::pushString(const String& value)
90 {
91 ASSERT(m_tracedValue.get());
92 StringUTF8Adaptor adaptor(value);
93 m_tracedValue->AppendString(adaptor.asStringPiece());
94 }
95
96 void TracedValue::beginArray()
97 {
98 ASSERT(m_tracedValue.get());
99 m_tracedValue->BeginArray();
100 }
101
102 void TracedValue::beginDictionary()
103 {
104 ASSERT(m_tracedValue.get());
105 m_tracedValue->BeginDictionary();
106 }
107
108 void TracedValue::endArray()
109 {
110 ASSERT(m_tracedValue.get());
111 m_tracedValue->EndArray();
112 }
113
114 String TracedValue::toString() const
115 {
116 ASSERT(m_tracedValue.get());
117 std::string out;
118 m_tracedValue->AppendAsTraceFormat(&out);
119 return String::fromUTF8(out.c_str());
120 }
121
122 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698