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 CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "chrome/browser/chromeos/drive/drive_file_error.h" | 17 #include "chrome/browser/chromeos/drive/drive_file_error.h" |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
21 } | 21 } |
22 | 22 |
23 namespace gdata { | 23 namespace gdata { |
| 24 class DocumentEntry; |
| 25 } |
| 26 |
| 27 namespace drive { |
24 | 28 |
25 struct CreateDBParams; | 29 struct CreateDBParams; |
26 class DocumentEntry; | |
27 class DriveDirectory; | 30 class DriveDirectory; |
28 class DriveEntry; | 31 class DriveEntry; |
29 class DriveEntryProto; | 32 class DriveEntryProto; |
30 class DriveFile; | 33 class DriveFile; |
31 class ResourceMetadataDB; | 34 class ResourceMetadataDB; |
32 | 35 |
33 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; | 36 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; |
34 | 37 |
35 // File type on the drive file system can be either a regular file or | 38 // File type on the drive file system can be either a regular file or |
36 // a hosted document. | 39 // a hosted document. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 144 |
142 // Largest change timestamp that was the source of content for the current | 145 // Largest change timestamp that was the source of content for the current |
143 // state of the root directory. | 146 // state of the root directory. |
144 int64 largest_changestamp() const { return largest_changestamp_; } | 147 int64 largest_changestamp() const { return largest_changestamp_; } |
145 void set_largest_changestamp(int64 value) { largest_changestamp_ = value; } | 148 void set_largest_changestamp(int64 value) { largest_changestamp_ = value; } |
146 | 149 |
147 // The root directory content origin. | 150 // The root directory content origin. |
148 ContentOrigin origin() const { return origin_; } | 151 ContentOrigin origin() const { return origin_; } |
149 void set_origin(ContentOrigin value) { origin_ = value; } | 152 void set_origin(ContentOrigin value) { origin_ = value; } |
150 | 153 |
151 // Creates a DriveEntry from a DocumentEntry. | 154 // Creates a DriveEntry from a gdata::DocumentEntry. |
152 scoped_ptr<DriveEntry> FromDocumentEntry(const DocumentEntry& doc); | 155 scoped_ptr<DriveEntry> FromDocumentEntry(const gdata::DocumentEntry& doc); |
153 | 156 |
154 // Creates a DriveFile instance. | 157 // Creates a DriveFile instance. |
155 scoped_ptr<DriveFile> CreateDriveFile(); | 158 scoped_ptr<DriveFile> CreateDriveFile(); |
156 | 159 |
157 // Creates a DriveDirectory instance. | 160 // Creates a DriveDirectory instance. |
158 scoped_ptr<DriveDirectory> CreateDriveDirectory(); | 161 scoped_ptr<DriveDirectory> CreateDriveDirectory(); |
159 | 162 |
160 // Sets root directory resource id and initialize the root entry. | 163 // Sets root directory resource id and initialize the root entry. |
161 void InitializeRootEntry(const std::string& root_id); | 164 void InitializeRootEntry(const std::string& root_id); |
162 | 165 |
163 // Add |doc entry| to directory with path |directory_path| and invoke the | 166 // Add |doc entry| to directory with path |directory_path| and invoke the |
164 // callback asynchronously. | 167 // callback asynchronously. |
165 // |callback| must not be null. | 168 // |callback| must not be null. |
166 void AddEntryToDirectory(const FilePath& directory_path, | 169 void AddEntryToDirectory(const FilePath& directory_path, |
167 scoped_ptr<DocumentEntry> doc_entry, | 170 scoped_ptr<gdata::DocumentEntry> doc_entry, |
168 const FileMoveCallback& callback); | 171 const FileMoveCallback& callback); |
169 | 172 |
170 // Moves entry specified by |file_path| to the directory specified by | 173 // Moves entry specified by |file_path| to the directory specified by |
171 // |directory_path| and calls the callback asynchronously. Removes the entry | 174 // |directory_path| and calls the callback asynchronously. Removes the entry |
172 // from the previous parent. | 175 // from the previous parent. |
173 // |callback| must not be null. | 176 // |callback| must not be null. |
174 void MoveEntryToDirectory(const FilePath& file_path, | 177 void MoveEntryToDirectory(const FilePath& file_path, |
175 const FilePath& directory_path, | 178 const FilePath& directory_path, |
176 const FileMoveCallback& callback); | 179 const FileMoveCallback& callback); |
177 | 180 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 void GetEntryInfoPairByPaths( | 234 void GetEntryInfoPairByPaths( |
232 const FilePath& first_path, | 235 const FilePath& first_path, |
233 const FilePath& second_path, | 236 const FilePath& second_path, |
234 const GetEntryInfoPairCallback& callback); | 237 const GetEntryInfoPairCallback& callback); |
235 | 238 |
236 // Replaces a file entry with the same resource id as |doc_entry| by deleting | 239 // Replaces a file entry with the same resource id as |doc_entry| by deleting |
237 // the existing entry, creating a new DriveFile from |doc_entry|, and adding | 240 // the existing entry, creating a new DriveFile from |doc_entry|, and adding |
238 // it to the parent of the old entry. For directories, this just returns the | 241 // it to the parent of the old entry. For directories, this just returns the |
239 // existing directory proto. |callback| is run with the error, file path and | 242 // existing directory proto. |callback| is run with the error, file path and |
240 // proto of the entry. |callback| must not be null. | 243 // proto of the entry. |callback| must not be null. |
241 void RefreshFile(scoped_ptr<DocumentEntry> doc_entry, | 244 void RefreshFile(scoped_ptr<gdata::DocumentEntry> doc_entry, |
242 const GetEntryInfoWithFilePathCallback& callback); | 245 const GetEntryInfoWithFilePathCallback& callback); |
243 | 246 |
244 // Removes all child files of |directory| and replace with file_map. | 247 // Removes all child files of |directory| and replace with file_map. |
245 // |callback| is called with the directory path. |callback| must not be null. | 248 // |callback| is called with the directory path. |callback| must not be null. |
246 void RefreshDirectory(const std::string& directory_resource_id, | 249 void RefreshDirectory(const std::string& directory_resource_id, |
247 const ResourceMap& file_map, | 250 const ResourceMap& file_map, |
248 const FileMoveCallback& callback); | 251 const FileMoveCallback& callback); |
249 | 252 |
250 // Serializes/Parses to/from string via proto classes. | 253 // Serializes/Parses to/from string via proto classes. |
251 void SerializeToString(std::string* serialized_proto) const; | 254 void SerializeToString(std::string* serialized_proto) const; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 int64 largest_changestamp_; // Stored in the serialized proto. | 311 int64 largest_changestamp_; // Stored in the serialized proto. |
309 ContentOrigin origin_; | 312 ContentOrigin origin_; |
310 | 313 |
311 // This should remain the last member so it'll be destroyed first and | 314 // This should remain the last member so it'll be destroyed first and |
312 // invalidate its weak pointers before other members are destroyed. | 315 // invalidate its weak pointers before other members are destroyed. |
313 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; | 316 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; |
314 | 317 |
315 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); | 318 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); |
316 }; | 319 }; |
317 | 320 |
318 } // namespace gdata | 321 } // namespace drive |
319 | 322 |
320 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ | 323 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ |
OLD | NEW |