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

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

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 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_ 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_
6 #define GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_ 6 #define GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9
10 #include <memory>
9 #include <string> 11 #include <string>
10 #include <utility> 12 #include <utility>
11 13
12 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 16 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
17 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace base { 22 namespace base {
22 class Value; 23 class Value;
23 template <class StructType> 24 template <class StructType>
24 class JSONValueConverter; 25 class JSONValueConverter;
25 26
(...skipping 11 matching lines...) Expand all
37 public: 38 public:
38 AboutResource(); 39 AboutResource();
39 ~AboutResource(); 40 ~AboutResource();
40 41
41 // Registers the mapping between JSON field names and the members in this 42 // Registers the mapping between JSON field names and the members in this
42 // class. 43 // class.
43 static void RegisterJSONConverter( 44 static void RegisterJSONConverter(
44 base::JSONValueConverter<AboutResource>* converter); 45 base::JSONValueConverter<AboutResource>* converter);
45 46
46 // Creates about resource from parsed JSON. 47 // Creates about resource from parsed JSON.
47 static scoped_ptr<AboutResource> CreateFrom(const base::Value& value); 48 static std::unique_ptr<AboutResource> CreateFrom(const base::Value& value);
48 49
49 // Returns the largest change ID number. 50 // Returns the largest change ID number.
50 int64_t largest_change_id() const { return largest_change_id_; } 51 int64_t largest_change_id() const { return largest_change_id_; }
51 // Returns total number of quota bytes. 52 // Returns total number of quota bytes.
52 int64_t quota_bytes_total() const { return quota_bytes_total_; } 53 int64_t quota_bytes_total() const { return quota_bytes_total_; }
53 // Returns the number of quota bytes used. 54 // Returns the number of quota bytes used.
54 int64_t quota_bytes_used_aggregate() const { 55 int64_t quota_bytes_used_aggregate() const {
55 return quota_bytes_used_aggregate_; 56 return quota_bytes_used_aggregate_;
56 } 57 }
57 // Returns root folder ID. 58 // Returns root folder ID.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 100
100 DriveAppIcon(); 101 DriveAppIcon();
101 ~DriveAppIcon(); 102 ~DriveAppIcon();
102 103
103 // Registers the mapping between JSON field names and the members in this 104 // Registers the mapping between JSON field names and the members in this
104 // class. 105 // class.
105 static void RegisterJSONConverter( 106 static void RegisterJSONConverter(
106 base::JSONValueConverter<DriveAppIcon>* converter); 107 base::JSONValueConverter<DriveAppIcon>* converter);
107 108
108 // Creates drive app icon instance from parsed JSON. 109 // Creates drive app icon instance from parsed JSON.
109 static scoped_ptr<DriveAppIcon> CreateFrom(const base::Value& value); 110 static std::unique_ptr<DriveAppIcon> CreateFrom(const base::Value& value);
110 111
111 // Category of the icon. 112 // Category of the icon.
112 IconCategory category() const { return category_; } 113 IconCategory category() const { return category_; }
113 114
114 // Size in pixels of one side of the icon (icons are always square). 115 // Size in pixels of one side of the icon (icons are always square).
115 int icon_side_length() const { return icon_side_length_; } 116 int icon_side_length() const { return icon_side_length_; }
116 117
117 // Returns URL for this icon. 118 // Returns URL for this icon.
118 const GURL& icon_url() const { return icon_url_; } 119 const GURL& icon_url() const { return icon_url_; }
119 120
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 public: 154 public:
154 ~AppResource(); 155 ~AppResource();
155 AppResource(); 156 AppResource();
156 157
157 // Registers the mapping between JSON field names and the members in this 158 // Registers the mapping between JSON field names and the members in this
158 // class. 159 // class.
159 static void RegisterJSONConverter( 160 static void RegisterJSONConverter(
160 base::JSONValueConverter<AppResource>* converter); 161 base::JSONValueConverter<AppResource>* converter);
161 162
162 // Creates app resource from parsed JSON. 163 // Creates app resource from parsed JSON.
163 static scoped_ptr<AppResource> CreateFrom(const base::Value& value); 164 static std::unique_ptr<AppResource> CreateFrom(const base::Value& value);
164 165
165 // Returns application ID, which is 12-digit decimals (e.g. "123456780123"). 166 // Returns application ID, which is 12-digit decimals (e.g. "123456780123").
166 const std::string& application_id() const { return application_id_; } 167 const std::string& application_id() const { return application_id_; }
167 168
168 // Returns application name. 169 // Returns application name.
169 const std::string& name() const { return name_; } 170 const std::string& name() const { return name_; }
170 171
171 // Returns the name of the type of object this application creates. 172 // Returns the name of the type of object this application creates.
172 // This is used for displaying in "Create" menu item for this app. 173 // This is used for displaying in "Create" menu item for this app.
173 // If empty, application name is used instead. 174 // If empty, application name is used instead.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 public: 286 public:
286 AppList(); 287 AppList();
287 ~AppList(); 288 ~AppList();
288 289
289 // Registers the mapping between JSON field names and the members in this 290 // Registers the mapping between JSON field names and the members in this
290 // class. 291 // class.
291 static void RegisterJSONConverter( 292 static void RegisterJSONConverter(
292 base::JSONValueConverter<AppList>* converter); 293 base::JSONValueConverter<AppList>* converter);
293 294
294 // Creates app list from parsed JSON. 295 // Creates app list from parsed JSON.
295 static scoped_ptr<AppList> CreateFrom(const base::Value& value); 296 static std::unique_ptr<AppList> CreateFrom(const base::Value& value);
296 297
297 // ETag for this resource. 298 // ETag for this resource.
298 const std::string& etag() const { return etag_; } 299 const std::string& etag() const { return etag_; }
299 300
300 // Returns a vector of applications. 301 // Returns a vector of applications.
301 const ScopedVector<AppResource>& items() const { return items_; } 302 const ScopedVector<AppResource>& items() const { return items_; }
302 303
303 void set_etag(const std::string& etag) { 304 void set_etag(const std::string& etag) {
304 etag_ = etag; 305 etag_ = etag;
305 } 306 }
(...skipping 19 matching lines...) Expand all
325 public: 326 public:
326 ParentReference(); 327 ParentReference();
327 ~ParentReference(); 328 ~ParentReference();
328 329
329 // Registers the mapping between JSON field names and the members in this 330 // Registers the mapping between JSON field names and the members in this
330 // class. 331 // class.
331 static void RegisterJSONConverter( 332 static void RegisterJSONConverter(
332 base::JSONValueConverter<ParentReference>* converter); 333 base::JSONValueConverter<ParentReference>* converter);
333 334
334 // Creates parent reference from parsed JSON. 335 // Creates parent reference from parsed JSON.
335 static scoped_ptr<ParentReference> CreateFrom(const base::Value& value); 336 static std::unique_ptr<ParentReference> CreateFrom(const base::Value& value);
336 337
337 // Returns the file id of the reference. 338 // Returns the file id of the reference.
338 const std::string& file_id() const { return file_id_; } 339 const std::string& file_id() const { return file_id_; }
339 340
340 // Returns the URL for the parent in Drive. 341 // Returns the URL for the parent in Drive.
341 const GURL& parent_link() const { return parent_link_; } 342 const GURL& parent_link() const { return parent_link_; }
342 343
343 void set_file_id(const std::string& file_id) { file_id_ = file_id; } 344 void set_file_id(const std::string& file_id) { file_id_ = file_id; }
344 void set_parent_link(const GURL& parent_link) { 345 void set_parent_link(const GURL& parent_link) {
345 parent_link_ = parent_link; 346 parent_link_ = parent_link;
(...skipping 14 matching lines...) Expand all
360 public: 361 public:
361 FileLabels(); 362 FileLabels();
362 ~FileLabels(); 363 ~FileLabels();
363 364
364 // Registers the mapping between JSON field names and the members in this 365 // Registers the mapping between JSON field names and the members in this
365 // class. 366 // class.
366 static void RegisterJSONConverter( 367 static void RegisterJSONConverter(
367 base::JSONValueConverter<FileLabels>* converter); 368 base::JSONValueConverter<FileLabels>* converter);
368 369
369 // Creates about resource from parsed JSON. 370 // Creates about resource from parsed JSON.
370 static scoped_ptr<FileLabels> CreateFrom(const base::Value& value); 371 static std::unique_ptr<FileLabels> CreateFrom(const base::Value& value);
371 372
372 // Whether this file has been trashed. 373 // Whether this file has been trashed.
373 bool is_trashed() const { return trashed_; } 374 bool is_trashed() const { return trashed_; }
374 375
375 void set_trashed(bool trashed) { trashed_ = trashed; } 376 void set_trashed(bool trashed) { trashed_ = trashed; }
376 377
377 private: 378 private:
378 friend class FileResource; 379 friend class FileResource;
379 380
380 // Parses and initializes data members from content of |value|. 381 // Parses and initializes data members from content of |value|.
381 // Return false if parsing fails. 382 // Return false if parsing fails.
382 bool Parse(const base::Value& value); 383 bool Parse(const base::Value& value);
383 384
384 bool trashed_; 385 bool trashed_;
385 }; 386 };
386 387
387 // ImageMediaMetadata represents image metadata for a file. 388 // ImageMediaMetadata represents image metadata for a file.
388 // https://developers.google.com/drive/v2/reference/files 389 // https://developers.google.com/drive/v2/reference/files
389 class ImageMediaMetadata { 390 class ImageMediaMetadata {
390 public: 391 public:
391 ImageMediaMetadata(); 392 ImageMediaMetadata();
392 ~ImageMediaMetadata(); 393 ~ImageMediaMetadata();
393 394
394 // Registers the mapping between JSON field names and the members in this 395 // Registers the mapping between JSON field names and the members in this
395 // class. 396 // class.
396 static void RegisterJSONConverter( 397 static void RegisterJSONConverter(
397 base::JSONValueConverter<ImageMediaMetadata>* converter); 398 base::JSONValueConverter<ImageMediaMetadata>* converter);
398 399
399 // Creates about resource from parsed JSON. 400 // Creates about resource from parsed JSON.
400 static scoped_ptr<ImageMediaMetadata> CreateFrom(const base::Value& value); 401 static std::unique_ptr<ImageMediaMetadata> CreateFrom(
402 const base::Value& value);
401 403
402 // Width of the image in pixels. 404 // Width of the image in pixels.
403 int width() const { return width_; } 405 int width() const { return width_; }
404 // Height of the image in pixels. 406 // Height of the image in pixels.
405 int height() const { return height_; } 407 int height() const { return height_; }
406 // Rotation of the image in clockwise degrees. 408 // Rotation of the image in clockwise degrees.
407 int rotation() const { return rotation_; } 409 int rotation() const { return rotation_; }
408 410
409 void set_width(int width) { width_ = width; } 411 void set_width(int width) { width_ = width; }
410 void set_height(int height) { height_ = height; } 412 void set_height(int height) { height_ = height; }
(...skipping 24 matching lines...) Expand all
435 FileResource(); 437 FileResource();
436 FileResource(const FileResource& other); 438 FileResource(const FileResource& other);
437 ~FileResource(); 439 ~FileResource();
438 440
439 // Registers the mapping between JSON field names and the members in this 441 // Registers the mapping between JSON field names and the members in this
440 // class. 442 // class.
441 static void RegisterJSONConverter( 443 static void RegisterJSONConverter(
442 base::JSONValueConverter<FileResource>* converter); 444 base::JSONValueConverter<FileResource>* converter);
443 445
444 // Creates file resource from parsed JSON. 446 // Creates file resource from parsed JSON.
445 static scoped_ptr<FileResource> CreateFrom(const base::Value& value); 447 static std::unique_ptr<FileResource> CreateFrom(const base::Value& value);
446 448
447 // Returns true if this is a directory. 449 // Returns true if this is a directory.
448 // Note: "folder" is used elsewhere in this file to match Drive API reference, 450 // Note: "folder" is used elsewhere in this file to match Drive API reference,
449 // but outside this file we use "directory" to match HTML5 filesystem API. 451 // but outside this file we use "directory" to match HTML5 filesystem API.
450 bool IsDirectory() const; 452 bool IsDirectory() const;
451 453
452 // Returns true if this is a hosted document. 454 // Returns true if this is a hosted document.
453 // A hosted document is a document in one of Google Docs formats (Documents, 455 // A hosted document is a document in one of Google Docs formats (Documents,
454 // Spreadsheets, Slides, ...) whose content is not exposed via the API. It is 456 // Spreadsheets, Slides, ...) whose content is not exposed via the API. It is
455 // available only as |alternate_link()| to the document hosted on the server. 457 // available only as |alternate_link()| to the document hosted on the server.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 602
601 // Registers the mapping between JSON field names and the members in this 603 // Registers the mapping between JSON field names and the members in this
602 // class. 604 // class.
603 static void RegisterJSONConverter( 605 static void RegisterJSONConverter(
604 base::JSONValueConverter<FileList>* converter); 606 base::JSONValueConverter<FileList>* converter);
605 607
606 // Returns true if the |value| has kind field for FileList. 608 // Returns true if the |value| has kind field for FileList.
607 static bool HasFileListKind(const base::Value& value); 609 static bool HasFileListKind(const base::Value& value);
608 610
609 // Creates file list from parsed JSON. 611 // Creates file list from parsed JSON.
610 static scoped_ptr<FileList> CreateFrom(const base::Value& value); 612 static std::unique_ptr<FileList> CreateFrom(const base::Value& value);
611 613
612 // Returns a link to the next page of files. The URL includes the next page 614 // Returns a link to the next page of files. The URL includes the next page
613 // token. 615 // token.
614 const GURL& next_link() const { return next_link_; } 616 const GURL& next_link() const { return next_link_; }
615 617
616 // Returns a set of files in this list. 618 // Returns a set of files in this list.
617 const ScopedVector<FileResource>& items() const { return items_; } 619 const ScopedVector<FileResource>& items() const { return items_; }
618 ScopedVector<FileResource>* mutable_items() { return &items_; } 620 ScopedVector<FileResource>* mutable_items() { return &items_; }
619 621
620 void set_next_link(const GURL& next_link) { 622 void set_next_link(const GURL& next_link) {
(...skipping 20 matching lines...) Expand all
641 public: 643 public:
642 ChangeResource(); 644 ChangeResource();
643 ~ChangeResource(); 645 ~ChangeResource();
644 646
645 // Registers the mapping between JSON field names and the members in this 647 // Registers the mapping between JSON field names and the members in this
646 // class. 648 // class.
647 static void RegisterJSONConverter( 649 static void RegisterJSONConverter(
648 base::JSONValueConverter<ChangeResource>* converter); 650 base::JSONValueConverter<ChangeResource>* converter);
649 651
650 // Creates change resource from parsed JSON. 652 // Creates change resource from parsed JSON.
651 static scoped_ptr<ChangeResource> CreateFrom(const base::Value& value); 653 static std::unique_ptr<ChangeResource> CreateFrom(const base::Value& value);
652 654
653 // Returns change ID for this change. This is a monotonically increasing 655 // Returns change ID for this change. This is a monotonically increasing
654 // number. 656 // number.
655 int64_t change_id() const { return change_id_; } 657 int64_t change_id() const { return change_id_; }
656 658
657 // Returns a string file ID for corresponding file of the change. 659 // Returns a string file ID for corresponding file of the change.
658 const std::string& file_id() const { return file_id_; } 660 const std::string& file_id() const { return file_id_; }
659 661
660 // Returns true if this file is deleted in the change. 662 // Returns true if this file is deleted in the change.
661 bool is_deleted() const { return deleted_; } 663 bool is_deleted() const { return deleted_; }
662 664
663 // Returns FileResource of the file which the change refers to. 665 // Returns FileResource of the file which the change refers to.
664 const FileResource* file() const { return file_.get(); } 666 const FileResource* file() const { return file_.get(); }
665 FileResource* mutable_file() { return file_.get(); } 667 FileResource* mutable_file() { return file_.get(); }
666 668
667 // Returns the time of this modification. 669 // Returns the time of this modification.
668 const base::Time& modification_date() const { return modification_date_; } 670 const base::Time& modification_date() const { return modification_date_; }
669 671
670 void set_change_id(int64_t change_id) { change_id_ = change_id; } 672 void set_change_id(int64_t change_id) { change_id_ = change_id; }
671 void set_file_id(const std::string& file_id) { 673 void set_file_id(const std::string& file_id) {
672 file_id_ = file_id; 674 file_id_ = file_id;
673 } 675 }
674 void set_deleted(bool deleted) { 676 void set_deleted(bool deleted) {
675 deleted_ = deleted; 677 deleted_ = deleted;
676 } 678 }
677 void set_file(scoped_ptr<FileResource> file) { file_ = std::move(file); } 679 void set_file(std::unique_ptr<FileResource> file) { file_ = std::move(file); }
678 void set_modification_date(const base::Time& modification_date) { 680 void set_modification_date(const base::Time& modification_date) {
679 modification_date_ = modification_date; 681 modification_date_ = modification_date;
680 } 682 }
681 683
682 private: 684 private:
683 friend class base::internal::RepeatedMessageConverter<ChangeResource>; 685 friend class base::internal::RepeatedMessageConverter<ChangeResource>;
684 friend class ChangeList; 686 friend class ChangeList;
685 687
686 // Parses and initializes data members from content of |value|. 688 // Parses and initializes data members from content of |value|.
687 // Return false if parsing fails. 689 // Return false if parsing fails.
688 bool Parse(const base::Value& value); 690 bool Parse(const base::Value& value);
689 691
690 int64_t change_id_; 692 int64_t change_id_;
691 std::string file_id_; 693 std::string file_id_;
692 bool deleted_; 694 bool deleted_;
693 scoped_ptr<FileResource> file_; 695 std::unique_ptr<FileResource> file_;
694 base::Time modification_date_; 696 base::Time modification_date_;
695 697
696 DISALLOW_COPY_AND_ASSIGN(ChangeResource); 698 DISALLOW_COPY_AND_ASSIGN(ChangeResource);
697 }; 699 };
698 700
699 // ChangeList represents a set of changes in the drive. 701 // ChangeList represents a set of changes in the drive.
700 // https://developers.google.com/drive/v2/reference/changes/list 702 // https://developers.google.com/drive/v2/reference/changes/list
701 class ChangeList { 703 class ChangeList {
702 public: 704 public:
703 ChangeList(); 705 ChangeList();
704 ~ChangeList(); 706 ~ChangeList();
705 707
706 // Registers the mapping between JSON field names and the members in this 708 // Registers the mapping between JSON field names and the members in this
707 // class. 709 // class.
708 static void RegisterJSONConverter( 710 static void RegisterJSONConverter(
709 base::JSONValueConverter<ChangeList>* converter); 711 base::JSONValueConverter<ChangeList>* converter);
710 712
711 // Returns true if the |value| has kind field for ChangeList. 713 // Returns true if the |value| has kind field for ChangeList.
712 static bool HasChangeListKind(const base::Value& value); 714 static bool HasChangeListKind(const base::Value& value);
713 715
714 // Creates change list from parsed JSON. 716 // Creates change list from parsed JSON.
715 static scoped_ptr<ChangeList> CreateFrom(const base::Value& value); 717 static std::unique_ptr<ChangeList> CreateFrom(const base::Value& value);
716 718
717 // Returns a link to the next page of files. The URL includes the next page 719 // Returns a link to the next page of files. The URL includes the next page
718 // token. 720 // token.
719 const GURL& next_link() const { return next_link_; } 721 const GURL& next_link() const { return next_link_; }
720 722
721 // Returns the largest change ID number. 723 // Returns the largest change ID number.
722 int64_t largest_change_id() const { return largest_change_id_; } 724 int64_t largest_change_id() const { return largest_change_id_; }
723 725
724 // Returns a set of changes in this list. 726 // Returns a set of changes in this list.
725 const ScopedVector<ChangeResource>& items() const { return items_; } 727 const ScopedVector<ChangeResource>& items() const { return items_; }
(...skipping 17 matching lines...) Expand all
743 GURL next_link_; 745 GURL next_link_;
744 int64_t largest_change_id_; 746 int64_t largest_change_id_;
745 ScopedVector<ChangeResource> items_; 747 ScopedVector<ChangeResource> items_;
746 748
747 DISALLOW_COPY_AND_ASSIGN(ChangeList); 749 DISALLOW_COPY_AND_ASSIGN(ChangeList);
748 }; 750 };
749 751
750 } // namespace google_apis 752 } // namespace google_apis
751 753
752 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_ 754 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698