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

Side by Side Diff: components/drive/chromeos/change_list_processor.h

Issue 2799603002: Process TeamDrive change in change list. (Closed)
Patch Set: Add test for update. Created 3 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 COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_ 5 #ifndef COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_
6 #define COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_ 6 #define COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 15 matching lines...) Expand all
26 namespace google_apis { 26 namespace google_apis {
27 class AboutResource; 27 class AboutResource;
28 class ChangeList; 28 class ChangeList;
29 class FileList; 29 class FileList;
30 } // namespace google_apis 30 } // namespace google_apis
31 31
32 namespace drive { 32 namespace drive {
33 33
34 class FileChange; 34 class FileChange;
35 class ResourceEntry; 35 class ResourceEntry;
36 class TeamDriveChange;
36 37
37 namespace internal { 38 namespace internal {
38 39
39 class ResourceMetadata; 40 class ResourceMetadata;
40 41
41 // Holds information needed to fetch contents of a directory. 42 // Holds information needed to fetch contents of a directory.
42 // This object is copyable. 43 // This object is copyable.
43 class DirectoryFetchInfo { 44 class DirectoryFetchInfo {
44 public: 45 public:
45 DirectoryFetchInfo() : changestamp_(0) {} 46 DirectoryFetchInfo() : changestamp_(0) {}
(...skipping 29 matching lines...) Expand all
75 // Class to represent a change list. 76 // Class to represent a change list.
76 class ChangeList { 77 class ChangeList {
77 public: 78 public:
78 ChangeList(); // For tests. 79 ChangeList(); // For tests.
79 explicit ChangeList(const google_apis::ChangeList& change_list); 80 explicit ChangeList(const google_apis::ChangeList& change_list);
80 explicit ChangeList(const google_apis::FileList& file_list); 81 explicit ChangeList(const google_apis::FileList& file_list);
81 ~ChangeList(); 82 ~ChangeList();
82 83
83 const std::vector<ResourceEntry>& entries() const { return entries_; } 84 const std::vector<ResourceEntry>& entries() const { return entries_; }
84 std::vector<ResourceEntry>* mutable_entries() { return &entries_; } 85 std::vector<ResourceEntry>* mutable_entries() { return &entries_; }
86 const std::vector<TeamDriveChange>& team_drives() const {
87 return team_drives_;
88 }
89 std::vector<TeamDriveChange>* mutable_team_drives() { return &team_drives_; }
85 const std::vector<std::string>& parent_resource_ids() const { 90 const std::vector<std::string>& parent_resource_ids() const {
86 return parent_resource_ids_; 91 return parent_resource_ids_;
87 } 92 }
88 std::vector<std::string>* mutable_parent_resource_ids() { 93 std::vector<std::string>* mutable_parent_resource_ids() {
89 return &parent_resource_ids_; 94 return &parent_resource_ids_;
90 } 95 }
91 const GURL& next_url() const { return next_url_; } 96 const GURL& next_url() const { return next_url_; }
92 int64_t largest_changestamp() const { return largest_changestamp_; } 97 int64_t largest_changestamp() const { return largest_changestamp_; }
93 98
94 void set_largest_changestamp(int64_t largest_changestamp) { 99 void set_largest_changestamp(int64_t largest_changestamp) {
95 largest_changestamp_ = largest_changestamp; 100 largest_changestamp_ = largest_changestamp;
96 } 101 }
97 102
98 private: 103 private:
99 std::vector<ResourceEntry> entries_; 104 std::vector<ResourceEntry> entries_;
105 std::vector<TeamDriveChange> team_drives_;
100 std::vector<std::string> parent_resource_ids_; 106 std::vector<std::string> parent_resource_ids_;
101 GURL next_url_; 107 GURL next_url_;
102 int64_t largest_changestamp_; 108 int64_t largest_changestamp_;
103 109
104 DISALLOW_COPY_AND_ASSIGN(ChangeList); 110 DISALLOW_COPY_AND_ASSIGN(ChangeList);
105 }; 111 };
106 112
107 // ChangeListProcessor is used to process change lists, or full resource 113 // ChangeListProcessor is used to process change lists, or full resource
108 // lists from WAPI (codename for Documents List API) or Google Drive API, and 114 // lists from WAPI (codename for Documents List API) or Google Drive API, and
109 // updates the resource metadata stored locally. 115 // updates the resource metadata stored locally.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 153
148 // Applies the pre-processed metadata from entry_map_ onto the resource 154 // Applies the pre-processed metadata from entry_map_ onto the resource
149 // metadata. |about_resource| must not be null. 155 // metadata. |about_resource| must not be null.
150 FileError ApplyEntryMap( 156 FileError ApplyEntryMap(
151 int64_t changestamp, 157 int64_t changestamp,
152 std::unique_ptr<google_apis::AboutResource> about_resource); 158 std::unique_ptr<google_apis::AboutResource> about_resource);
153 159
154 // Apply |entry| to resource_metadata_. 160 // Apply |entry| to resource_metadata_.
155 FileError ApplyEntry(const ResourceEntry& entry); 161 FileError ApplyEntry(const ResourceEntry& entry);
156 162
163 // Converts |change| to a ResourceEntry and apply to resource_metadata_.
164 FileError ApplyTeamDriveChange(const TeamDriveChange& change);
165
157 // Adds the directories changed by the update on |entry| to |changed_dirs_|. 166 // Adds the directories changed by the update on |entry| to |changed_dirs_|.
158 void UpdateChangedDirs(const ResourceEntry& entry); 167 void UpdateChangedDirs(const ResourceEntry& entry);
159 168
160 ResourceMetadata* resource_metadata_; // Not owned. 169 ResourceMetadata* resource_metadata_; // Not owned.
161 base::CancellationFlag* in_shutdown_; // Not owned. 170 base::CancellationFlag* in_shutdown_; // Not owned.
162 171
163 ResourceEntryMap entry_map_; 172 ResourceEntryMap entry_map_;
164 ParentResourceIdMap parent_resource_id_map_; 173 ParentResourceIdMap parent_resource_id_map_;
165 std::unique_ptr<FileChange> changed_files_; 174 std::unique_ptr<FileChange> changed_files_;
166 175
167 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor); 176 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor);
168 }; 177 };
169 178
170 } // namespace internal 179 } // namespace internal
171 } // namespace drive 180 } // namespace drive
172 181
173 #endif // COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_ 182 #endif // COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698