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

Side by Side Diff: google_apis/drive/drive_api_parser.cc

Issue 1873663002: Convert //google_apis from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "google_apis/drive/drive_api_parser.h" 5 #include "google_apis/drive/drive_api_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10
9 #include "base/json/json_value_converter.h" 11 #include "base/json/json_value_converter.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "google_apis/drive/time_util.h" 17 #include "google_apis/drive/time_util.h"
17 18
18 namespace google_apis { 19 namespace google_apis {
19 20
20 namespace { 21 namespace {
21 22
22 const int64_t kUnsetFileSize = -1; 23 const int64_t kUnsetFileSize = -1;
23 24
24 bool CreateFileResourceFromValue(const base::Value* value, 25 bool CreateFileResourceFromValue(const base::Value* value,
25 scoped_ptr<FileResource>* file) { 26 std::unique_ptr<FileResource>* file) {
26 *file = FileResource::CreateFrom(*value); 27 *file = FileResource::CreateFrom(*value);
27 return !!*file; 28 return !!*file;
28 } 29 }
29 30
30 // Converts |url_string| to |result|. Always returns true to be used 31 // Converts |url_string| to |result|. Always returns true to be used
31 // for JSONValueConverter::RegisterCustomField method. 32 // for JSONValueConverter::RegisterCustomField method.
32 // TODO(mukai): make it return false in case of invalid |url_string|. 33 // TODO(mukai): make it return false in case of invalid |url_string|.
33 bool GetGURLFromString(const base::StringPiece& url_string, GURL* result) { 34 bool GetGURLFromString(const base::StringPiece& url_string, GURL* result) {
34 *result = GURL(url_string.as_string()); 35 *result = GURL(url_string.as_string());
35 return true; 36 return true;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // AboutResource implementation 210 // AboutResource implementation
210 211
211 AboutResource::AboutResource() 212 AboutResource::AboutResource()
212 : largest_change_id_(0), 213 : largest_change_id_(0),
213 quota_bytes_total_(0), 214 quota_bytes_total_(0),
214 quota_bytes_used_aggregate_(0) {} 215 quota_bytes_used_aggregate_(0) {}
215 216
216 AboutResource::~AboutResource() {} 217 AboutResource::~AboutResource() {}
217 218
218 // static 219 // static
219 scoped_ptr<AboutResource> AboutResource::CreateFrom(const base::Value& value) { 220 std::unique_ptr<AboutResource> AboutResource::CreateFrom(
220 scoped_ptr<AboutResource> resource(new AboutResource()); 221 const base::Value& value) {
222 std::unique_ptr<AboutResource> resource(new AboutResource());
221 if (!IsResourceKindExpected(value, kAboutKind) || !resource->Parse(value)) { 223 if (!IsResourceKindExpected(value, kAboutKind) || !resource->Parse(value)) {
222 LOG(ERROR) << "Unable to create: Invalid About resource JSON!"; 224 LOG(ERROR) << "Unable to create: Invalid About resource JSON!";
223 return scoped_ptr<AboutResource>(); 225 return std::unique_ptr<AboutResource>();
224 } 226 }
225 return resource; 227 return resource;
226 } 228 }
227 229
228 // static 230 // static
229 void AboutResource::RegisterJSONConverter( 231 void AboutResource::RegisterJSONConverter(
230 base::JSONValueConverter<AboutResource>* converter) { 232 base::JSONValueConverter<AboutResource>* converter) {
231 converter->RegisterCustomField<int64_t>(kLargestChangeId, 233 converter->RegisterCustomField<int64_t>(kLargestChangeId,
232 &AboutResource::largest_change_id_, 234 &AboutResource::largest_change_id_,
233 &base::StringToInt64); 235 &base::StringToInt64);
(...skipping 30 matching lines...) Expand all
264 kCategory, 266 kCategory,
265 &DriveAppIcon::category_, 267 &DriveAppIcon::category_,
266 &DriveAppIcon::GetIconCategory); 268 &DriveAppIcon::GetIconCategory);
267 converter->RegisterIntField(kSize, &DriveAppIcon::icon_side_length_); 269 converter->RegisterIntField(kSize, &DriveAppIcon::icon_side_length_);
268 converter->RegisterCustomField<GURL>(kIconUrl, 270 converter->RegisterCustomField<GURL>(kIconUrl,
269 &DriveAppIcon::icon_url_, 271 &DriveAppIcon::icon_url_,
270 GetGURLFromString); 272 GetGURLFromString);
271 } 273 }
272 274
273 // static 275 // static
274 scoped_ptr<DriveAppIcon> DriveAppIcon::CreateFrom(const base::Value& value) { 276 std::unique_ptr<DriveAppIcon> DriveAppIcon::CreateFrom(
275 scoped_ptr<DriveAppIcon> resource(new DriveAppIcon()); 277 const base::Value& value) {
278 std::unique_ptr<DriveAppIcon> resource(new DriveAppIcon());
276 if (!resource->Parse(value)) { 279 if (!resource->Parse(value)) {
277 LOG(ERROR) << "Unable to create: Invalid DriveAppIcon JSON!"; 280 LOG(ERROR) << "Unable to create: Invalid DriveAppIcon JSON!";
278 return scoped_ptr<DriveAppIcon>(); 281 return std::unique_ptr<DriveAppIcon>();
279 } 282 }
280 return resource; 283 return resource;
281 } 284 }
282 285
283 bool DriveAppIcon::Parse(const base::Value& value) { 286 bool DriveAppIcon::Parse(const base::Value& value) {
284 base::JSONValueConverter<DriveAppIcon> converter; 287 base::JSONValueConverter<DriveAppIcon> converter;
285 if (!converter.Convert(value, this)) { 288 if (!converter.Convert(value, this)) {
286 LOG(ERROR) << "Unable to parse: Invalid DriveAppIcon"; 289 LOG(ERROR) << "Unable to parse: Invalid DriveAppIcon";
287 return false; 290 return false;
288 } 291 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 &AppResource::primary_file_extensions_); 332 &AppResource::primary_file_extensions_);
330 converter->RegisterRepeatedString(kSecondaryFileExtensions, 333 converter->RegisterRepeatedString(kSecondaryFileExtensions,
331 &AppResource::secondary_file_extensions_); 334 &AppResource::secondary_file_extensions_);
332 converter->RegisterRepeatedMessage(kIcons, &AppResource::icons_); 335 converter->RegisterRepeatedMessage(kIcons, &AppResource::icons_);
333 converter->RegisterCustomField<GURL>(kCreateUrl, 336 converter->RegisterCustomField<GURL>(kCreateUrl,
334 &AppResource::create_url_, 337 &AppResource::create_url_,
335 GetGURLFromString); 338 GetGURLFromString);
336 } 339 }
337 340
338 // static 341 // static
339 scoped_ptr<AppResource> AppResource::CreateFrom(const base::Value& value) { 342 std::unique_ptr<AppResource> AppResource::CreateFrom(const base::Value& value) {
340 scoped_ptr<AppResource> resource(new AppResource()); 343 std::unique_ptr<AppResource> resource(new AppResource());
341 if (!IsResourceKindExpected(value, kAppKind) || !resource->Parse(value)) { 344 if (!IsResourceKindExpected(value, kAppKind) || !resource->Parse(value)) {
342 LOG(ERROR) << "Unable to create: Invalid AppResource JSON!"; 345 LOG(ERROR) << "Unable to create: Invalid AppResource JSON!";
343 return scoped_ptr<AppResource>(); 346 return std::unique_ptr<AppResource>();
344 } 347 }
345 return resource; 348 return resource;
346 } 349 }
347 350
348 bool AppResource::Parse(const base::Value& value) { 351 bool AppResource::Parse(const base::Value& value) {
349 base::JSONValueConverter<AppResource> converter; 352 base::JSONValueConverter<AppResource> converter;
350 if (!converter.Convert(value, this)) { 353 if (!converter.Convert(value, this)) {
351 LOG(ERROR) << "Unable to parse: Invalid AppResource"; 354 LOG(ERROR) << "Unable to parse: Invalid AppResource";
352 return false; 355 return false;
353 } 356 }
354 return true; 357 return true;
355 } 358 }
356 359
357 //////////////////////////////////////////////////////////////////////////////// 360 ////////////////////////////////////////////////////////////////////////////////
358 // AppList implementation 361 // AppList implementation
359 362
360 AppList::AppList() {} 363 AppList::AppList() {}
361 364
362 AppList::~AppList() {} 365 AppList::~AppList() {}
363 366
364 // static 367 // static
365 void AppList::RegisterJSONConverter( 368 void AppList::RegisterJSONConverter(
366 base::JSONValueConverter<AppList>* converter) { 369 base::JSONValueConverter<AppList>* converter) {
367 converter->RegisterStringField(kETag, &AppList::etag_); 370 converter->RegisterStringField(kETag, &AppList::etag_);
368 converter->RegisterRepeatedMessage<AppResource>(kItems, 371 converter->RegisterRepeatedMessage<AppResource>(kItems,
369 &AppList::items_); 372 &AppList::items_);
370 } 373 }
371 374
372 // static 375 // static
373 scoped_ptr<AppList> AppList::CreateFrom(const base::Value& value) { 376 std::unique_ptr<AppList> AppList::CreateFrom(const base::Value& value) {
374 scoped_ptr<AppList> resource(new AppList()); 377 std::unique_ptr<AppList> resource(new AppList());
375 if (!IsResourceKindExpected(value, kAppListKind) || !resource->Parse(value)) { 378 if (!IsResourceKindExpected(value, kAppListKind) || !resource->Parse(value)) {
376 LOG(ERROR) << "Unable to create: Invalid AppList JSON!"; 379 LOG(ERROR) << "Unable to create: Invalid AppList JSON!";
377 return scoped_ptr<AppList>(); 380 return std::unique_ptr<AppList>();
378 } 381 }
379 return resource; 382 return resource;
380 } 383 }
381 384
382 bool AppList::Parse(const base::Value& value) { 385 bool AppList::Parse(const base::Value& value) {
383 base::JSONValueConverter<AppList> converter; 386 base::JSONValueConverter<AppList> converter;
384 if (!converter.Convert(value, this)) { 387 if (!converter.Convert(value, this)) {
385 LOG(ERROR) << "Unable to parse: Invalid AppList"; 388 LOG(ERROR) << "Unable to parse: Invalid AppList";
386 return false; 389 return false;
387 } 390 }
(...skipping 10 matching lines...) Expand all
398 // static 401 // static
399 void ParentReference::RegisterJSONConverter( 402 void ParentReference::RegisterJSONConverter(
400 base::JSONValueConverter<ParentReference>* converter) { 403 base::JSONValueConverter<ParentReference>* converter) {
401 converter->RegisterStringField(kId, &ParentReference::file_id_); 404 converter->RegisterStringField(kId, &ParentReference::file_id_);
402 converter->RegisterCustomField<GURL>(kParentLink, 405 converter->RegisterCustomField<GURL>(kParentLink,
403 &ParentReference::parent_link_, 406 &ParentReference::parent_link_,
404 GetGURLFromString); 407 GetGURLFromString);
405 } 408 }
406 409
407 // static 410 // static
408 scoped_ptr<ParentReference> 411 std::unique_ptr<ParentReference> ParentReference::CreateFrom(
409 ParentReference::CreateFrom(const base::Value& value) { 412 const base::Value& value) {
410 scoped_ptr<ParentReference> reference(new ParentReference()); 413 std::unique_ptr<ParentReference> reference(new ParentReference());
411 if (!IsResourceKindExpected(value, kParentReferenceKind) || 414 if (!IsResourceKindExpected(value, kParentReferenceKind) ||
412 !reference->Parse(value)) { 415 !reference->Parse(value)) {
413 LOG(ERROR) << "Unable to create: Invalid ParentRefernce JSON!"; 416 LOG(ERROR) << "Unable to create: Invalid ParentRefernce JSON!";
414 return scoped_ptr<ParentReference>(); 417 return std::unique_ptr<ParentReference>();
415 } 418 }
416 return reference; 419 return reference;
417 } 420 }
418 421
419 bool ParentReference::Parse(const base::Value& value) { 422 bool ParentReference::Parse(const base::Value& value) {
420 base::JSONValueConverter<ParentReference> converter; 423 base::JSONValueConverter<ParentReference> converter;
421 if (!converter.Convert(value, this)) { 424 if (!converter.Convert(value, this)) {
422 LOG(ERROR) << "Unable to parse: Invalid ParentReference"; 425 LOG(ERROR) << "Unable to parse: Invalid ParentReference";
423 return false; 426 return false;
424 } 427 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 kParents, 477 kParents,
475 &FileResource::parents_, 478 &FileResource::parents_,
476 GetParentsFromValue); 479 GetParentsFromValue);
477 converter->RegisterCustomValueField<std::vector<OpenWithLink> >( 480 converter->RegisterCustomValueField<std::vector<OpenWithLink> >(
478 kOpenWithLinks, 481 kOpenWithLinks,
479 &FileResource::open_with_links_, 482 &FileResource::open_with_links_,
480 GetOpenWithLinksFromDictionaryValue); 483 GetOpenWithLinksFromDictionaryValue);
481 } 484 }
482 485
483 // static 486 // static
484 scoped_ptr<FileResource> FileResource::CreateFrom(const base::Value& value) { 487 std::unique_ptr<FileResource> FileResource::CreateFrom(
485 scoped_ptr<FileResource> resource(new FileResource()); 488 const base::Value& value) {
489 std::unique_ptr<FileResource> resource(new FileResource());
486 if (!IsResourceKindExpected(value, kFileKind) || !resource->Parse(value)) { 490 if (!IsResourceKindExpected(value, kFileKind) || !resource->Parse(value)) {
487 LOG(ERROR) << "Unable to create: Invalid FileResource JSON!"; 491 LOG(ERROR) << "Unable to create: Invalid FileResource JSON!";
488 return scoped_ptr<FileResource>(); 492 return std::unique_ptr<FileResource>();
489 } 493 }
490 return resource; 494 return resource;
491 } 495 }
492 496
493 bool FileResource::IsDirectory() const { 497 bool FileResource::IsDirectory() const {
494 return mime_type_ == kDriveFolderMimeType; 498 return mime_type_ == kDriveFolderMimeType;
495 } 499 }
496 500
497 bool FileResource::IsHostedDocument() const { 501 bool FileResource::IsHostedDocument() const {
498 // Hosted documents don't have fileSize field set: 502 // Hosted documents don't have fileSize field set:
(...skipping 26 matching lines...) Expand all
525 converter->RegisterRepeatedMessage<FileResource>(kItems, 529 converter->RegisterRepeatedMessage<FileResource>(kItems,
526 &FileList::items_); 530 &FileList::items_);
527 } 531 }
528 532
529 // static 533 // static
530 bool FileList::HasFileListKind(const base::Value& value) { 534 bool FileList::HasFileListKind(const base::Value& value) {
531 return IsResourceKindExpected(value, kFileListKind); 535 return IsResourceKindExpected(value, kFileListKind);
532 } 536 }
533 537
534 // static 538 // static
535 scoped_ptr<FileList> FileList::CreateFrom(const base::Value& value) { 539 std::unique_ptr<FileList> FileList::CreateFrom(const base::Value& value) {
536 scoped_ptr<FileList> resource(new FileList()); 540 std::unique_ptr<FileList> resource(new FileList());
537 if (!HasFileListKind(value) || !resource->Parse(value)) { 541 if (!HasFileListKind(value) || !resource->Parse(value)) {
538 LOG(ERROR) << "Unable to create: Invalid FileList JSON!"; 542 LOG(ERROR) << "Unable to create: Invalid FileList JSON!";
539 return scoped_ptr<FileList>(); 543 return std::unique_ptr<FileList>();
540 } 544 }
541 return resource; 545 return resource;
542 } 546 }
543 547
544 bool FileList::Parse(const base::Value& value) { 548 bool FileList::Parse(const base::Value& value) {
545 base::JSONValueConverter<FileList> converter; 549 base::JSONValueConverter<FileList> converter;
546 if (!converter.Convert(value, this)) { 550 if (!converter.Convert(value, this)) {
547 LOG(ERROR) << "Unable to parse: Invalid FileList"; 551 LOG(ERROR) << "Unable to parse: Invalid FileList";
548 return false; 552 return false;
549 } 553 }
(...skipping 15 matching lines...) Expand all
565 converter->RegisterStringField(kFileId, &ChangeResource::file_id_); 569 converter->RegisterStringField(kFileId, &ChangeResource::file_id_);
566 converter->RegisterBoolField(kDeleted, &ChangeResource::deleted_); 570 converter->RegisterBoolField(kDeleted, &ChangeResource::deleted_);
567 converter->RegisterCustomValueField(kFile, &ChangeResource::file_, 571 converter->RegisterCustomValueField(kFile, &ChangeResource::file_,
568 &CreateFileResourceFromValue); 572 &CreateFileResourceFromValue);
569 converter->RegisterCustomField<base::Time>( 573 converter->RegisterCustomField<base::Time>(
570 kModificationDate, &ChangeResource::modification_date_, 574 kModificationDate, &ChangeResource::modification_date_,
571 &util::GetTimeFromString); 575 &util::GetTimeFromString);
572 } 576 }
573 577
574 // static 578 // static
575 scoped_ptr<ChangeResource> 579 std::unique_ptr<ChangeResource> ChangeResource::CreateFrom(
576 ChangeResource::CreateFrom(const base::Value& value) { 580 const base::Value& value) {
577 scoped_ptr<ChangeResource> resource(new ChangeResource()); 581 std::unique_ptr<ChangeResource> resource(new ChangeResource());
578 if (!IsResourceKindExpected(value, kChangeKind) || !resource->Parse(value)) { 582 if (!IsResourceKindExpected(value, kChangeKind) || !resource->Parse(value)) {
579 LOG(ERROR) << "Unable to create: Invalid ChangeResource JSON!"; 583 LOG(ERROR) << "Unable to create: Invalid ChangeResource JSON!";
580 return scoped_ptr<ChangeResource>(); 584 return std::unique_ptr<ChangeResource>();
581 } 585 }
582 return resource; 586 return resource;
583 } 587 }
584 588
585 bool ChangeResource::Parse(const base::Value& value) { 589 bool ChangeResource::Parse(const base::Value& value) {
586 base::JSONValueConverter<ChangeResource> converter; 590 base::JSONValueConverter<ChangeResource> converter;
587 if (!converter.Convert(value, this)) { 591 if (!converter.Convert(value, this)) {
588 LOG(ERROR) << "Unable to parse: Invalid ChangeResource"; 592 LOG(ERROR) << "Unable to parse: Invalid ChangeResource";
589 return false; 593 return false;
590 } 594 }
(...skipping 18 matching lines...) Expand all
609 converter->RegisterRepeatedMessage<ChangeResource>(kItems, 613 converter->RegisterRepeatedMessage<ChangeResource>(kItems,
610 &ChangeList::items_); 614 &ChangeList::items_);
611 } 615 }
612 616
613 // static 617 // static
614 bool ChangeList::HasChangeListKind(const base::Value& value) { 618 bool ChangeList::HasChangeListKind(const base::Value& value) {
615 return IsResourceKindExpected(value, kChangeListKind); 619 return IsResourceKindExpected(value, kChangeListKind);
616 } 620 }
617 621
618 // static 622 // static
619 scoped_ptr<ChangeList> ChangeList::CreateFrom(const base::Value& value) { 623 std::unique_ptr<ChangeList> ChangeList::CreateFrom(const base::Value& value) {
620 scoped_ptr<ChangeList> resource(new ChangeList()); 624 std::unique_ptr<ChangeList> resource(new ChangeList());
621 if (!HasChangeListKind(value) || !resource->Parse(value)) { 625 if (!HasChangeListKind(value) || !resource->Parse(value)) {
622 LOG(ERROR) << "Unable to create: Invalid ChangeList JSON!"; 626 LOG(ERROR) << "Unable to create: Invalid ChangeList JSON!";
623 return scoped_ptr<ChangeList>(); 627 return std::unique_ptr<ChangeList>();
624 } 628 }
625 return resource; 629 return resource;
626 } 630 }
627 631
628 bool ChangeList::Parse(const base::Value& value) { 632 bool ChangeList::Parse(const base::Value& value) {
629 base::JSONValueConverter<ChangeList> converter; 633 base::JSONValueConverter<ChangeList> converter;
630 if (!converter.Convert(value, this)) { 634 if (!converter.Convert(value, this)) {
631 LOG(ERROR) << "Unable to parse: Invalid ChangeList"; 635 LOG(ERROR) << "Unable to parse: Invalid ChangeList";
632 return false; 636 return false;
633 } 637 }
634 return true; 638 return true;
635 } 639 }
636 640
637 641
638 //////////////////////////////////////////////////////////////////////////////// 642 ////////////////////////////////////////////////////////////////////////////////
639 // FileLabels implementation 643 // FileLabels implementation
640 644
641 FileLabels::FileLabels() : trashed_(false) {} 645 FileLabels::FileLabels() : trashed_(false) {}
642 646
643 FileLabels::~FileLabels() {} 647 FileLabels::~FileLabels() {}
644 648
645 // static 649 // static
646 void FileLabels::RegisterJSONConverter( 650 void FileLabels::RegisterJSONConverter(
647 base::JSONValueConverter<FileLabels>* converter) { 651 base::JSONValueConverter<FileLabels>* converter) {
648 converter->RegisterBoolField(kLabelTrashed, &FileLabels::trashed_); 652 converter->RegisterBoolField(kLabelTrashed, &FileLabels::trashed_);
649 } 653 }
650 654
651 // static 655 // static
652 scoped_ptr<FileLabels> FileLabels::CreateFrom(const base::Value& value) { 656 std::unique_ptr<FileLabels> FileLabels::CreateFrom(const base::Value& value) {
653 scoped_ptr<FileLabels> resource(new FileLabels()); 657 std::unique_ptr<FileLabels> resource(new FileLabels());
654 if (!resource->Parse(value)) { 658 if (!resource->Parse(value)) {
655 LOG(ERROR) << "Unable to create: Invalid FileLabels JSON!"; 659 LOG(ERROR) << "Unable to create: Invalid FileLabels JSON!";
656 return scoped_ptr<FileLabels>(); 660 return std::unique_ptr<FileLabels>();
657 } 661 }
658 return resource; 662 return resource;
659 } 663 }
660 664
661 bool FileLabels::Parse(const base::Value& value) { 665 bool FileLabels::Parse(const base::Value& value) {
662 base::JSONValueConverter<FileLabels> converter; 666 base::JSONValueConverter<FileLabels> converter;
663 if (!converter.Convert(value, this)) { 667 if (!converter.Convert(value, this)) {
664 LOG(ERROR) << "Unable to parse: Invalid FileLabels."; 668 LOG(ERROR) << "Unable to parse: Invalid FileLabels.";
665 return false; 669 return false;
666 } 670 }
(...skipping 15 matching lines...) Expand all
682 base::JSONValueConverter<ImageMediaMetadata>* converter) { 686 base::JSONValueConverter<ImageMediaMetadata>* converter) {
683 converter->RegisterIntField(kImageMediaMetadataWidth, 687 converter->RegisterIntField(kImageMediaMetadataWidth,
684 &ImageMediaMetadata::width_); 688 &ImageMediaMetadata::width_);
685 converter->RegisterIntField(kImageMediaMetadataHeight, 689 converter->RegisterIntField(kImageMediaMetadataHeight,
686 &ImageMediaMetadata::height_); 690 &ImageMediaMetadata::height_);
687 converter->RegisterIntField(kImageMediaMetadataRotation, 691 converter->RegisterIntField(kImageMediaMetadataRotation,
688 &ImageMediaMetadata::rotation_); 692 &ImageMediaMetadata::rotation_);
689 } 693 }
690 694
691 // static 695 // static
692 scoped_ptr<ImageMediaMetadata> ImageMediaMetadata::CreateFrom( 696 std::unique_ptr<ImageMediaMetadata> ImageMediaMetadata::CreateFrom(
693 const base::Value& value) { 697 const base::Value& value) {
694 scoped_ptr<ImageMediaMetadata> resource(new ImageMediaMetadata()); 698 std::unique_ptr<ImageMediaMetadata> resource(new ImageMediaMetadata());
695 if (!resource->Parse(value)) { 699 if (!resource->Parse(value)) {
696 LOG(ERROR) << "Unable to create: Invalid ImageMediaMetadata JSON!"; 700 LOG(ERROR) << "Unable to create: Invalid ImageMediaMetadata JSON!";
697 return scoped_ptr<ImageMediaMetadata>(); 701 return std::unique_ptr<ImageMediaMetadata>();
698 } 702 }
699 return resource; 703 return resource;
700 } 704 }
701 705
702 bool ImageMediaMetadata::Parse(const base::Value& value) { 706 bool ImageMediaMetadata::Parse(const base::Value& value) {
703 base::JSONValueConverter<ImageMediaMetadata> converter; 707 base::JSONValueConverter<ImageMediaMetadata> converter;
704 if (!converter.Convert(value, this)) { 708 if (!converter.Convert(value, this)) {
705 LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata."; 709 LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata.";
706 return false; 710 return false;
707 } 711 }
708 return true; 712 return true;
709 } 713 }
710 714
711 } // namespace google_apis 715 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698