OLD | NEW |
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 #include "platform/inspector_protocol/Values.h" | 5 #include "platform/inspector_protocol/Values.h" |
6 | 6 |
7 #include "platform/inspector_protocol/Parser.h" | 7 #include "platform/inspector_protocol/Parser.h" |
8 #include "platform/inspector_protocol/String16.h" | 8 #include "platform/inspector_protocol/String16.h" |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 294 |
295 PassOwnPtr<Value> DictionaryValue::clone() const | 295 PassOwnPtr<Value> DictionaryValue::clone() const |
296 { | 296 { |
297 OwnPtr<DictionaryValue> result = DictionaryValue::create(); | 297 OwnPtr<DictionaryValue> result = DictionaryValue::create(); |
298 for (size_t i = 0; i < m_order.size(); ++i) { | 298 for (size_t i = 0; i < m_order.size(); ++i) { |
299 String16 key = m_order[i]; | 299 String16 key = m_order[i]; |
300 Value* value = m_data.get(key); | 300 Value* value = m_data.get(key); |
301 ASSERT(value); | 301 ASSERT(value); |
302 result->setValue(key, value->clone()); | 302 result->setValue(key, value->clone()); |
303 } | 303 } |
304 return result.release(); | 304 return std::move(result); |
305 } | 305 } |
306 | 306 |
307 DictionaryValue::DictionaryValue() | 307 DictionaryValue::DictionaryValue() |
308 : Value(TypeObject) | 308 : Value(TypeObject) |
309 { | 309 { |
310 } | 310 } |
311 | 311 |
312 ListValue::~ListValue() | 312 ListValue::~ListValue() |
313 { | 313 { |
314 } | 314 } |
315 | 315 |
316 void ListValue::writeJSON(String16Builder* output) const | 316 void ListValue::writeJSON(String16Builder* output) const |
317 { | 317 { |
318 output->append('['); | 318 output->append('['); |
319 for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it
!= m_data.end(); ++it) { | 319 for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it
!= m_data.end(); ++it) { |
320 if (it != m_data.begin()) | 320 if (it != m_data.begin()) |
321 output->append(','); | 321 output->append(','); |
322 (*it)->writeJSON(output); | 322 (*it)->writeJSON(output); |
323 } | 323 } |
324 output->append(']'); | 324 output->append(']'); |
325 } | 325 } |
326 | 326 |
327 PassOwnPtr<Value> ListValue::clone() const | 327 PassOwnPtr<Value> ListValue::clone() const |
328 { | 328 { |
329 OwnPtr<ListValue> result = ListValue::create(); | 329 OwnPtr<ListValue> result = ListValue::create(); |
330 for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it
!= m_data.end(); ++it) | 330 for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it
!= m_data.end(); ++it) |
331 result->pushValue((*it)->clone()); | 331 result->pushValue((*it)->clone()); |
332 return result.release(); | 332 return std::move(result); |
333 } | 333 } |
334 | 334 |
335 ListValue::ListValue() | 335 ListValue::ListValue() |
336 : Value(TypeArray) | 336 : Value(TypeArray) |
337 { | 337 { |
338 } | 338 } |
339 | 339 |
340 void ListValue::pushValue(PassOwnPtr<protocol::Value> value) | 340 void ListValue::pushValue(PassOwnPtr<protocol::Value> value) |
341 { | 341 { |
342 ASSERT(value); | 342 ASSERT(value); |
343 m_data.append(std::move(value)); | 343 m_data.append(std::move(value)); |
344 } | 344 } |
345 | 345 |
346 protocol::Value* ListValue::at(size_t index) | 346 protocol::Value* ListValue::at(size_t index) |
347 { | 347 { |
348 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); | 348 ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); |
349 return m_data[index].get(); | 349 return m_data[index].get(); |
350 } | 350 } |
351 | 351 |
352 } // namespace protocol | 352 } // namespace protocol |
353 } // namespace blink | 353 } // namespace blink |
OLD | NEW |