| Index: Source/platform/TracedValue.h
|
| diff --git a/Source/platform/TracedValue.h b/Source/platform/TracedValue.h
|
| index 10bb732fe023e8a6f4c0c08d6cdb833899924934..5cb1ba6b82434fd5f1762ba84fd1320b563f6144 100644
|
| --- a/Source/platform/TracedValue.h
|
| +++ b/Source/platform/TracedValue.h
|
| @@ -11,23 +11,160 @@
|
| #include "wtf/text/WTFString.h"
|
|
|
| namespace WebCore {
|
| +class JSONArray;
|
| +class JSONObject;
|
| class JSONValue;
|
| +template<class T> class TracedArray;
|
|
|
| -class PLATFORM_EXPORT TracedValue : public TraceEvent::ConvertableToTraceFormat {
|
| - WTF_MAKE_NONCOPYABLE(TracedValue);
|
| +class PLATFORM_EXPORT TracedValueBase {
|
| + WTF_MAKE_NONCOPYABLE(TracedValueBase);
|
| +protected:
|
| + TracedValueBase();
|
| + ~TracedValueBase();
|
| +
|
| + 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 String& value);
|
| + void beginDictionaryNamed(const char* name);
|
| + void beginArrayNamed(const char* name);
|
| + void endCurrentDictionary();
|
| +
|
| + void pushInteger(int);
|
| + void pushDouble(double);
|
| + void pushBoolean(bool);
|
| + void pushString(const String&);
|
| + void pushArray();
|
| + void pushDictionary();
|
| + void endCurrentArray();
|
| +
|
| + JSONObject* currentDictionary() const;
|
| + JSONArray* currentArray() const;
|
| +
|
| + Vector<RefPtr<JSONValue> > m_stack;
|
| +};
|
| +
|
| +template <class OwnerType>
|
| +class PLATFORM_EXPORT TracedDictionary : public TracedValueBase {
|
| + WTF_MAKE_NONCOPYABLE(TracedDictionary);
|
| public:
|
| - static PassRefPtr<TraceEvent::ConvertableToTraceFormat> fromJSONValue(PassRefPtr<JSONValue> value)
|
| + OwnerType& endDictionary()
|
| {
|
| - return adoptRef(new TracedValue(value));
|
| + endCurrentDictionary();
|
| + return *reinterpret_cast<OwnerType*>(this);
|
| }
|
|
|
| - String asTraceFormat() const OVERRIDE;
|
| + TracedDictionary<TracedDictionary<OwnerType> >& beginDictionary(const char* name)
|
| + {
|
| + beginDictionaryNamed(name);
|
| + return *reinterpret_cast<TracedDictionary<TracedDictionary<OwnerType> >* >(this);
|
| + }
|
| + TracedArray<TracedDictionary<OwnerType> >& beginArray(const char* name)
|
| + {
|
| + beginArrayNamed(name);
|
| + return *reinterpret_cast<TracedArray<TracedDictionary<OwnerType> >* >(this);
|
| + }
|
| + TracedDictionary<OwnerType>& setInteger(const char* name, int value)
|
| + {
|
| + TracedValueBase::setInteger(name, value);
|
| + return *this;
|
| + }
|
| + TracedDictionary<OwnerType>& setDouble(const char* name, double value)
|
| + {
|
| + TracedValueBase::setDouble(name, value);
|
| + return *this;
|
| + }
|
| + TracedDictionary<OwnerType>& setBoolean(const char* name, bool value)
|
| + {
|
| + TracedValueBase::setBoolean(name, value);
|
| + return *this;
|
| + }
|
| + TracedDictionary<OwnerType>& setString(const char* name, const String& value)
|
| + {
|
| + TracedValueBase::setString(name, value);
|
| + return *this;
|
| + }
|
|
|
| private:
|
| - explicit TracedValue(PassRefPtr<JSONValue>);
|
| - virtual ~TracedValue();
|
| + TracedDictionary();
|
| + ~TracedDictionary();
|
| +};
|
|
|
| - RefPtr<JSONValue> m_value;
|
| +template <class OwnerType>
|
| +class PLATFORM_EXPORT TracedArray : public TracedValueBase {
|
| + WTF_MAKE_NONCOPYABLE(TracedArray);
|
| +public:
|
| + TracedDictionary<TracedArray<OwnerType> >& beginDictionary()
|
| + {
|
| + pushDictionary();
|
| + return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(this);
|
| + }
|
| + TracedDictionary<TracedArray<OwnerType> >& beginArray()
|
| + {
|
| + pushArray();
|
| + return *reinterpret_cast<TracedDictionary<TracedArray<OwnerType> >* >(this);
|
| + }
|
| + OwnerType& endArray()
|
| + {
|
| + endCurrentArray();
|
| + return *reinterpret_cast<OwnerType*>(this);
|
| + }
|
| +
|
| + TracedArray<OwnerType>& pushInteger(int value)
|
| + {
|
| + TracedValueBase::pushInteger(value);
|
| + return *this;
|
| + }
|
| + TracedArray<OwnerType>& pushDouble(double value)
|
| + {
|
| + TracedValueBase::pushDouble(value);
|
| + return *this;
|
| + }
|
| + TracedArray<OwnerType>& pushBoolean(bool value)
|
| + {
|
| + TracedValueBase::pushBoolean(value);
|
| + return *this;
|
| + }
|
| + TracedArray<OwnerType>& pushString(const String& value)
|
| + {
|
| + TracedValueBase::pushString(value);
|
| + return *this;
|
| + }
|
| +
|
| +private:
|
| + TracedArray();
|
| + ~TracedArray();
|
| +};
|
| +
|
| +class PLATFORM_EXPORT TracedValue : public TracedValueBase {
|
| + WTF_MAKE_NONCOPYABLE(TracedValue);
|
| +public:
|
| + TracedValue();
|
| + ~TracedValue();
|
| +
|
| + TracedDictionary<TracedValue>& beginDictionary(const char* name);
|
| + TracedArray<TracedValue>& beginArray(const char* name);
|
| + TracedValue& setInteger(const char* name, int value)
|
| + {
|
| + TracedValueBase::setInteger(name, value);
|
| + return *this;
|
| + }
|
| + TracedValue& setDouble(const char* name, double value)
|
| + {
|
| + TracedValueBase::setDouble(name, value);
|
| + return *this;
|
| + }
|
| + TracedValue& setBoolean(const char* name, bool value)
|
| + {
|
| + TracedValueBase::setBoolean(name, value);
|
| + return *this;
|
| + }
|
| + TracedValue& setString(const char* name, const String& value)
|
| + {
|
| + TracedValueBase::setString(name, value);
|
| + return *this;
|
| + }
|
| + PassRefPtr<TraceEvent::ConvertableToTraceFormat> finish();
|
| };
|
|
|
| } // namespace WebCore
|
|
|