OLD | NEW |
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> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "components/drive/file_errors.h" | 18 #include "components/drive/file_errors.h" |
19 #include "components/drive/file_errors.h" | |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 namespace base { | 21 namespace base { |
23 class CancellationFlag; | 22 class CancellationFlag; |
24 } // namespace base | 23 } // namespace base |
25 | 24 |
26 namespace google_apis { | 25 namespace google_apis { |
27 class AboutResource; | 26 class AboutResource; |
28 class ChangeList; | 27 class ChangeList; |
29 class FileList; | 28 class FileList; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Class to represent a change list. | 74 // Class to represent a change list. |
76 class ChangeList { | 75 class ChangeList { |
77 public: | 76 public: |
78 ChangeList(); // For tests. | 77 ChangeList(); // For tests. |
79 explicit ChangeList(const google_apis::ChangeList& change_list); | 78 explicit ChangeList(const google_apis::ChangeList& change_list); |
80 explicit ChangeList(const google_apis::FileList& file_list); | 79 explicit ChangeList(const google_apis::FileList& file_list); |
81 ~ChangeList(); | 80 ~ChangeList(); |
82 | 81 |
83 const std::vector<ResourceEntry>& entries() const { return entries_; } | 82 const std::vector<ResourceEntry>& entries() const { return entries_; } |
84 std::vector<ResourceEntry>* mutable_entries() { return &entries_; } | 83 std::vector<ResourceEntry>* mutable_entries() { return &entries_; } |
| 84 const std::vector<ResourceEntry>& team_drives() const { return team_drives_; } |
| 85 std::vector<ResourceEntry>* mutable_team_drives() { return &team_drives_; } |
85 const std::vector<std::string>& parent_resource_ids() const { | 86 const std::vector<std::string>& parent_resource_ids() const { |
86 return parent_resource_ids_; | 87 return parent_resource_ids_; |
87 } | 88 } |
88 std::vector<std::string>* mutable_parent_resource_ids() { | 89 std::vector<std::string>* mutable_parent_resource_ids() { |
89 return &parent_resource_ids_; | 90 return &parent_resource_ids_; |
90 } | 91 } |
91 const GURL& next_url() const { return next_url_; } | 92 const GURL& next_url() const { return next_url_; } |
92 int64_t largest_changestamp() const { return largest_changestamp_; } | 93 int64_t largest_changestamp() const { return largest_changestamp_; } |
93 | 94 |
94 void set_largest_changestamp(int64_t largest_changestamp) { | 95 void set_largest_changestamp(int64_t largest_changestamp) { |
95 largest_changestamp_ = largest_changestamp; | 96 largest_changestamp_ = largest_changestamp; |
96 } | 97 } |
97 | 98 |
98 private: | 99 private: |
99 std::vector<ResourceEntry> entries_; | 100 std::vector<ResourceEntry> entries_; |
| 101 std::vector<ResourceEntry> team_drives_; |
100 std::vector<std::string> parent_resource_ids_; | 102 std::vector<std::string> parent_resource_ids_; |
101 GURL next_url_; | 103 GURL next_url_; |
102 int64_t largest_changestamp_; | 104 int64_t largest_changestamp_; |
103 | 105 |
104 DISALLOW_COPY_AND_ASSIGN(ChangeList); | 106 DISALLOW_COPY_AND_ASSIGN(ChangeList); |
105 }; | 107 }; |
106 | 108 |
107 // ChangeListProcessor is used to process change lists, or full resource | 109 // ChangeListProcessor is used to process change lists, or full resource |
108 // lists from WAPI (codename for Documents List API) or Google Drive API, and | 110 // lists from WAPI (codename for Documents List API) or Google Drive API, and |
109 // updates the resource metadata stored locally. | 111 // updates the resource metadata stored locally. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 149 |
148 // Applies the pre-processed metadata from entry_map_ onto the resource | 150 // Applies the pre-processed metadata from entry_map_ onto the resource |
149 // metadata. |about_resource| must not be null. | 151 // metadata. |about_resource| must not be null. |
150 FileError ApplyEntryMap( | 152 FileError ApplyEntryMap( |
151 int64_t changestamp, | 153 int64_t changestamp, |
152 std::unique_ptr<google_apis::AboutResource> about_resource); | 154 std::unique_ptr<google_apis::AboutResource> about_resource); |
153 | 155 |
154 // Apply |entry| to resource_metadata_. | 156 // Apply |entry| to resource_metadata_. |
155 FileError ApplyEntry(const ResourceEntry& entry); | 157 FileError ApplyEntry(const ResourceEntry& entry); |
156 | 158 |
| 159 // Apply |change| to resource_metadata_. |
| 160 FileError ApplyTeamDriveChange(const ResourceEntry& change); |
| 161 |
157 // Adds the directories changed by the update on |entry| to |changed_dirs_|. | 162 // Adds the directories changed by the update on |entry| to |changed_dirs_|. |
158 void UpdateChangedDirs(const ResourceEntry& entry); | 163 void UpdateChangedDirs(const ResourceEntry& entry); |
159 | 164 |
160 ResourceMetadata* resource_metadata_; // Not owned. | 165 ResourceMetadata* resource_metadata_; // Not owned. |
161 base::CancellationFlag* in_shutdown_; // Not owned. | 166 base::CancellationFlag* in_shutdown_; // Not owned. |
162 | 167 |
163 ResourceEntryMap entry_map_; | 168 ResourceEntryMap entry_map_; |
164 ParentResourceIdMap parent_resource_id_map_; | 169 ParentResourceIdMap parent_resource_id_map_; |
165 std::unique_ptr<FileChange> changed_files_; | 170 std::unique_ptr<FileChange> changed_files_; |
166 | 171 |
167 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor); | 172 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor); |
168 }; | 173 }; |
169 | 174 |
170 } // namespace internal | 175 } // namespace internal |
171 } // namespace drive | 176 } // namespace drive |
172 | 177 |
173 #endif // COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_ | 178 #endif // COMPONENTS_DRIVE_CHROMEOS_CHANGE_LIST_PROCESSOR_H_ |
OLD | NEW |