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

Side by Side Diff: chrome/browser/chromeos/drive/drive_resource_metadata.h

Issue 11227020: Set root resource ID upon full feed update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_resource_metadata.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Content is initialized from the direct server response. 54 // Content is initialized from the direct server response.
55 FROM_SERVER, 55 FROM_SERVER,
56 }; 56 };
57 57
58 // The root directory name used for the Google Drive file system tree. The 58 // The root directory name used for the Google Drive file system tree. The
59 // name is used in URLs for the file manager, hence user-visible. 59 // name is used in URLs for the file manager, hence user-visible.
60 const FilePath::CharType kDriveRootDirectory[] = FILE_PATH_LITERAL("drive"); 60 const FilePath::CharType kDriveRootDirectory[] = FILE_PATH_LITERAL("drive");
61 61
62 // The resource ID for the root directory is defined in the spec: 62 // The resource ID for the root directory is defined in the spec:
63 // https://developers.google.com/google-apps/documents-list/ 63 // https://developers.google.com/google-apps/documents-list/
64 const char kDriveRootDirectoryResourceId[] = "folder:root"; 64 const char kDriveRootDirectoryResourceId[] = "folder:root";
achuithb 2012/10/22 09:27:56 We should probably move this to the cc file in ano
kochi 2012/10/23 06:08:46 Done.
65 65
66 // This should be incremented when incompatibility change is made in 66 // This should be incremented when incompatibility change is made in
67 // drive.proto. 67 // drive.proto.
68 const int32 kProtoVersion = 2; 68 const int32 kProtoVersion = 2;
69 69
70 // Used for file operations like removing files. 70 // Used for file operations like removing files.
71 typedef base::Callback<void(DriveFileError error)> 71 typedef base::Callback<void(DriveFileError error)>
72 FileOperationCallback; 72 FileOperationCallback;
73 73
74 // Callback similar to FileOperationCallback but with a given |file_path|. 74 // Callback similar to FileOperationCallback but with a given |file_path|.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void SerializeToString(std::string* serialized_proto) const; 254 void SerializeToString(std::string* serialized_proto) const;
255 bool ParseFromString(const std::string& serialized_proto); 255 bool ParseFromString(const std::string& serialized_proto);
256 256
257 // Restores from and saves to database, calling |callback| asynchronously. 257 // Restores from and saves to database, calling |callback| asynchronously.
258 // |callback| must not be null. 258 // |callback| must not be null.
259 void InitFromDB(const FilePath& db_path, 259 void InitFromDB(const FilePath& db_path,
260 base::SequencedTaskRunner* blocking_task_runner, 260 base::SequencedTaskRunner* blocking_task_runner,
261 const FileOperationCallback& callback); 261 const FileOperationCallback& callback);
262 void SaveToDB(); 262 void SaveToDB();
263 263
264 // Returns the resource ID of the root directory or empty string if it is
265 // not initialized.
266 const std::string& root_resource_id() const { return root_resource_id_; }
267
264 private: 268 private:
265 // Initializes the resource map using serialized_resources fetched from the 269 // Initializes the resource map using serialized_resources fetched from the
266 // database. 270 // database.
267 // |callback| must not be null. 271 // |callback| must not be null.
268 void InitResourceMap(CreateDBParams* create_params, 272 void InitResourceMap(CreateDBParams* create_params,
269 const FileOperationCallback& callback); 273 const FileOperationCallback& callback);
270 274
271 // Clears root_ and the resource map. 275 // Clears root_ and the resource map.
272 void ClearRoot(); 276 void ClearRoot();
273 277
(...skipping 25 matching lines...) Expand all
299 DriveEntry* FindEntryByPathSync(const FilePath& file_path); 303 DriveEntry* FindEntryByPathSync(const FilePath& file_path);
300 304
301 // Private data members. 305 // Private data members.
302 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 306 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
303 scoped_ptr<ResourceMetadataDB> resource_metadata_db_; 307 scoped_ptr<ResourceMetadataDB> resource_metadata_db_;
304 308
305 ResourceMap resource_map_; 309 ResourceMap resource_map_;
306 310
307 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto. 311 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto.
308 312
313 // Retains special resource ID for the root directory.
314 // This must be initialized only once using |InitializeRootEntry()|.
315 std::string root_resource_id_;
316
309 base::Time last_serialized_; 317 base::Time last_serialized_;
310 size_t serialized_size_; 318 size_t serialized_size_;
311 int64 largest_changestamp_; // Stored in the serialized proto. 319 int64 largest_changestamp_; // Stored in the serialized proto.
312 ContentOrigin origin_; 320 ContentOrigin origin_;
313 321
314 // This should remain the last member so it'll be destroyed first and 322 // This should remain the last member so it'll be destroyed first and
315 // invalidate its weak pointers before other members are destroyed. 323 // invalidate its weak pointers before other members are destroyed.
316 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; 324 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
317 325
318 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); 326 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
319 }; 327 };
320 328
321 } // namespace drive 329 } // namespace drive
322 330
323 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 331 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_resource_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698