| 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 "platform/EventTracer.h" | 8 #include "platform/EventTracer.h" |
| 9 | 9 |
| 10 #include "wtf/PassRefPtr.h" | 10 #include "wtf/PassRefPtr.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 Vector<RefPtr<JSONValue> > m_stack; | 44 Vector<RefPtr<JSONValue> > m_stack; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 template <class OwnerType> | 47 template <class OwnerType> |
| 48 class TracedDictionary : public TracedValueBase { | 48 class TracedDictionary : public TracedValueBase { |
| 49 WTF_MAKE_NONCOPYABLE(TracedDictionary); | 49 WTF_MAKE_NONCOPYABLE(TracedDictionary); |
| 50 public: | 50 public: |
| 51 OwnerType& endDictionary() | 51 OwnerType& endDictionary() |
| 52 { | 52 { |
| 53 ASSERT(m_stack.size() == nestingLevel); |
| 53 endCurrentDictionary(); | 54 endCurrentDictionary(); |
| 54 return *reinterpret_cast<OwnerType*>(this); | 55 return *reinterpret_cast<OwnerType*>(this); |
| 55 } | 56 } |
| 56 | 57 |
| 57 TracedDictionary<TracedDictionary<OwnerType> >& beginDictionary(const char*
name) | 58 TracedDictionary<TracedDictionary<OwnerType> >& beginDictionary(const char*
name) |
| 58 { | 59 { |
| 59 beginDictionaryNamed(name); | 60 beginDictionaryNamed(name); |
| 60 return *reinterpret_cast<TracedDictionary<TracedDictionary<OwnerType> >*
>(this); | 61 return *reinterpret_cast<TracedDictionary<TracedDictionary<OwnerType> >*
>(this); |
| 61 } | 62 } |
| 62 TracedArray<TracedDictionary<OwnerType> >& beginArray(const char* name) | 63 TracedArray<TracedDictionary<OwnerType> >& beginArray(const char* name) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 { | 79 { |
| 79 TracedValueBase::setBoolean(name, value); | 80 TracedValueBase::setBoolean(name, value); |
| 80 return *this; | 81 return *this; |
| 81 } | 82 } |
| 82 TracedDictionary<OwnerType>& setString(const char* name, const String& value
) | 83 TracedDictionary<OwnerType>& setString(const char* name, const String& value
) |
| 83 { | 84 { |
| 84 TracedValueBase::setString(name, value); | 85 TracedValueBase::setString(name, value); |
| 85 return *this; | 86 return *this; |
| 86 } | 87 } |
| 87 | 88 |
| 89 static const size_t nestingLevel = OwnerType::nestingLevel + 1; |
| 90 |
| 88 private: | 91 private: |
| 89 TracedDictionary(); | 92 TracedDictionary(); |
| 90 ~TracedDictionary(); | 93 ~TracedDictionary(); |
| 91 }; | 94 }; |
| 92 | 95 |
| 93 template <class OwnerType> | 96 template <class OwnerType> |
| 94 class TracedArray : public TracedValueBase { | 97 class TracedArray : public TracedValueBase { |
| 95 WTF_MAKE_NONCOPYABLE(TracedArray); | 98 WTF_MAKE_NONCOPYABLE(TracedArray); |
| 96 public: | 99 public: |
| 97 TracedDictionary<TracedArray<OwnerType> >& beginDictionary() | 100 TracedDictionary<TracedArray<OwnerType> >& beginDictionary() |
| 98 { | 101 { |
| 99 pushDictionary(); | 102 pushDictionary(); |
| 100 return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(th
is); | 103 return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(th
is); |
| 101 } | 104 } |
| 102 TracedDictionary<TracedArray<OwnerType> >& beginArray() | 105 TracedDictionary<TracedArray<OwnerType> >& beginArray() |
| 103 { | 106 { |
| 104 pushArray(); | 107 pushArray(); |
| 105 return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(th
is); | 108 return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(th
is); |
| 106 } | 109 } |
| 107 OwnerType& endArray() | 110 OwnerType& endArray() |
| 108 { | 111 { |
| 112 ASSERT(m_stack.size() == nestingLevel); |
| 109 endCurrentArray(); | 113 endCurrentArray(); |
| 110 return *reinterpret_cast<OwnerType*>(this); | 114 return *reinterpret_cast<OwnerType*>(this); |
| 111 } | 115 } |
| 112 | 116 |
| 113 TracedArray<OwnerType>& pushInteger(int value) | 117 TracedArray<OwnerType>& pushInteger(int value) |
| 114 { | 118 { |
| 115 TracedValueBase::pushInteger(value); | 119 TracedValueBase::pushInteger(value); |
| 116 return *this; | 120 return *this; |
| 117 } | 121 } |
| 118 TracedArray<OwnerType>& pushDouble(double value) | 122 TracedArray<OwnerType>& pushDouble(double value) |
| 119 { | 123 { |
| 120 TracedValueBase::pushDouble(value); | 124 TracedValueBase::pushDouble(value); |
| 121 return *this; | 125 return *this; |
| 122 } | 126 } |
| 123 TracedArray<OwnerType>& pushBoolean(bool value) | 127 TracedArray<OwnerType>& pushBoolean(bool value) |
| 124 { | 128 { |
| 125 TracedValueBase::pushBoolean(value); | 129 TracedValueBase::pushBoolean(value); |
| 126 return *this; | 130 return *this; |
| 127 } | 131 } |
| 128 TracedArray<OwnerType>& pushString(const String& value) | 132 TracedArray<OwnerType>& pushString(const String& value) |
| 129 { | 133 { |
| 130 TracedValueBase::pushString(value); | 134 TracedValueBase::pushString(value); |
| 131 return *this; | 135 return *this; |
| 132 } | 136 } |
| 133 | 137 |
| 138 static const size_t nestingLevel = OwnerType::nestingLevel + 1; |
| 139 |
| 134 private: | 140 private: |
| 135 TracedArray(); | 141 TracedArray(); |
| 136 ~TracedArray(); | 142 ~TracedArray(); |
| 137 }; | 143 }; |
| 138 | 144 |
| 139 class PLATFORM_EXPORT TracedValue : public TracedValueBase { | 145 class PLATFORM_EXPORT TracedValue : public TracedValueBase { |
| 140 WTF_MAKE_NONCOPYABLE(TracedValue); | 146 WTF_MAKE_NONCOPYABLE(TracedValue); |
| 141 public: | 147 public: |
| 142 TracedValue(); | 148 TracedValue(); |
| 143 ~TracedValue(); | 149 ~TracedValue(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 158 { | 164 { |
| 159 TracedValueBase::setBoolean(name, value); | 165 TracedValueBase::setBoolean(name, value); |
| 160 return *this; | 166 return *this; |
| 161 } | 167 } |
| 162 TracedValue& setString(const char* name, const String& value) | 168 TracedValue& setString(const char* name, const String& value) |
| 163 { | 169 { |
| 164 TracedValueBase::setString(name, value); | 170 TracedValueBase::setString(name, value); |
| 165 return *this; | 171 return *this; |
| 166 } | 172 } |
| 167 PassRefPtr<TraceEvent::ConvertableToTraceFormat> finish(); | 173 PassRefPtr<TraceEvent::ConvertableToTraceFormat> finish(); |
| 174 |
| 175 static const size_t nestingLevel = 1; |
| 168 }; | 176 }; |
| 169 | 177 |
| 170 } // namespace WebCore | 178 } // namespace WebCore |
| 171 | 179 |
| 172 #endif // TracedValue_h | 180 #endif // TracedValue_h |
| OLD | NEW |