Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Values.h

Issue 2087953004: Switch v8 inspector to stl collections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Values_h 5 #ifndef Values_h
6 #define Values_h 6 #define Values_h
7 7
8 #include "platform/inspector_protocol/Allocator.h" 8 #include "platform/inspector_protocol/Allocator.h"
9 #include "platform/inspector_protocol/Collections.h" 9 #include "platform/inspector_protocol/Collections.h"
10 #include "platform/inspector_protocol/Platform.h" 10 #include "platform/inspector_protocol/Platform.h"
11 #include "platform/inspector_protocol/String16.h" 11 #include "platform/inspector_protocol/String16.h"
12 12
13 #include <vector>
14
13 namespace blink { 15 namespace blink {
14 namespace protocol { 16 namespace protocol {
15 17
16 class ListValue; 18 class ListValue;
17 class DictionaryValue; 19 class DictionaryValue;
18 class Value; 20 class Value;
19 21
20 class PLATFORM_EXPORT Value { 22 class PLATFORM_EXPORT Value {
21 PROTOCOL_DISALLOW_COPY(Value); 23 PROTOCOL_DISALLOW_COPY(Value);
22 public: 24 public:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 Entry at(size_t index) const; 169 Entry at(size_t index) const;
168 170
169 bool booleanProperty(const String16& name, bool defaultValue) const; 171 bool booleanProperty(const String16& name, bool defaultValue) const;
170 double numberProperty(const String16& name, double defaultValue) const; 172 double numberProperty(const String16& name, double defaultValue) const;
171 void remove(const String16& name); 173 void remove(const String16& name);
172 174
173 ~DictionaryValue() override; 175 ~DictionaryValue() override;
174 176
175 private: 177 private:
176 DictionaryValue(); 178 DictionaryValue();
179 template<typename T>
180 void set(const String16& key, std::unique_ptr<T>& value)
181 {
182 DCHECK(value);
183 bool isNew = m_data.find(key) == m_data.end();
184 m_data[key] = std::move(value);
185 if (isNew)
186 m_order.push_back(key);
187 }
177 188
178 using Dictionary = protocol::HashMap<String16, std::unique_ptr<Value>>; 189 using Dictionary = protocol::HashMap<String16, std::unique_ptr<Value>>;
179 Dictionary m_data; 190 Dictionary m_data;
180 protocol::Vector<String16> m_order; 191 std::vector<String16> m_order;
181 }; 192 };
182 193
183 class PLATFORM_EXPORT ListValue : public Value { 194 class PLATFORM_EXPORT ListValue : public Value {
184 public: 195 public:
185 static std::unique_ptr<ListValue> create() 196 static std::unique_ptr<ListValue> create()
186 { 197 {
187 return wrapUnique(new ListValue()); 198 return wrapUnique(new ListValue());
188 } 199 }
189 200
190 static ListValue* cast(Value* value) 201 static ListValue* cast(Value* value)
(...skipping 13 matching lines...) Expand all
204 void writeJSON(String16Builder* output) const override; 215 void writeJSON(String16Builder* output) const override;
205 std::unique_ptr<Value> clone() const override; 216 std::unique_ptr<Value> clone() const override;
206 217
207 void pushValue(std::unique_ptr<Value>); 218 void pushValue(std::unique_ptr<Value>);
208 219
209 Value* at(size_t index); 220 Value* at(size_t index);
210 size_t size() const { return m_data.size(); } 221 size_t size() const { return m_data.size(); }
211 222
212 private: 223 private:
213 ListValue(); 224 ListValue();
214 protocol::Vector<std::unique_ptr<Value>> m_data; 225 std::vector<std::unique_ptr<Value>> m_data;
215 }; 226 };
216 227
217 } // namespace protocol 228 } // namespace protocol
218 } // namespace blink 229 } // namespace blink
219 230
220 #endif // Values_h 231 #endif // Values_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698