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

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

Issue 384543004: Get rid of DriveEntryKind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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_GDATA_WAPI_PARSER_H_ 5 #ifndef GOOGLE_APIS_DRIVE_GDATA_WAPI_PARSER_H_
6 #define GOOGLE_APIS_DRIVE_GDATA_WAPI_PARSER_H_ 6 #define GOOGLE_APIS_DRIVE_GDATA_WAPI_PARSER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 int64 image_rotation() const { return image_rotation_; } 411 int64 image_rotation() const { return image_rotation_; }
412 412
413 // The time of this modification. 413 // The time of this modification.
414 // Note: This property is filled only when converted from ChangeResource. 414 // Note: This property is filled only when converted from ChangeResource.
415 const base::Time& modification_date() const { return modification_date_; } 415 const base::Time& modification_date() const { return modification_date_; }
416 416
417 // Text version of resource entry kind. Returns an empty string for 417 // Text version of resource entry kind. Returns an empty string for
418 // unknown entry kind. 418 // unknown entry kind.
419 std::string GetEntryKindText() const; 419 std::string GetEntryKindText() const;
420 420
421 // Returns preferred file extension for hosted documents. If entry is not
422 // a hosted document, this call returns an empty string.
423 static std::string GetHostedDocumentExtension(DriveEntryKind kind);
424
425 // True if resource entry is remotely hosted. 421 // True if resource entry is remotely hosted.
426 bool is_hosted_document() const { 422 bool is_hosted_document() const {
427 return (ClassifyEntryKind(kind_) & KIND_OF_HOSTED_DOCUMENT) > 0; 423 return (ClassifyEntryKind(kind_) & KIND_OF_HOSTED_DOCUMENT) > 0;
428 } 424 }
429 // True if resource entry hosted by Google Documents. 425 // True if resource entry hosted by Google Documents.
430 bool is_google_document() const { 426 bool is_google_document() const {
431 return (ClassifyEntryKind(kind_) & KIND_OF_GOOGLE_DOCUMENT) > 0; 427 return (ClassifyEntryKind(kind_) & KIND_OF_GOOGLE_DOCUMENT) > 0;
432 } 428 }
433 // True if resource entry is hosted by an external application. 429 // True if resource entry is hosted by an external application.
434 bool is_external_document() const { 430 bool is_external_document() const {
435 return (ClassifyEntryKind(kind_) & KIND_OF_EXTERNAL_DOCUMENT) > 0; 431 return (ClassifyEntryKind(kind_) & KIND_OF_EXTERNAL_DOCUMENT) > 0;
436 } 432 }
437 // True if resource entry is a folder (collection). 433 // True if resource entry is a folder (collection).
438 bool is_folder() const { 434 bool is_folder() const {
439 return (ClassifyEntryKind(kind_) & KIND_OF_FOLDER) > 0; 435 return (ClassifyEntryKind(kind_) & KIND_OF_FOLDER) > 0;
440 } 436 }
441 // True if resource entry is regular file. 437 // True if resource entry is regular file.
442 bool is_file() const { 438 bool is_file() const {
443 return (ClassifyEntryKind(kind_) & KIND_OF_FILE) > 0; 439 return (ClassifyEntryKind(kind_) & KIND_OF_FILE) > 0;
444 } 440 }
445 // True if resource entry can't be mapped to the file system.
446 bool is_special() const {
447 return !is_file() && !is_folder() && !is_hosted_document();
448 }
449
450 // The following constructs are exposed for unit tests.
451
452 // Classes of EntryKind. Used for ClassifyEntryKind().
453 enum EntryKindClass {
454 KIND_OF_NONE = 0,
455 KIND_OF_HOSTED_DOCUMENT = 1,
456 KIND_OF_GOOGLE_DOCUMENT = 1 << 1,
457 KIND_OF_EXTERNAL_DOCUMENT = 1 << 2,
458 KIND_OF_FOLDER = 1 << 3,
459 KIND_OF_FILE = 1 << 4,
460 };
461
462 // Returns the kind enum corresponding to the extension in form ".xxx".
463 static DriveEntryKind GetEntryKindFromExtension(const std::string& extension);
464
465 // Classifies the EntryKind. The returned value is a bitmask of
466 // EntryKindClass. For example, DOCUMENT is classified as
467 // KIND_OF_HOSTED_DOCUMENT and KIND_OF_GOOGLE_DOCUMENT, hence the returned
468 // value is KIND_OF_HOSTED_DOCUMENT | KIND_OF_GOOGLE_DOCUMENT.
469 static int ClassifyEntryKind(DriveEntryKind kind);
470
471 // Classifies the EntryKind by the file extension of specific path. The
472 // returned value is a bitmask of EntryKindClass. See also ClassifyEntryKind.
473 static int ClassifyEntryKindByFileExtension(const base::FilePath& file);
474 441
475 void set_resource_id(const std::string& resource_id) { 442 void set_resource_id(const std::string& resource_id) {
476 resource_id_ = resource_id; 443 resource_id_ = resource_id;
477 } 444 }
478 void set_id(const std::string& id) { id_ = id; } 445 void set_id(const std::string& id) { id_ = id; }
479 void set_kind(DriveEntryKind kind) { kind_ = kind; } 446 void set_kind(DriveEntryKind kind) { kind_ = kind; }
480 void set_title(const std::string& title) { title_ = title; } 447 void set_title(const std::string& title) { title_ = title; }
481 void set_published_time(const base::Time& published_time) { 448 void set_published_time(const base::Time& published_time) {
482 published_time_ = published_time; 449 published_time_ = published_time;
483 } 450 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 int items_per_page_; 603 int items_per_page_;
637 std::string title_; 604 std::string title_;
638 int64 largest_changestamp_; 605 int64 largest_changestamp_;
639 606
640 DISALLOW_COPY_AND_ASSIGN(ResourceList); 607 DISALLOW_COPY_AND_ASSIGN(ResourceList);
641 }; 608 };
642 609
643 } // namespace google_apis 610 } // namespace google_apis
644 611
645 #endif // GOOGLE_APIS_DRIVE_GDATA_WAPI_PARSER_H_ 612 #endif // GOOGLE_APIS_DRIVE_GDATA_WAPI_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698