blob: 0b747bf120971aed580287d5cda05e190102408d [file] [log] [blame]
eric@webkit.org43974b62010-05-31 22:28:30 +00001/*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +00003 * Copyright (C) 2014 University of Washington. All rights reserved.
drousso@apple.comb0d5aef2017-07-18 20:21:31 +00004 * Copyright (C) 2017 Apple Inc. All rights reserved.
eric@webkit.org43974b62010-05-31 22:28:30 +00005 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
commit-queue@webkit.org35dd3012016-08-15 20:55:16 +000033#pragma once
eric@webkit.org43974b62010-05-31 22:28:30 +000034
andersca@apple.com816a7d32015-07-15 21:29:34 +000035#include "JSExportMacros.h"
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +000036#include <wtf/Assertions.h>
eric@webkit.org43974b62010-05-31 22:28:30 +000037#include <wtf/HashMap.h>
38#include <wtf/RefCounted.h>
39#include <wtf/Vector.h>
barraclough@apple.combbb3cd42010-08-10 17:45:41 +000040#include <wtf/text/StringHash.h>
weinig@apple.com3f5ab022012-09-06 17:36:48 +000041#include <wtf/text/WTFString.h>
eric@webkit.org43974b62010-05-31 22:28:30 +000042
joepeck@webkit.orga3198442013-12-11 22:40:23 +000043namespace Inspector {
eric@webkit.org43974b62010-05-31 22:28:30 +000044
eric@webkit.orgd82076b52010-06-07 11:33:11 +000045class InspectorArray;
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000046class InspectorArrayBase;
eric@webkit.orgd82076b52010-06-07 11:33:11 +000047class InspectorObject;
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000048class InspectorObjectBase;
eric@webkit.org43974b62010-05-31 22:28:30 +000049
joepeck@webkit.orga3198442013-12-11 22:40:23 +000050class JS_EXPORT_PRIVATE InspectorValue : public RefCounted<InspectorValue> {
eric@webkit.org43974b62010-05-31 22:28:30 +000051public:
yurys@chromium.org78119ca2011-08-05 09:37:02 +000052 static const int maxDepth = 1000;
53
bburg@apple.com3e2abaa2016-04-11 23:22:16 +000054 virtual ~InspectorValue()
55 {
56 switch (m_type) {
57 case Type::Null:
58 case Type::Boolean:
59 case Type::Double:
60 case Type::Integer:
61 break;
62 case Type::String:
63 if (m_value.string)
64 m_value.string->deref();
65 break;
66 case Type::Object:
67 case Type::Array:
68 break;
69 }
70 }
eric@webkit.org43974b62010-05-31 22:28:30 +000071
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +000072 static Ref<InspectorValue> null();
bburg@apple.com3e2abaa2016-04-11 23:22:16 +000073 static Ref<InspectorValue> create(bool);
74 static Ref<InspectorValue> create(int);
75 static Ref<InspectorValue> create(double);
76 static Ref<InspectorValue> create(const String&);
77 static Ref<InspectorValue> create(const char*);
eric@webkit.org43974b62010-05-31 22:28:30 +000078
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000079 enum class Type {
80 Null = 0,
81 Boolean,
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +000082 Double,
83 Integer,
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000084 String,
85 Object,
bburg@apple.com3e2abaa2016-04-11 23:22:16 +000086 Array,
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000087 };
eric@webkit.org43974b62010-05-31 22:28:30 +000088
89 Type type() const { return m_type; }
burg@cs.washington.edub5d2afc2014-08-15 22:40:33 +000090 bool isNull() const { return m_type == Type::Null; }
commit-queue@webkit.orgc9903262010-09-03 14:01:33 +000091
bburg@apple.com3e2abaa2016-04-11 23:22:16 +000092 bool asBoolean(bool&) const;
93 bool asInteger(int&) const;
94 bool asInteger(unsigned&) const;
95 bool asInteger(long&) const;
96 bool asInteger(long long&) const;
97 bool asInteger(unsigned long&) const;
98 bool asInteger(unsigned long long&) const;
99 bool asDouble(double&) const;
100 bool asDouble(float&) const;
101 bool asString(String&) const;
102 bool asValue(RefPtr<InspectorValue>&);
103
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000104 virtual bool asObject(RefPtr<InspectorObject>&);
105 virtual bool asArray(RefPtr<InspectorArray>&);
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000106
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000107 static bool parseJSON(const String& jsonInput, RefPtr<InspectorValue>& output);
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000108
eric@webkit.org43974b62010-05-31 22:28:30 +0000109 String toJSONString() const;
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000110 virtual void writeJSON(StringBuilder& output) const;
eric@webkit.org43974b62010-05-31 22:28:30 +0000111
drousso@apple.comb0d5aef2017-07-18 20:21:31 +0000112 virtual size_t memoryCost() const;
113
eric@webkit.org43974b62010-05-31 22:28:30 +0000114protected:
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000115 InspectorValue()
116 : m_type(Type::Null) { }
117
118 explicit InspectorValue(Type type)
119 : m_type(type) { }
120
121 explicit InspectorValue(bool value)
122 : m_type(Type::Boolean)
123 {
124 m_value.boolean = value;
125 }
126
127 explicit InspectorValue(int value)
128 : m_type(Type::Integer)
129 {
130 m_value.number = static_cast<double>(value);
131 }
132
133 explicit InspectorValue(double value)
134 : m_type(Type::Double)
135 {
136 m_value.number = value;
137 }
138
139 explicit InspectorValue(const String& value)
140 : m_type(Type::String)
141 {
142 m_value.string = value.impl();
143 if (m_value.string)
144 m_value.string->ref();
145 }
146
147 explicit InspectorValue(const char* value)
148 : m_type(Type::String)
149 {
150 String wrapper(value);
151 m_value.string = wrapper.impl();
152 if (m_value.string)
153 m_value.string->ref();
154 }
bburg@apple.com371eaff2016-04-08 19:59:25 +0000155
156private:
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000157 Type m_type { Type::Null };
eric@webkit.org43974b62010-05-31 22:28:30 +0000158 union {
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000159 bool boolean;
160 double number;
161 StringImpl* string;
162 } m_value;
commit-queue@webkit.org70beb712016-04-09 20:54:57 +0000163};
164
joepeck@webkit.orga3198442013-12-11 22:40:23 +0000165class JS_EXPORT_PRIVATE InspectorObjectBase : public InspectorValue {
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000166private:
andersca@apple.comc3523f82013-10-18 23:41:24 +0000167 typedef HashMap<String, RefPtr<InspectorValue>> Dictionary;
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000168
169public:
170 typedef Dictionary::iterator iterator;
171 typedef Dictionary::const_iterator const_iterator;
172
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000173 InspectorObject* openAccessors();
174
drousso@apple.comb0d5aef2017-07-18 20:21:31 +0000175 size_t memoryCost() const final;
176
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000177protected:
andersca@apple.com70c60582013-10-07 16:26:16 +0000178 virtual ~InspectorObjectBase();
eric@webkit.org43974b62010-05-31 22:28:30 +0000179
darin@apple.com11ff47c2016-03-04 16:47:55 +0000180 bool asObject(RefPtr<InspectorObject>& output) override;
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000181
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000182 // FIXME: use templates to reduce the amount of duplicated set*() methods.
loislo@chromium.orgec5ebeb2010-08-26 13:11:28 +0000183 void setBoolean(const String& name, bool);
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000184 void setInteger(const String& name, int);
185 void setDouble(const String& name, double);
eric@webkit.org43974b62010-05-31 22:28:30 +0000186 void setString(const String& name, const String&);
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000187 void setValue(const String& name, RefPtr<InspectorValue>&&);
188 void setObject(const String& name, RefPtr<InspectorObjectBase>&&);
189 void setArray(const String& name, RefPtr<InspectorArrayBase>&&);
eric@webkit.org43974b62010-05-31 22:28:30 +0000190
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000191 iterator find(const String& name);
loislo@chromium.org12044a82010-08-23 14:07:09 +0000192 const_iterator find(const String& name) const;
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000193
194 // FIXME: use templates to reduce the amount of duplicated get*() methods.
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000195 bool getBoolean(const String& name, bool& output) const;
196 template<class T> bool getDouble(const String& name, T& output) const
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000197 {
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000198 RefPtr<InspectorValue> value;
199 if (!getValue(name, value))
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000200 return false;
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000201
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000202 return value->asDouble(output);
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000203 }
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000204 template<class T> bool getInteger(const String& name, T& output) const
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000205 {
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000206 RefPtr<InspectorValue> value;
207 if (!getValue(name, value))
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000208 return false;
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000209
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000210 return value->asInteger(output);
211 }
212
burg@cs.washington.eduba2d1032014-09-30 03:30:54 +0000213 bool getString(const String& name, String& output) const;
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000214 bool getObject(const String& name, RefPtr<InspectorObject>&) const;
215 bool getArray(const String& name, RefPtr<InspectorArray>&) const;
216 bool getValue(const String& name, RefPtr<InspectorValue>&) const;
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000217
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000218 void remove(const String& name);
219
darin@apple.com11ff47c2016-03-04 16:47:55 +0000220 void writeJSON(StringBuilder& output) const override;
eric@webkit.org43974b62010-05-31 22:28:30 +0000221
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000222 iterator begin() { return m_map.begin(); }
223 iterator end() { return m_map.end(); }
224 const_iterator begin() const { return m_map.begin(); }
225 const_iterator end() const { return m_map.end(); }
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000226
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000227 int size() const { return m_map.size(); }
yurys@chromium.orga13f46b2012-01-25 11:54:51 +0000228
yurys@chromium.org26c45922011-12-09 08:33:02 +0000229protected:
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000230 InspectorObjectBase();
yurys@chromium.org26c45922011-12-09 08:33:02 +0000231
232private:
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000233 Dictionary m_map;
loislo@chromium.org4bfbcc12010-06-04 17:23:10 +0000234 Vector<String> m_order;
eric@webkit.org43974b62010-05-31 22:28:30 +0000235};
236
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000237class InspectorObject : public InspectorObjectBase {
238public:
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000239 static JS_EXPORT_PRIVATE Ref<InspectorObject> create();
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000240
241 using InspectorObjectBase::asObject;
242
drousso@apple.comb0d5aef2017-07-18 20:21:31 +0000243 // This class expected non-cyclic values, as we cannot serialize cycles in JSON.
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000244 using InspectorObjectBase::setBoolean;
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000245 using InspectorObjectBase::setInteger;
246 using InspectorObjectBase::setDouble;
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000247 using InspectorObjectBase::setString;
248 using InspectorObjectBase::setValue;
249 using InspectorObjectBase::setObject;
250 using InspectorObjectBase::setArray;
251
252 using InspectorObjectBase::find;
253 using InspectorObjectBase::getBoolean;
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000254 using InspectorObjectBase::getInteger;
255 using InspectorObjectBase::getDouble;
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000256 using InspectorObjectBase::getString;
257 using InspectorObjectBase::getObject;
258 using InspectorObjectBase::getArray;
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000259 using InspectorObjectBase::getValue;
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000260
261 using InspectorObjectBase::remove;
262
263 using InspectorObjectBase::begin;
264 using InspectorObjectBase::end;
265
266 using InspectorObjectBase::size;
267};
268
269
joepeck@webkit.orga3198442013-12-11 22:40:23 +0000270class JS_EXPORT_PRIVATE InspectorArrayBase : public InspectorValue {
eric@webkit.org43974b62010-05-31 22:28:30 +0000271public:
andersca@apple.comc3523f82013-10-18 23:41:24 +0000272 typedef Vector<RefPtr<InspectorValue>>::iterator iterator;
273 typedef Vector<RefPtr<InspectorValue>>::const_iterator const_iterator;
pfeldman@chromium.org2f44edb2011-11-29 14:43:10 +0000274
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000275 unsigned length() const { return static_cast<unsigned>(m_map.size()); }
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000276
drousso@apple.comb9f22de2017-07-26 21:45:22 +0000277 RefPtr<InspectorValue> get(size_t index) const;
278
drousso@apple.comb0d5aef2017-07-18 20:21:31 +0000279 size_t memoryCost() const final;
280
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000281protected:
andersca@apple.com70c60582013-10-07 16:26:16 +0000282 virtual ~InspectorArrayBase();
eric@webkit.org43974b62010-05-31 22:28:30 +0000283
darin@apple.com11ff47c2016-03-04 16:47:55 +0000284 bool asArray(RefPtr<InspectorArray>&) override;
eric@webkit.orgd82076b52010-06-07 11:33:11 +0000285
loislo@chromium.orgec5ebeb2010-08-26 13:11:28 +0000286 void pushBoolean(bool);
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000287 void pushInteger(int);
288 void pushDouble(double);
eric@webkit.org43974b62010-05-31 22:28:30 +0000289 void pushString(const String&);
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000290 void pushValue(RefPtr<InspectorValue>&&);
291 void pushObject(RefPtr<InspectorObjectBase>&&);
292 void pushArray(RefPtr<InspectorArrayBase>&&);
loislo@chromium.org52486552010-07-16 17:16:56 +0000293
darin@apple.com11ff47c2016-03-04 16:47:55 +0000294 void writeJSON(StringBuilder& output) const override;
eric@webkit.org43974b62010-05-31 22:28:30 +0000295
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000296 iterator begin() { return m_map.begin(); }
297 iterator end() { return m_map.end(); }
298 const_iterator begin() const { return m_map.begin(); }
299 const_iterator end() const { return m_map.end(); }
pfeldman@chromium.org2f44edb2011-11-29 14:43:10 +0000300
commit-queue@webkit.org2191c912012-01-16 13:44:14 +0000301protected:
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000302 InspectorArrayBase();
commit-queue@webkit.org2191c912012-01-16 13:44:14 +0000303
304private:
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000305 Vector<RefPtr<InspectorValue>> m_map;
eric@webkit.org43974b62010-05-31 22:28:30 +0000306};
307
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000308class InspectorArray : public InspectorArrayBase {
309public:
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000310 static JS_EXPORT_PRIVATE Ref<InspectorArray> create();
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000311
312 using InspectorArrayBase::asArray;
313
drousso@apple.comb0d5aef2017-07-18 20:21:31 +0000314 // This class expected non-cyclic values, as we cannot serialize cycles in JSON.
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000315 using InspectorArrayBase::pushBoolean;
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000316 using InspectorArrayBase::pushInteger;
317 using InspectorArrayBase::pushDouble;
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000318 using InspectorArrayBase::pushString;
319 using InspectorArrayBase::pushValue;
320 using InspectorArrayBase::pushObject;
321 using InspectorArrayBase::pushArray;
322
323 using InspectorArrayBase::get;
324
325 using InspectorArrayBase::begin;
326 using InspectorArrayBase::end;
327};
328
329
330inline InspectorObjectBase::iterator InspectorObjectBase::find(const String& name)
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000331{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000332 return m_map.find(name);
podivilov@chromium.orgba4a88c2011-02-03 15:24:41 +0000333}
334
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000335inline InspectorObjectBase::const_iterator InspectorObjectBase::find(const String& name) const
loislo@chromium.org12044a82010-08-23 14:07:09 +0000336{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000337 return m_map.find(name);
loislo@chromium.org12044a82010-08-23 14:07:09 +0000338}
339
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000340inline void InspectorObjectBase::setBoolean(const String& name, bool value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000341{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000342 setValue(name, InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000343}
344
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000345inline void InspectorObjectBase::setInteger(const String& name, int value)
346{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000347 setValue(name, InspectorValue::create(value));
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000348}
349
350inline void InspectorObjectBase::setDouble(const String& name, double value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000351{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000352 setValue(name, InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000353}
354
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000355inline void InspectorObjectBase::setString(const String& name, const String& value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000356{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000357 setValue(name, InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000358}
359
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000360inline void InspectorObjectBase::setValue(const String& name, RefPtr<InspectorValue>&& value)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000361{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000362 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000363 if (m_map.set(name, WTFMove(value)).isNewEntry)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000364 m_order.append(name);
365}
366
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000367inline void InspectorObjectBase::setObject(const String& name, RefPtr<InspectorObjectBase>&& value)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000368{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000369 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000370 if (m_map.set(name, WTFMove(value)).isNewEntry)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000371 m_order.append(name);
372}
373
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000374inline void InspectorObjectBase::setArray(const String& name, RefPtr<InspectorArrayBase>&& value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000375{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000376 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000377 if (m_map.set(name, WTFMove(value)).isNewEntry)
loislo@chromium.org4bfbcc12010-06-04 17:23:10 +0000378 m_order.append(name);
eric@webkit.org43974b62010-05-31 22:28:30 +0000379}
380
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000381inline void InspectorArrayBase::pushBoolean(bool value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000382{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000383 m_map.append(InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000384}
385
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000386inline void InspectorArrayBase::pushInteger(int value)
vsevik@chromium.org73861122012-03-28 19:44:57 +0000387{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000388 m_map.append(InspectorValue::create(value));
vsevik@chromium.org73861122012-03-28 19:44:57 +0000389}
390
burg@cs.washington.edu68ca4db2014-09-12 04:53:35 +0000391inline void InspectorArrayBase::pushDouble(double value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000392{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000393 m_map.append(InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000394}
395
commit-queue@webkit.org118a87a2012-04-10 22:39:39 +0000396inline void InspectorArrayBase::pushString(const String& value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000397{
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000398 m_map.append(InspectorValue::create(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000399}
400
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000401inline void InspectorArrayBase::pushValue(RefPtr<InspectorValue>&& value)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000402{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000403 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000404 m_map.append(WTFMove(value));
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000405}
406
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000407inline void InspectorArrayBase::pushObject(RefPtr<InspectorObjectBase>&& value)
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000408{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000409 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000410 m_map.append(WTFMove(value));
pfeldman@chromium.org7fab0972010-08-13 13:22:17 +0000411}
412
joepeck@webkit.org9f378ef2015-01-07 23:29:03 +0000413inline void InspectorArrayBase::pushArray(RefPtr<InspectorArrayBase>&& value)
eric@webkit.org43974b62010-05-31 22:28:30 +0000414{
pfeldman@chromium.org6537d932011-11-09 11:49:13 +0000415 ASSERT(value);
bburg@apple.com3e2abaa2016-04-11 23:22:16 +0000416 m_map.append(WTFMove(value));
eric@webkit.org43974b62010-05-31 22:28:30 +0000417}
418
joepeck@webkit.orga3198442013-12-11 22:40:23 +0000419} // namespace Inspector