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

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

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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_CHANGE_LIST_PROCESSOR_H_ 5 #ifndef COMPONENTS_DRIVE_CHANGE_LIST_PROCESSOR_H_
6 #define COMPONENTS_DRIVE_CHANGE_LIST_PROCESSOR_H_ 6 #define COMPONENTS_DRIVE_CHANGE_LIST_PROCESSOR_H_
7 7
8 #include <stdint.h>
9
8 #include <map> 10 #include <map>
9 #include <set> 11 #include <set>
10 #include <string> 12 #include <string>
11 13
12 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
15 #include "components/drive/file_errors.h" 18 #include "components/drive/file_errors.h"
16 #include "components/drive/file_errors.h" 19 #include "components/drive/file_errors.h"
17 #include "url/gurl.h" 20 #include "url/gurl.h"
18 21
19 namespace base { 22 namespace base {
20 class CancellationFlag; 23 class CancellationFlag;
21 } // namespace base 24 } // namespace base
22 25
(...skipping 12 matching lines...) Expand all
35 38
36 class ResourceMetadata; 39 class ResourceMetadata;
37 40
38 // Holds information needed to fetch contents of a directory. 41 // Holds information needed to fetch contents of a directory.
39 // This object is copyable. 42 // This object is copyable.
40 class DirectoryFetchInfo { 43 class DirectoryFetchInfo {
41 public: 44 public:
42 DirectoryFetchInfo() : changestamp_(0) {} 45 DirectoryFetchInfo() : changestamp_(0) {}
43 DirectoryFetchInfo(const std::string& local_id, 46 DirectoryFetchInfo(const std::string& local_id,
44 const std::string& resource_id, 47 const std::string& resource_id,
45 int64 changestamp) 48 int64_t changestamp)
46 : local_id_(local_id), 49 : local_id_(local_id),
47 resource_id_(resource_id), 50 resource_id_(resource_id),
48 changestamp_(changestamp) { 51 changestamp_(changestamp) {}
49 }
50 52
51 // Returns true if the object is empty. 53 // Returns true if the object is empty.
52 bool empty() const { return local_id_.empty(); } 54 bool empty() const { return local_id_.empty(); }
53 55
54 // Local ID of the directory. 56 // Local ID of the directory.
55 const std::string& local_id() const { return local_id_; } 57 const std::string& local_id() const { return local_id_; }
56 58
57 // Resource ID of the directory. 59 // Resource ID of the directory.
58 const std::string& resource_id() const { return resource_id_; } 60 const std::string& resource_id() const { return resource_id_; }
59 61
60 // Changestamp of the directory. The changestamp is used to determine if 62 // Changestamp of the directory. The changestamp is used to determine if
61 // the directory contents should be fetched. 63 // the directory contents should be fetched.
62 int64 changestamp() const { return changestamp_; } 64 int64_t changestamp() const { return changestamp_; }
63 65
64 // Returns a string representation of this object. 66 // Returns a string representation of this object.
65 std::string ToString() const; 67 std::string ToString() const;
66 68
67 private: 69 private:
68 const std::string local_id_; 70 const std::string local_id_;
69 const std::string resource_id_; 71 const std::string resource_id_;
70 const int64 changestamp_; 72 const int64_t changestamp_;
71 }; 73 };
72 74
73 // Class to represent a change list. 75 // Class to represent a change list.
74 class ChangeList { 76 class ChangeList {
75 public: 77 public:
76 ChangeList(); // For tests. 78 ChangeList(); // For tests.
77 explicit ChangeList(const google_apis::ChangeList& change_list); 79 explicit ChangeList(const google_apis::ChangeList& change_list);
78 explicit ChangeList(const google_apis::FileList& file_list); 80 explicit ChangeList(const google_apis::FileList& file_list);
79 ~ChangeList(); 81 ~ChangeList();
80 82
81 const std::vector<ResourceEntry>& entries() const { return entries_; } 83 const std::vector<ResourceEntry>& entries() const { return entries_; }
82 std::vector<ResourceEntry>* mutable_entries() { return &entries_; } 84 std::vector<ResourceEntry>* mutable_entries() { return &entries_; }
83 const std::vector<std::string>& parent_resource_ids() const { 85 const std::vector<std::string>& parent_resource_ids() const {
84 return parent_resource_ids_; 86 return parent_resource_ids_;
85 } 87 }
86 std::vector<std::string>* mutable_parent_resource_ids() { 88 std::vector<std::string>* mutable_parent_resource_ids() {
87 return &parent_resource_ids_; 89 return &parent_resource_ids_;
88 } 90 }
89 const GURL& next_url() const { return next_url_; } 91 const GURL& next_url() const { return next_url_; }
90 int64 largest_changestamp() const { return largest_changestamp_; } 92 int64_t largest_changestamp() const { return largest_changestamp_; }
91 93
92 void set_largest_changestamp(int64 largest_changestamp) { 94 void set_largest_changestamp(int64_t largest_changestamp) {
93 largest_changestamp_ = largest_changestamp; 95 largest_changestamp_ = largest_changestamp;
94 } 96 }
95 97
96 private: 98 private:
97 std::vector<ResourceEntry> entries_; 99 std::vector<ResourceEntry> entries_;
98 std::vector<std::string> parent_resource_ids_; 100 std::vector<std::string> parent_resource_ids_;
99 GURL next_url_; 101 GURL next_url_;
100 int64 largest_changestamp_; 102 int64_t largest_changestamp_;
101 103
102 DISALLOW_COPY_AND_ASSIGN(ChangeList); 104 DISALLOW_COPY_AND_ASSIGN(ChangeList);
103 }; 105 };
104 106
105 // ChangeListProcessor is used to process change lists, or full resource 107 // ChangeListProcessor is used to process change lists, or full resource
106 // lists from WAPI (codename for Documents List API) or Google Drive API, and 108 // lists from WAPI (codename for Documents List API) or Google Drive API, and
107 // updates the resource metadata stored locally. 109 // updates the resource metadata stored locally.
108 class ChangeListProcessor { 110 class ChangeListProcessor {
109 public: 111 public:
110 ChangeListProcessor(ResourceMetadata* resource_metadata, 112 ChangeListProcessor(ResourceMetadata* resource_metadata,
(...skipping 28 matching lines...) Expand all
139 141
140 private: 142 private:
141 typedef std::map<std::string /* resource_id */, ResourceEntry> 143 typedef std::map<std::string /* resource_id */, ResourceEntry>
142 ResourceEntryMap; 144 ResourceEntryMap;
143 typedef std::map<std::string /* resource_id */, 145 typedef std::map<std::string /* resource_id */,
144 std::string /* parent_resource_id*/> ParentResourceIdMap; 146 std::string /* parent_resource_id*/> ParentResourceIdMap;
145 147
146 // Applies the pre-processed metadata from entry_map_ onto the resource 148 // Applies the pre-processed metadata from entry_map_ onto the resource
147 // metadata. |about_resource| must not be null. 149 // metadata. |about_resource| must not be null.
148 FileError ApplyEntryMap( 150 FileError ApplyEntryMap(
149 int64 changestamp, 151 int64_t changestamp,
150 scoped_ptr<google_apis::AboutResource> about_resource); 152 scoped_ptr<google_apis::AboutResource> about_resource);
151 153
152 // Apply |entry| to resource_metadata_. 154 // Apply |entry| to resource_metadata_.
153 FileError ApplyEntry(const ResourceEntry& entry); 155 FileError ApplyEntry(const ResourceEntry& entry);
154 156
155 // Adds the directories changed by the update on |entry| to |changed_dirs_|. 157 // Adds the directories changed by the update on |entry| to |changed_dirs_|.
156 void UpdateChangedDirs(const ResourceEntry& entry); 158 void UpdateChangedDirs(const ResourceEntry& entry);
157 159
158 ResourceMetadata* resource_metadata_; // Not owned. 160 ResourceMetadata* resource_metadata_; // Not owned.
159 base::CancellationFlag* in_shutdown_; // Not owned. 161 base::CancellationFlag* in_shutdown_; // Not owned.
160 162
161 ResourceEntryMap entry_map_; 163 ResourceEntryMap entry_map_;
162 ParentResourceIdMap parent_resource_id_map_; 164 ParentResourceIdMap parent_resource_id_map_;
163 scoped_ptr<FileChange> changed_files_; 165 scoped_ptr<FileChange> changed_files_;
164 166
165 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor); 167 DISALLOW_COPY_AND_ASSIGN(ChangeListProcessor);
166 }; 168 };
167 169
168 } // namespace internal 170 } // namespace internal
169 } // namespace drive 171 } // namespace drive
170 172
171 #endif // COMPONENTS_DRIVE_CHANGE_LIST_PROCESSOR_H_ 173 #endif // COMPONENTS_DRIVE_CHANGE_LIST_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/drive/change_list_loader_unittest.cc ('k') | components/drive/change_list_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698