Index: third_party/WebKit/Source/platform/inspector_protocol/Array.h |
diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Array.h b/third_party/WebKit/Source/platform/inspector_protocol/Array.h |
index d92af3a5ed7d05259a52304c5f86a6f407cdda82..720182258b953366ca8ef8fc62342debc380733b 100644 |
--- a/third_party/WebKit/Source/platform/inspector_protocol/Array.h |
+++ b/third_party/WebKit/Source/platform/inspector_protocol/Array.h |
@@ -17,7 +17,7 @@ namespace blink { |
namespace protocol { |
template<typename T> |
-class ArrayBase { |
+class Array { |
public: |
static std::unique_ptr<Array<T>> create() |
{ |
@@ -31,12 +31,12 @@ public: |
errors->addError("array expected"); |
return nullptr; |
} |
- errors->push(); |
std::unique_ptr<Array<T>> result(new Array<T>()); |
+ errors->push(); |
for (size_t i = 0; i < array->size(); ++i) { |
errors->setName(String16::fromInteger(i)); |
- T item = FromValue<T>::parse(array->at(i), errors); |
- result->m_vector.push_back(item); |
+ std::unique_ptr<T> item = ValueConversions<T>::parse(array->at(i), errors); |
+ result->m_vector.push_back(std::move(item)); |
} |
errors->pop(); |
if (errors->hasErrors()) |
@@ -44,9 +44,9 @@ public: |
return result; |
} |
- void addItem(const T& value) |
+ void addItem(std::unique_ptr<T> value) |
{ |
- m_vector.push_back(value); |
+ m_vector.push_back(std::move(value)); |
} |
size_t length() |
@@ -54,31 +54,25 @@ public: |
return m_vector.size(); |
} |
- T get(size_t index) |
+ T* get(size_t index) |
{ |
- return m_vector[index]; |
+ return m_vector[index].get(); |
} |
std::unique_ptr<protocol::ListValue> serialize() |
{ |
std::unique_ptr<protocol::ListValue> result = ListValue::create(); |
for (auto& item : m_vector) |
- result->pushValue(toValue(item)); |
+ result->pushValue(ValueConversions<T>::serialize(item)); |
return result; |
} |
private: |
- std::vector<T> m_vector; |
+ std::vector<std::unique_ptr<T>> m_vector; |
}; |
-template<> class Array<String> : public ArrayBase<String> {}; |
-template<> class Array<String16> : public ArrayBase<String16> {}; |
-template<> class Array<int> : public ArrayBase<int> {}; |
-template<> class Array<double> : public ArrayBase<double> {}; |
-template<> class Array<bool> : public ArrayBase<bool> {}; |
- |
template<typename T> |
-class Array { |
+class ArrayBase { |
public: |
static std::unique_ptr<Array<T>> create() |
{ |
@@ -92,12 +86,12 @@ public: |
errors->addError("array expected"); |
return nullptr; |
} |
- std::unique_ptr<Array<T>> result(new Array<T>()); |
errors->push(); |
+ std::unique_ptr<Array<T>> result(new Array<T>()); |
for (size_t i = 0; i < array->size(); ++i) { |
errors->setName(String16::fromInteger(i)); |
- std::unique_ptr<T> item = FromValue<T>::parse(array->at(i), errors); |
- result->m_vector.push_back(std::move(item)); |
+ T item = ValueConversions<T>::parse(array->at(i), errors); |
+ result->m_vector.push_back(item); |
} |
errors->pop(); |
if (errors->hasErrors()) |
@@ -105,9 +99,9 @@ public: |
return result; |
} |
- void addItem(std::unique_ptr<T> value) |
+ void addItem(const T& value) |
{ |
- m_vector.push_back(std::move(value)); |
+ m_vector.push_back(value); |
} |
size_t length() |
@@ -115,23 +109,29 @@ public: |
return m_vector.size(); |
} |
- T* get(size_t index) |
+ T get(size_t index) |
{ |
- return m_vector[index].get(); |
+ return m_vector[index]; |
} |
std::unique_ptr<protocol::ListValue> serialize() |
{ |
std::unique_ptr<protocol::ListValue> result = ListValue::create(); |
for (auto& item : m_vector) |
- result->pushValue(toValue(item)); |
+ result->pushValue(ValueConversions<T>::serialize(item)); |
return result; |
} |
private: |
- std::vector<std::unique_ptr<T>> m_vector; |
+ std::vector<T> m_vector; |
}; |
+template<> class Array<String> : public ArrayBase<String> {}; |
+template<> class Array<String16> : public ArrayBase<String16> {}; |
+template<> class Array<int> : public ArrayBase<int> {}; |
+template<> class Array<double> : public ArrayBase<double> {}; |
+template<> class Array<bool> : public ArrayBase<bool> {}; |
+ |
} // namespace platform |
} // namespace blink |