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

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

Issue 10836354: Rename GData* to Drive* in gdata.proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. 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_GDATA_DIRECTORY_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_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 DriveEntryProto;
28 class GDataDirectory;
27 class GDataEntry; 29 class GDataEntry;
28 class GDataEntryProto;
29 class GDataFile; 30 class GDataFile;
30 class GDataDirectory;
31 class ResourceMetadataDB; 31 class ResourceMetadataDB;
32 32
33 typedef std::vector<GDataEntryProto> GDataEntryProtoVector; 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
36 // a hosted document. 36 // a hosted document.
37 enum GDataFileType { 37 enum GDataFileType {
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 {
(...skipping 11 matching lines...) Expand all
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 kGDataRootDirectory[] = 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 kGDataRootDirectoryResourceId[] = "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 // gdata.proto. 64 // gdata.proto.
65 const int32 kProtoVersion = 2; 65 const int32 kProtoVersion = 2;
achuithb 2012/08/21 09:23:45 I think you also need to bump this number to 3.
kochi 2012/08/21 09:37:34 I don't think so. The name of the proto is changed
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, GDataEntry* entry)> 69 typedef base::Callback<void(GDataFileError error, GDataEntry* entry)>
70 FindEntryCallback; 70 FindEntryCallback;
71 71
72 // Used for file operations like removing files. 72 // Used for file operations like removing files.
73 typedef base::Callback<void(GDataFileError error)> 73 typedef base::Callback<void(GDataFileError error)>
74 FileOperationCallback; 74 FileOperationCallback;
75 75
76 // Callback similar to FileOperationCallback but with a given |file_path|. 76 // Callback similar to FileOperationCallback but with a given |file_path|.
77 // Used for operations that change a file path like moving files. 77 // Used for operations that change a file path like moving files.
78 typedef base::Callback<void(GDataFileError error, 78 typedef base::Callback<void(GDataFileError error,
79 const FilePath& file_path)> 79 const FilePath& file_path)>
80 FileMoveCallback; 80 FileMoveCallback;
81 81
82 // Used to get entry info from the file system. 82 // Used to get entry info from the file system.
83 // If |error| is not GDATA_FILE_OK, |entry_info| is set to NULL. 83 // If |error| is not GDATA_FILE_OK, |entry_info| is set to NULL.
84 typedef base::Callback<void(GDataFileError error, 84 typedef base::Callback<void(GDataFileError error,
85 scoped_ptr<GDataEntryProto> entry_proto)> 85 scoped_ptr<DriveEntryProto> entry_proto)>
86 GetEntryInfoCallback; 86 GetEntryInfoCallback;
87 87
88 typedef base::Callback<void(GDataFileError error, 88 typedef base::Callback<void(GDataFileError error,
89 scoped_ptr<GDataEntryProtoVector> entries)> 89 scoped_ptr<DriveEntryProtoVector> entries)>
90 ReadDirectoryCallback; 90 ReadDirectoryCallback;
91 91
92 // Used to get entry info from the file system, with the Drive file path. 92 // Used to get entry info from the file system, with the Drive file path.
93 // If |error| is not GDATA_FILE_OK, |entry_proto| is set to NULL. 93 // If |error| is not GDATA_FILE_OK, |entry_proto| is set to NULL.
94 // 94 //
95 // |drive_file_path| parameter is provided as GDataEntryProto does not contain 95 // |drive_file_path| parameter is provided as DriveEntryProto does not contain
96 // the Drive file path (i.e. only contains the base name without parent 96 // the Drive file path (i.e. only contains the base name without parent
97 // directory names). 97 // directory names).
98 typedef base::Callback<void(GDataFileError error, 98 typedef base::Callback<void(GDataFileError error,
99 const FilePath& drive_file_path, 99 const FilePath& drive_file_path,
100 scoped_ptr<GDataEntryProto> entry_proto)> 100 scoped_ptr<DriveEntryProto> entry_proto)>
101 GetEntryInfoWithFilePathCallback; 101 GetEntryInfoWithFilePathCallback;
102 102
103 // This is a part of EntryInfoPairResult. 103 // This is a part of EntryInfoPairResult.
104 struct EntryInfoResult { 104 struct EntryInfoResult {
105 EntryInfoResult(); 105 EntryInfoResult();
106 ~EntryInfoResult(); 106 ~EntryInfoResult();
107 107
108 FilePath path; 108 FilePath path;
109 GDataFileError error; 109 GDataFileError error;
110 scoped_ptr<GDataEntryProto> proto; 110 scoped_ptr<DriveEntryProto> proto;
111 }; 111 };
112 112
113 // The result of GetEntryInfoPairCallback(). Used to get a pair of entries 113 // The result of GetEntryInfoPairCallback(). Used to get a pair of entries
114 // in one function call. 114 // in one function call.
115 struct EntryInfoPairResult { 115 struct EntryInfoPairResult {
116 EntryInfoPairResult(); 116 EntryInfoPairResult();
117 ~EntryInfoPairResult(); 117 ~EntryInfoPairResult();
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.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 GDataFile* CreateGDataFile(); 163 GDataFile* CreateGDataFile();
164 164
165 // Creates a GDataDirectory instance. 165 // Creates a GDataDirectory instance.
166 GDataDirectory* CreateGDataDirectory(); 166 GDataDirectory* CreateGDataDirectory();
167 167
168 // Sets root directory resource id and initialize the root entry. 168 // Sets root directory resource id and initialize the root entry.
169 void InitializeRootEntry(const std::string& root_id); 169 void InitializeRootEntry(const std::string& root_id);
170 170
171 // Add |new entry| to |directory| and invoke the callback asynchronously. 171 // Add |new entry| to |directory| and invoke the callback asynchronously.
172 // |callback| may not be null. 172 // |callback| may not be null.
173 // TODO(achuith,satorux): Use GDataEntryProto instead for new_entry. 173 // TODO(achuith,satorux): Use DriveEntryProto instead for new_entry.
174 // crbug.com/142048 174 // crbug.com/142048
175 void AddEntryToDirectory(GDataDirectory* directory, 175 void AddEntryToDirectory(GDataDirectory* directory,
176 GDataEntry* new_entry, 176 GDataEntry* new_entry,
177 const FileMoveCallback& callback); 177 const FileMoveCallback& callback);
178 178
179 // Moves |entry| to |directory_path| asynchronously. Removes entry from 179 // Moves |entry| to |directory_path| asynchronously. Removes entry from
180 // previous parent. Must be called on UI thread. |callback| is called on the 180 // previous parent. Must be called on UI thread. |callback| is called on the
181 // UI thread. |callback| may not be null. 181 // UI thread. |callback| may not be null.
182 void MoveEntryToDirectory(const FilePath& directory_path, 182 void MoveEntryToDirectory(const FilePath& directory_path,
183 GDataEntry* entry, 183 GDataEntry* entry,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const std::string& serialized_proto); 277 const std::string& serialized_proto);
278 278
279 // Continues with GetEntryInfoPairByPaths after the first GDataEntry has been 279 // Continues with GetEntryInfoPairByPaths after the first GDataEntry has been
280 // asynchronously fetched. This fetches the second GDataEntry only if the 280 // asynchronously fetched. This fetches the second GDataEntry only if the
281 // first was found. 281 // first was found.
282 void GetEntryInfoPairByPathsAfterGetFirst( 282 void GetEntryInfoPairByPathsAfterGetFirst(
283 const FilePath& first_path, 283 const FilePath& first_path,
284 const FilePath& second_path, 284 const FilePath& second_path,
285 const GetEntryInfoPairCallback& callback, 285 const GetEntryInfoPairCallback& callback,
286 GDataFileError error, 286 GDataFileError error,
287 scoped_ptr<GDataEntryProto> entry_proto); 287 scoped_ptr<DriveEntryProto> entry_proto);
288 288
289 // Continues with GetIntroInfoPairByPaths after the second GDataEntry has been 289 // Continues with GetIntroInfoPairByPaths after the second GDataEntry has been
290 // asynchronously fetched. 290 // asynchronously fetched.
291 void GetEntryInfoPairByPathsAfterGetSecond( 291 void GetEntryInfoPairByPathsAfterGetSecond(
292 const FilePath& second_path, 292 const FilePath& second_path,
293 const GetEntryInfoPairCallback& callback, 293 const GetEntryInfoPairCallback& callback,
294 scoped_ptr<EntryInfoPairResult> result, 294 scoped_ptr<EntryInfoPairResult> result,
295 GDataFileError error, 295 GDataFileError error,
296 scoped_ptr<GDataEntryProto> entry_proto); 296 scoped_ptr<DriveEntryProto> entry_proto);
297 297
298 // These internal functions need friend access to private GDataDirectory 298 // These internal functions need friend access to private GDataDirectory
299 // methods. 299 // methods.
300 // Replaces file entry |old_entry| with its fresh value |fresh_file|. 300 // Replaces file entry |old_entry| with its fresh value |fresh_file|.
301 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, 301 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file,
302 GDataEntry* old_entry); 302 GDataEntry* 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,
(...skipping 17 matching lines...) Expand all
324 // This should remain the last member so it'll be destroyed first and 324 // This should remain the last member so it'll be destroyed first and
325 // invalidate its weak pointers before other members are destroyed. 325 // invalidate its weak pointers before other members are destroyed.
326 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; 326 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_;
327 327
328 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); 328 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService);
329 }; 329 };
330 330
331 } // namespace gdata 331 } // namespace gdata
332 332
333 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_H_ 333 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DIRECTORY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698