| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef TracedValue_h | 5 #ifndef TracedValue_h |
| 6 #define TracedValue_h | 6 #define TracedValue_h |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "platform/EventTracer.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
| 11 #include <memory> | |
| 12 | |
| 13 namespace base { | |
| 14 namespace trace_event { | |
| 15 class TracedValue; | |
| 16 } | |
| 17 } | |
| 18 | 11 |
| 19 namespace blink { | 12 namespace blink { |
| 20 | 13 |
| 21 // TracedValue copies all passed names and values and doesn't retain references. | 14 // TracedValue copies all passed names and values and doesn't retain references. |
| 22 class PLATFORM_EXPORT TracedValue final { | 15 class PLATFORM_EXPORT TracedValue final : public base::trace_event::ConvertableT
oTraceFormat { |
| 23 WTF_MAKE_NONCOPYABLE(TracedValue); | 16 WTF_MAKE_NONCOPYABLE(TracedValue); |
| 24 | 17 |
| 25 public: | 18 public: |
| 26 ~TracedValue(); | 19 ~TracedValue(); |
| 27 | 20 |
| 28 static std::unique_ptr<TracedValue> create(); | 21 static std::unique_ptr<TracedValue> create(); |
| 29 | 22 |
| 30 void endDictionary(); | 23 void endDictionary(); |
| 31 void endArray(); | 24 void endArray(); |
| 32 | 25 |
| 33 void setInteger(const char* name, int value); | 26 void setInteger(const char* name, int value); |
| 34 void setDouble(const char* name, double); | 27 void setDouble(const char* name, double); |
| 35 void setBoolean(const char* name, bool value); | 28 void setBoolean(const char* name, bool value); |
| 36 void setString(const char* name, const String& value); | 29 void setString(const char* name, const String& value); |
| 37 void beginArray(const char* name); | 30 void beginArray(const char* name); |
| 38 void beginDictionary(const char* name); | 31 void beginDictionary(const char* name); |
| 39 | 32 |
| 40 void pushInteger(int); | 33 void pushInteger(int); |
| 41 void pushDouble(double); | 34 void pushDouble(double); |
| 42 void pushBoolean(bool); | 35 void pushBoolean(bool); |
| 43 void pushString(const String&); | 36 void pushString(const String&); |
| 44 void beginArray(); | 37 void beginArray(); |
| 45 void beginDictionary(); | 38 void beginDictionary(); |
| 46 | 39 |
| 47 String toString() const; | 40 String toString() const; |
| 48 | 41 |
| 49 private: | 42 private: |
| 50 TracedValue(); | 43 TracedValue(); |
| 51 | 44 |
| 52 // This will be moved (and become null) when TracedValue is passed to | 45 // ConvertableToTraceFormat |
| 53 // EventTracer::addTraceEvent(). | 46 using base::trace_event::ConvertableToTraceFormat::ToString; // Hide this me
thod from blink code. |
| 54 std::unique_ptr<base::trace_event::TracedValue> m_tracedValue; | 47 void AppendAsTraceFormat(std::string*) const final; |
| 48 void EstimateTraceMemoryOverhead(base::trace_event::TraceEventMemoryOverhead
*) final; |
| 55 | 49 |
| 56 friend class EventTracer; | 50 base::trace_event::TracedValue m_tracedValue; |
| 57 }; | 51 }; |
| 58 | 52 |
| 59 } // namespace blink | 53 } // namespace blink |
| 60 | 54 |
| 61 #endif // TracedValue_h | 55 #endif // TracedValue_h |
| OLD | NEW |