| 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/memory/ref_counted.h" |
| 9 #include "platform/EventTracer.h" | 9 #include "platform/EventTracer.h" |
| 10 #include "wtf/PassRefPtr.h" | 10 #include "wtf/PassRefPtr.h" |
| 11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 namespace trace_event { | 14 namespace trace_event { |
| 15 class TracedValue; | 15 class TracedValue; |
| 16 } | 16 } |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 // TracedValue copies all passed names and values and doesn't retain references. | 21 // TracedValue copies all passed names and values and doesn't retain references. |
| 22 class PLATFORM_EXPORT TracedValue : public TraceEvent::ConvertableToTraceFormat
{ | 22 class PLATFORM_EXPORT TracedValue final : public RefCounted<TracedValue> { |
| 23 WTF_MAKE_NONCOPYABLE(TracedValue); | 23 WTF_MAKE_NONCOPYABLE(TracedValue); |
| 24 | 24 |
| 25 public: | 25 public: |
| 26 ~TracedValue(); |
| 27 |
| 26 static PassRefPtr<TracedValue> create(); | 28 static PassRefPtr<TracedValue> create(); |
| 27 | 29 |
| 28 void endDictionary(); | 30 void endDictionary(); |
| 29 void endArray(); | 31 void endArray(); |
| 30 | 32 |
| 31 void setInteger(const char* name, int value); | 33 void setInteger(const char* name, int value); |
| 32 void setDouble(const char* name, double); | 34 void setDouble(const char* name, double); |
| 33 void setBoolean(const char* name, bool value); | 35 void setBoolean(const char* name, bool value); |
| 34 void setString(const char* name, const String& value); | 36 void setString(const char* name, const String& value); |
| 35 void beginArray(const char* name); | 37 void beginArray(const char* name); |
| 36 void beginDictionary(const char* name); | 38 void beginDictionary(const char* name); |
| 37 | 39 |
| 38 void pushInteger(int); | 40 void pushInteger(int); |
| 39 void pushDouble(double); | 41 void pushDouble(double); |
| 40 void pushBoolean(bool); | 42 void pushBoolean(bool); |
| 41 void pushString(const String&); | 43 void pushString(const String&); |
| 42 void beginArray(); | 44 void beginArray(); |
| 43 void beginDictionary(); | 45 void beginDictionary(); |
| 44 | 46 |
| 45 String asTraceFormat() const override; | 47 String toString() const; |
| 46 void estimateTraceMemoryOverhead(base::trace_event::TraceEventMemoryOverhead
*) override; | |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 TracedValue(); | 50 TracedValue(); |
| 50 ~TracedValue() override; | |
| 51 | 51 |
| 52 // This will be moved (and become null) when TracedValue is passed to |
| 53 // EventTracer::addTraceEvent(). |
| 52 scoped_refptr<base::trace_event::TracedValue> m_tracedValue; | 54 scoped_refptr<base::trace_event::TracedValue> m_tracedValue; |
| 55 |
| 56 friend class EventTracer; |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 } // namespace blink | 59 } // namespace blink |
| 56 | 60 |
| 57 #endif // TracedValue_h | 61 #endif // TracedValue_h |
| OLD | NEW |