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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp

Issue 1979963002: Remove OwnPtr::release() calls in platform/ (part inspector). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 #include "platform/inspector_protocol/Parser.h" 5 #include "platform/inspector_protocol/Parser.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 break; 394 break;
395 } 395 }
396 case ArrayBegin: { 396 case ArrayBegin: {
397 OwnPtr<ListValue> array = ListValue::create(); 397 OwnPtr<ListValue> array = ListValue::create();
398 start = tokenEnd; 398 start = tokenEnd;
399 token = parseToken(start, end, &tokenStart, &tokenEnd); 399 token = parseToken(start, end, &tokenStart, &tokenEnd);
400 while (token != ArrayEnd) { 400 while (token != ArrayEnd) {
401 OwnPtr<Value> arrayNode = buildValue(start, end, &tokenEnd, depth + 1); 401 OwnPtr<Value> arrayNode = buildValue(start, end, &tokenEnd, depth + 1);
402 if (!arrayNode) 402 if (!arrayNode)
403 return nullptr; 403 return nullptr;
404 array->pushValue(arrayNode.release()); 404 array->pushValue(std::move(arrayNode));
405 405
406 // After a list value, we expect a comma or the end of the list. 406 // After a list value, we expect a comma or the end of the list.
407 start = tokenEnd; 407 start = tokenEnd;
408 token = parseToken(start, end, &tokenStart, &tokenEnd); 408 token = parseToken(start, end, &tokenStart, &tokenEnd);
409 if (token == ListSeparator) { 409 if (token == ListSeparator) {
410 start = tokenEnd; 410 start = tokenEnd;
411 token = parseToken(start, end, &tokenStart, &tokenEnd); 411 token = parseToken(start, end, &tokenStart, &tokenEnd);
412 if (token == ArrayEnd) 412 if (token == ArrayEnd)
413 return nullptr; 413 return nullptr;
414 } else if (token != ArrayEnd) { 414 } else if (token != ArrayEnd) {
415 // Unexpected value after list value. Bail out. 415 // Unexpected value after list value. Bail out.
416 return nullptr; 416 return nullptr;
417 } 417 }
418 } 418 }
419 if (token != ArrayEnd) 419 if (token != ArrayEnd)
420 return nullptr; 420 return nullptr;
421 result = array.release(); 421 result = std::move(array);
422 break; 422 break;
423 } 423 }
424 case ObjectBegin: { 424 case ObjectBegin: {
425 OwnPtr<DictionaryValue> object = DictionaryValue::create(); 425 OwnPtr<DictionaryValue> object = DictionaryValue::create();
426 start = tokenEnd; 426 start = tokenEnd;
427 token = parseToken(start, end, &tokenStart, &tokenEnd); 427 token = parseToken(start, end, &tokenStart, &tokenEnd);
428 while (token != ObjectEnd) { 428 while (token != ObjectEnd) {
429 if (token != StringLiteral) 429 if (token != StringLiteral)
430 return nullptr; 430 return nullptr;
431 String16 key; 431 String16 key;
432 if (!decodeString(tokenStart + 1, tokenEnd - 1, &key)) 432 if (!decodeString(tokenStart + 1, tokenEnd - 1, &key))
433 return nullptr; 433 return nullptr;
434 start = tokenEnd; 434 start = tokenEnd;
435 435
436 token = parseToken(start, end, &tokenStart, &tokenEnd); 436 token = parseToken(start, end, &tokenStart, &tokenEnd);
437 if (token != ObjectPairSeparator) 437 if (token != ObjectPairSeparator)
438 return nullptr; 438 return nullptr;
439 start = tokenEnd; 439 start = tokenEnd;
440 440
441 OwnPtr<Value> value = buildValue(start, end, &tokenEnd, depth + 1); 441 OwnPtr<Value> value = buildValue(start, end, &tokenEnd, depth + 1);
442 if (!value) 442 if (!value)
443 return nullptr; 443 return nullptr;
444 object->setValue(key, value.release()); 444 object->setValue(key, std::move(value));
445 start = tokenEnd; 445 start = tokenEnd;
446 446
447 // After a key/value pair, we expect a comma or the end of the 447 // After a key/value pair, we expect a comma or the end of the
448 // object. 448 // object.
449 token = parseToken(start, end, &tokenStart, &tokenEnd); 449 token = parseToken(start, end, &tokenStart, &tokenEnd);
450 if (token == ListSeparator) { 450 if (token == ListSeparator) {
451 start = tokenEnd; 451 start = tokenEnd;
452 token = parseToken(start, end, &tokenStart, &tokenEnd); 452 token = parseToken(start, end, &tokenStart, &tokenEnd);
453 if (token == ObjectEnd) 453 if (token == ObjectEnd)
454 return nullptr; 454 return nullptr;
455 } else if (token != ObjectEnd) { 455 } else if (token != ObjectEnd) {
456 // Unexpected value after last object value. Bail out. 456 // Unexpected value after last object value. Bail out.
457 return nullptr; 457 return nullptr;
458 } 458 }
459 } 459 }
460 if (token != ObjectEnd) 460 if (token != ObjectEnd)
461 return nullptr; 461 return nullptr;
462 result = object.release(); 462 result = std::move(object);
463 break; 463 break;
464 } 464 }
465 465
466 default: 466 default:
467 // We got a token that's not a value. 467 // We got a token that's not a value.
468 return nullptr; 468 return nullptr;
469 } 469 }
470 470
471 skipWhitespaceAndComments(tokenEnd, end, valueTokenEnd); 471 skipWhitespaceAndComments(tokenEnd, end, valueTokenEnd);
472 return result.release(); 472 return result;
473 } 473 }
474 474
475 PassOwnPtr<Value> parseJSONInternal(const UChar* start, unsigned length) 475 PassOwnPtr<Value> parseJSONInternal(const UChar* start, unsigned length)
476 { 476 {
477 const UChar* end = start + length; 477 const UChar* end = start + length;
478 const UChar *tokenEnd; 478 const UChar *tokenEnd;
479 OwnPtr<Value> value = buildValue(start, end, &tokenEnd, 0); 479 OwnPtr<Value> value = buildValue(start, end, &tokenEnd, 0);
480 if (!value || tokenEnd != end) 480 if (!value || tokenEnd != end)
481 return nullptr; 481 return nullptr;
482 return value.release(); 482 return value;
483 } 483 }
484 484
485 } // anonymous namespace 485 } // anonymous namespace
486 486
487 PassOwnPtr<Value> parseJSON(const String16& json) 487 PassOwnPtr<Value> parseJSON(const String16& json)
488 { 488 {
489 if (json.isEmpty()) 489 if (json.isEmpty())
490 return nullptr; 490 return nullptr;
491 return parseJSONInternal(json.characters16(), json.length()); 491 return parseJSONInternal(json.characters16(), json.length());
492 } 492 }
493 493
494 } // namespace protocol 494 } // namespace protocol
495 } // namespace blink 495 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698