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

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

Issue 10873005: Rename GDataDirectoryService to DriveResourceMetadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DriveDirectoryService to DriveResourceMetadata Created 8 years, 4 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
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_GDATA_GDATA_DIRECTORY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_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.h" 12 #include "base/callback.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/gdata/gdata_errorcode.h" 17 #include "chrome/browser/chromeos/gdata/gdata_errorcode.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 24
25 struct CreateDBParams; 25 struct CreateDBParams;
26 class DocumentEntry; 26 class DocumentEntry;
27 class DriveDirectory; 27 class DriveDirectory;
28 class DriveEntry; 28 class DriveEntry;
29 class DriveEntryProto; 29 class DriveEntryProto;
30 class DriveFile; 30 class DriveFile;
31 class ResourceMetadataDB; 31 class ResourceMetadataDB;
32 32
33 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; 33 typedef std::vector<DriveEntryProto> DriveEntryProtoVector;
34 34
35 // File type on the gdata file system can be either a regular file or 35 // File type on the gdata file system can be either a regular file or
achuithb 2012/08/22 09:41:06 drive
kochi 2012/08/22 10:04:56 Done.
36 // a hosted document. 36 // a hosted document.
37 enum DriveFileType { 37 enum DriveFileType {
38 REGULAR_FILE, 38 REGULAR_FILE,
39 HOSTED_DOCUMENT, 39 HOSTED_DOCUMENT,
40 }; 40 };
41 41
42 // The root directory content origin. 42 // The root directory content origin.
43 enum ContentOrigin { 43 enum ContentOrigin {
44 UNINITIALIZED, 44 UNINITIALIZED,
45 // Content is currently loading from somewhere. Needs to wait. 45 // Content is currently loading from somewhere. Needs to wait.
46 INITIALIZING, 46 INITIALIZING,
47 // Content is initialized, but during refreshing. 47 // Content is initialized, but during refreshing.
48 REFRESHING, 48 REFRESHING,
49 // Content is initialized from disk cache. 49 // Content is initialized from disk cache.
50 FROM_CACHE, 50 FROM_CACHE,
51 // Content is initialized from the direct server response. 51 // Content is initialized from the direct server response.
52 FROM_SERVER, 52 FROM_SERVER,
53 }; 53 };
54 54
55 // The root directory name used for the Google Drive file system tree. The 55 // The root directory name used for the Google Drive file system tree. The
56 // name is used in URLs for the file manager, hence user-visible. 56 // name is used in URLs for the file manager, hence user-visible.
57 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("drive"); 57 const FilePath::CharType kDriveRootDirectory[] = FILE_PATH_LITERAL("drive");
58 58
59 // The resource ID for the root directory is defined in the spec: 59 // The resource ID for the root directory is defined in the spec:
60 // https://developers.google.com/google-apps/documents-list/ 60 // https://developers.google.com/google-apps/documents-list/
61 const char kGDataRootDirectoryResourceId[] = "folder:root"; 61 const char kDriveRootDirectoryResourceId[] = "folder:root";
62 62
63 // This should be incremented when incompatibility change is made in 63 // This should be incremented when incompatibility change is made in
64 // drive.proto. 64 // drive.proto.
65 const int32 kProtoVersion = 2; 65 const int32 kProtoVersion = 2;
66 66
67 // Callback type used to get result of file search. 67 // Callback type used to get result of file search.
68 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL. 68 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL.
69 typedef base::Callback<void(GDataFileError error, DriveEntry* entry)> 69 typedef base::Callback<void(GDataFileError error, DriveEntry* entry)>
70 FindEntryCallback; 70 FindEntryCallback;
71 71
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 EntryInfoResult first; 119 EntryInfoResult first;
120 EntryInfoResult second; // Only filled if the first entry is found. 120 EntryInfoResult second; // Only filled if the first entry is found.
121 }; 121 };
122 122
123 // Used to receive the result from GetEntryInfoPairCallback(). 123 // Used to receive the result from GetEntryInfoPairCallback().
124 typedef base::Callback<void(scoped_ptr<EntryInfoPairResult> pair_result)> 124 typedef base::Callback<void(scoped_ptr<EntryInfoPairResult> pair_result)>
125 GetEntryInfoPairCallback; 125 GetEntryInfoPairCallback;
126 126
127 // Class to handle DriveEntry* lookups, add/remove DriveEntry*. 127 // Class to handle DriveEntry* lookups, add/remove DriveEntry*.
128 class GDataDirectoryService { 128 class DriveResourceMetadata {
129 public: 129 public:
130 // Callback for GetEntryByResourceIdAsync. 130 // Callback for GetEntryByResourceIdAsync.
131 typedef base::Callback<void(DriveEntry* entry)> GetEntryByResourceIdCallback; 131 typedef base::Callback<void(DriveEntry* entry)> GetEntryByResourceIdCallback;
132 132
133 // Map of resource id and serialized DriveEntry. 133 // Map of resource id and serialized DriveEntry.
134 typedef std::map<std::string, std::string> SerializedMap; 134 typedef std::map<std::string, std::string> SerializedMap;
135 // Map of resource id strings to DriveEntry*. 135 // Map of resource id strings to DriveEntry*.
136 typedef std::map<std::string, DriveEntry*> ResourceMap; 136 typedef std::map<std::string, DriveEntry*> ResourceMap;
137 137
138 GDataDirectoryService(); 138 DriveResourceMetadata();
139 ~GDataDirectoryService(); 139 ~DriveResourceMetadata();
140 140
141 DriveDirectory* root() { return root_.get(); } 141 DriveDirectory* root() { return root_.get(); }
142 142
143 // Last time when we dumped serialized file system to disk. 143 // Last time when we dumped serialized file system to disk.
144 const base::Time& last_serialized() const { return last_serialized_; } 144 const base::Time& last_serialized() const { return last_serialized_; }
145 void set_last_serialized(const base::Time& time) { last_serialized_ = time; } 145 void set_last_serialized(const base::Time& time) { last_serialized_ = time; }
146 // Size of serialized file system on disk in bytes. 146 // Size of serialized file system on disk in bytes.
147 const size_t serialized_size() const { return serialized_size_; } 147 const size_t serialized_size() const { return serialized_size_; }
148 void set_serialized_size(size_t size) { serialized_size_ = size; } 148 void set_serialized_size(size_t size) { serialized_size_ = size; }
149 149
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 DriveEntry* old_entry); 302 DriveEntry* old_entry);
303 303
304 // Removes all child files of |directory| and replace with file_map. 304 // Removes all child files of |directory| and replace with file_map.
305 // |callback| may not be null. 305 // |callback| may not be null.
306 static void RefreshDirectoryInternal(const ResourceMap& file_map, 306 static void RefreshDirectoryInternal(const ResourceMap& file_map,
307 const FileMoveCallback& callback, 307 const FileMoveCallback& callback,
308 DriveEntry* directory_entry); 308 DriveEntry* directory_entry);
309 309
310 // Private data members. 310 // Private data members.
311 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 311 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
312 scoped_ptr<ResourceMetadataDB> directory_service_db_; 312 scoped_ptr<ResourceMetadataDB> resource_metadata_db_;
313 313
314 ResourceMap resource_map_; 314 ResourceMap resource_map_;
315 315
316 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto. 316 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto.
317 317
318 base::Time last_serialized_; 318 base::Time last_serialized_;
319 size_t serialized_size_; 319 size_t serialized_size_;
320 int64 largest_changestamp_; // Stored in the serialized proto. 320 int64 largest_changestamp_; // Stored in the serialized proto.
321 ContentOrigin origin_; 321 ContentOrigin origin_;
322 322
323 // This should remain the last member so it'll be destroyed first and 323 // This should remain the last member so it'll be destroyed first and
324 // invalidate its weak pointers before other members are destroyed. 324 // invalidate its weak pointers before other members are destroyed.
325 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; 325 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
326 326
327 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); 327 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
328 }; 328 };
329 329
330 } // namespace gdata 330 } // namespace gdata
331 331
332 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_H_ 332 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698