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

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

Issue 2151083002: DevTools: explicitly differentiate ints vs doubles in the protocol bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean 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 Array_h 5 #ifndef Array_h
6 #define Array_h 6 #define Array_h
7 7
8 #include "platform/inspector_protocol/ErrorSupport.h" 8 #include "platform/inspector_protocol/ErrorSupport.h"
9 #include "platform/inspector_protocol/Platform.h" 9 #include "platform/inspector_protocol/Platform.h"
10 #include "platform/inspector_protocol/String16.h" 10 #include "platform/inspector_protocol/String16.h"
(...skipping 16 matching lines...) Expand all
27 static std::unique_ptr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors) 27 static std::unique_ptr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors)
28 { 28 {
29 protocol::ListValue* array = ListValue::cast(value); 29 protocol::ListValue* array = ListValue::cast(value);
30 if (!array) { 30 if (!array) {
31 errors->addError("array expected"); 31 errors->addError("array expected");
32 return nullptr; 32 return nullptr;
33 } 33 }
34 errors->push(); 34 errors->push();
35 std::unique_ptr<Array<T>> result(new Array<T>()); 35 std::unique_ptr<Array<T>> result(new Array<T>());
36 for (size_t i = 0; i < array->size(); ++i) { 36 for (size_t i = 0; i < array->size(); ++i) {
37 errors->setName(String16::number(i)); 37 errors->setName(String16::fromInteger(i));
38 T item = FromValue<T>::parse(array->at(i), errors); 38 T item = FromValue<T>::parse(array->at(i), errors);
39 result->m_vector.push_back(item); 39 result->m_vector.push_back(item);
40 } 40 }
41 errors->pop(); 41 errors->pop();
42 if (errors->hasErrors()) 42 if (errors->hasErrors())
43 return nullptr; 43 return nullptr;
44 return result; 44 return result;
45 } 45 }
46 46
47 void addItem(const T& value) 47 void addItem(const T& value)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 static std::unique_ptr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors) 88 static std::unique_ptr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors)
89 { 89 {
90 protocol::ListValue* array = ListValue::cast(value); 90 protocol::ListValue* array = ListValue::cast(value);
91 if (!array) { 91 if (!array) {
92 errors->addError("array expected"); 92 errors->addError("array expected");
93 return nullptr; 93 return nullptr;
94 } 94 }
95 std::unique_ptr<Array<T>> result(new Array<T>()); 95 std::unique_ptr<Array<T>> result(new Array<T>());
96 errors->push(); 96 errors->push();
97 for (size_t i = 0; i < array->size(); ++i) { 97 for (size_t i = 0; i < array->size(); ++i) {
98 errors->setName(String16::number(i)); 98 errors->setName(String16::fromInteger(i));
99 std::unique_ptr<T> item = FromValue<T>::parse(array->at(i), errors); 99 std::unique_ptr<T> item = FromValue<T>::parse(array->at(i), errors);
100 result->m_vector.push_back(std::move(item)); 100 result->m_vector.push_back(std::move(item));
101 } 101 }
102 errors->pop(); 102 errors->pop();
103 if (errors->hasErrors()) 103 if (errors->hasErrors())
104 return nullptr; 104 return nullptr;
105 return result; 105 return result;
106 } 106 }
107 107
108 void addItem(std::unique_ptr<T> value) 108 void addItem(std::unique_ptr<T> value)
(...skipping 20 matching lines...) Expand all
129 } 129 }
130 130
131 private: 131 private:
132 std::vector<std::unique_ptr<T>> m_vector; 132 std::vector<std::unique_ptr<T>> m_vector;
133 }; 133 };
134 134
135 } // namespace platform 135 } // namespace platform
136 } // namespace blink 136 } // namespace blink
137 137
138 #endif // !defined(Array_h) 138 #endif // !defined(Array_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698