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_GDATA_GDATA_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 32 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
33 #include "content/public/browser/notification_observer.h" | 33 #include "content/public/browser/notification_observer.h" |
34 | 34 |
35 namespace base { | 35 namespace base { |
36 class WaitableEvent; | 36 class WaitableEvent; |
37 } | 37 } |
38 | 38 |
39 namespace gdata { | 39 namespace gdata { |
40 | 40 |
41 class DocumentsServiceInterface; | 41 class DocumentsServiceInterface; |
| 42 class GDataFileProto; |
42 struct UploadFileInfo; | 43 struct UploadFileInfo; |
43 | 44 |
44 namespace { | 45 namespace { |
45 struct LoadRootFeedParams; | 46 struct LoadRootFeedParams; |
46 } | 47 } |
47 | 48 |
48 // Used for file operations like removing files. | 49 // Used for file operations like removing files. |
49 typedef base::Callback<void(base::PlatformFileError error)> | 50 typedef base::Callback<void(base::PlatformFileError error)> |
50 FileOperationCallback; | 51 FileOperationCallback; |
51 | 52 |
52 // Callback for completion of cache operation. | 53 // Callback for completion of cache operation. |
53 typedef base::Callback<void(base::PlatformFileError error, | 54 typedef base::Callback<void(base::PlatformFileError error, |
54 const std::string& resource_id, | 55 const std::string& resource_id, |
55 const std::string& md5)> CacheOperationCallback; | 56 const std::string& md5)> CacheOperationCallback; |
56 | 57 |
57 // Callback for GetFileFromCache. | 58 // Callback for GetFileFromCache. |
58 typedef base::Callback<void(base::PlatformFileError error, | 59 typedef base::Callback<void(base::PlatformFileError error, |
59 const std::string& resource_id, | 60 const std::string& resource_id, |
60 const std::string& md5, | 61 const std::string& md5, |
61 const FilePath& cache_file_path)> | 62 const FilePath& cache_file_path)> |
62 GetFileFromCacheCallback; | 63 GetFileFromCacheCallback; |
63 | 64 |
64 // Used to get files from the file system. | 65 // Used to get files from the file system. |
65 typedef base::Callback<void(base::PlatformFileError error, | 66 typedef base::Callback<void(base::PlatformFileError error, |
66 const FilePath& file_path, | 67 const FilePath& file_path, |
67 const std::string& mime_type, | 68 const std::string& mime_type, |
68 GDataFileType file_type)> | 69 GDataFileType file_type)> |
69 GetFileCallback; | 70 GetFileCallback; |
70 | 71 |
| 72 // Used to get file info from the file system. |
| 73 // If |error| is not PLATFORM_FILE_OK, |file_info| is set to NULL. |
| 74 typedef base::Callback<void(base::PlatformFileError error, |
| 75 scoped_ptr<GDataFileProto> file_proto)> |
| 76 GetFileInfoCallback; |
| 77 |
71 // Callback for SetMountedState. | 78 // Callback for SetMountedState. |
72 typedef base::Callback<void(base::PlatformFileError error, | 79 typedef base::Callback<void(base::PlatformFileError error, |
73 const FilePath& file_path)> | 80 const FilePath& file_path)> |
74 SetMountedStateCallback; | 81 SetMountedStateCallback; |
75 | 82 |
76 // Used for file operations like removing files. | 83 // Used for file operations like removing files. |
77 typedef base::Callback<void(base::PlatformFileError error, | 84 typedef base::Callback<void(base::PlatformFileError error, |
78 base::ListValue* feed_list)> | 85 base::ListValue* feed_list)> |
79 GetJsonDocumentCallback; | 86 GetJsonDocumentCallback; |
80 | 87 |
(...skipping 11 matching lines...) Expand all Loading... |
92 // Used by GDataFileSystem::GetDocumentResourceIdOnIOThreadPool to return | 99 // Used by GDataFileSystem::GetDocumentResourceIdOnIOThreadPool to return |
93 // the resource ID read from a document JSON file on the local file system. | 100 // the resource ID read from a document JSON file on the local file system. |
94 typedef base::Callback<void(const std::string& resource_id)> | 101 typedef base::Callback<void(const std::string& resource_id)> |
95 GetDocumentResourceIdCallback; | 102 GetDocumentResourceIdCallback; |
96 | 103 |
97 // Callback for GetCacheState operation. | 104 // Callback for GetCacheState operation. |
98 typedef base::Callback<void(base::PlatformFileError error, | 105 typedef base::Callback<void(base::PlatformFileError error, |
99 int cache_state)> GetCacheStateCallback; | 106 int cache_state)> GetCacheStateCallback; |
100 | 107 |
101 // Helper structure used for extracting key properties from GDataFile object. | 108 // Helper structure used for extracting key properties from GDataFile object. |
| 109 // TODO(satorux): Remove this as part of crosbug.com/30066 |
102 struct GDataFileProperties { | 110 struct GDataFileProperties { |
103 GDataFileProperties(); | 111 GDataFileProperties(); |
104 ~GDataFileProperties(); | 112 ~GDataFileProperties(); |
105 | 113 |
106 base::PlatformFileInfo file_info; | 114 base::PlatformFileInfo file_info; |
107 std::string resource_id; | 115 std::string resource_id; |
108 std::string file_md5; | 116 std::string file_md5; |
109 std::string mime_type; | 117 std::string mime_type; |
110 GURL content_url; | 118 GURL content_url; |
111 GURL alternate_url; | 119 GURL alternate_url; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // Initializes cache if it has not been initialized. | 308 // Initializes cache if it has not been initialized. |
301 // Upon completion, |callback| is invoked on the thread where this method was | 309 // Upon completion, |callback| is invoked on the thread where this method was |
302 // called with the cache state if file exists in cache or CACHE_STATE_NONE | 310 // called with the cache state if file exists in cache or CACHE_STATE_NONE |
303 // otherwise. | 311 // otherwise. |
304 virtual void GetCacheState(const std::string& resource_id, | 312 virtual void GetCacheState(const std::string& resource_id, |
305 const std::string& md5, | 313 const std::string& md5, |
306 const GetCacheStateCallback& callback) = 0; | 314 const GetCacheStateCallback& callback) = 0; |
307 | 315 |
308 // Finds a file (not a directory) by |file_path| and returns its key | 316 // Finds a file (not a directory) by |file_path| and returns its key |
309 // |properties|. Returns true if file was found. | 317 // |properties|. Returns true if file was found. |
310 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, | 318 virtual void GetFileInfoByPathAsync(const FilePath& file_path, |
| 319 const GetFileInfoCallback& callback) = 0; |
| 320 |
| 321 // Finds a file (not a directory) by |file_path| and returns its key |
| 322 // |properties|. Returns true if file was found. |
| 323 // TODO(satorux): Remove this: crosbug.com/30066. |
| 324 virtual bool GetFileInfoByPath(const FilePath& file_path, |
311 GDataFileProperties* properties) = 0; | 325 GDataFileProperties* properties) = 0; |
312 | 326 |
313 // Returns true if the given path is under gdata cache directory, i.e. | 327 // Returns true if the given path is under gdata cache directory, i.e. |
314 // <user_profile_dir>/GCache/v1 | 328 // <user_profile_dir>/GCache/v1 |
315 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; | 329 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; |
316 | 330 |
317 // Returns the sub-directory under gdata cache directory for the given sub | 331 // Returns the sub-directory under gdata cache directory for the given sub |
318 // directory type. Example: <user_profile_dir>/GCache/v1/tmp | 332 // directory type. Example: <user_profile_dir>/GCache/v1/tmp |
319 virtual FilePath GetCacheDirectoryPath( | 333 virtual FilePath GetCacheDirectoryPath( |
320 GDataRootDirectory::CacheSubDirectoryType sub_dir_type) const = 0; | 334 GDataRootDirectory::CacheSubDirectoryType sub_dir_type) const = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 const GetFileCallback& get_file_callback, | 403 const GetFileCallback& get_file_callback, |
390 const GetDownloadDataCallback& get_download_data_callback) OVERRIDE; | 404 const GetDownloadDataCallback& get_download_data_callback) OVERRIDE; |
391 virtual void GetFileByResourceId( | 405 virtual void GetFileByResourceId( |
392 const std::string& resource_id, | 406 const std::string& resource_id, |
393 const GetFileCallback& get_file_callback, | 407 const GetFileCallback& get_file_callback, |
394 const GetDownloadDataCallback& get_download_data_callback) OVERRIDE; | 408 const GetDownloadDataCallback& get_download_data_callback) OVERRIDE; |
395 virtual GDataOperationRegistry* GetOperationRegistry() OVERRIDE; | 409 virtual GDataOperationRegistry* GetOperationRegistry() OVERRIDE; |
396 virtual void GetCacheState(const std::string& resource_id, | 410 virtual void GetCacheState(const std::string& resource_id, |
397 const std::string& md5, | 411 const std::string& md5, |
398 const GetCacheStateCallback& callback) OVERRIDE; | 412 const GetCacheStateCallback& callback) OVERRIDE; |
399 virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, | 413 virtual void GetFileInfoByPathAsync( |
| 414 const FilePath& file_path, |
| 415 const GetFileInfoCallback& callback) OVERRIDE; |
| 416 virtual bool GetFileInfoByPath(const FilePath& file_path, |
400 GDataFileProperties* properties) OVERRIDE; | 417 GDataFileProperties* properties) OVERRIDE; |
401 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; | 418 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; |
402 virtual FilePath GetCacheDirectoryPath( | 419 virtual FilePath GetCacheDirectoryPath( |
403 GDataRootDirectory::CacheSubDirectoryType sub_dir_type) const OVERRIDE; | 420 GDataRootDirectory::CacheSubDirectoryType sub_dir_type) const OVERRIDE; |
404 virtual FilePath GetCacheFilePath( | 421 virtual FilePath GetCacheFilePath( |
405 const std::string& resource_id, | 422 const std::string& resource_id, |
406 const std::string& md5, | 423 const std::string& md5, |
407 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | 424 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
408 CachedFileOrigin file_orign) const OVERRIDE; | 425 CachedFileOrigin file_orign) const OVERRIDE; |
409 virtual void GetAvailableSpace( | 426 virtual void GetAvailableSpace( |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 base::PlatformFileError error, | 1204 base::PlatformFileError error, |
1188 const std::string& resource_id, | 1205 const std::string& resource_id, |
1189 const std::string& md5); | 1206 const std::string& md5); |
1190 | 1207 |
1191 // Changes state of hosted documents visibility, triggers directory refresh. | 1208 // Changes state of hosted documents visibility, triggers directory refresh. |
1192 void SetHideHostedDocuments(bool hide); | 1209 void SetHideHostedDocuments(bool hide); |
1193 | 1210 |
1194 // Initializes preference change observer. | 1211 // Initializes preference change observer. |
1195 void InitializePreferenceObserver(); | 1212 void InitializePreferenceObserver(); |
1196 | 1213 |
| 1214 // Called when an entry is found for GetFileInfoByPath(). |
| 1215 void OnEntryFound(const GetFileInfoCallback& callback, |
| 1216 base::PlatformFileError error, |
| 1217 const FilePath& directory_path, |
| 1218 GDataEntry* entry); |
| 1219 |
1197 // The following functions are used to forward calls to asynchronous public | 1220 // The following functions are used to forward calls to asynchronous public |
1198 // member functions to UI thread. | 1221 // member functions to UI thread. |
1199 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, | 1222 void FindEntryByPathAsyncOnUIThread(const FilePath& search_file_path, |
1200 const FindEntryCallback& callback); | 1223 const FindEntryCallback& callback); |
1201 void CopyOnUIThread(const FilePath& src_file_path, | 1224 void CopyOnUIThread(const FilePath& src_file_path, |
1202 const FilePath& dest_file_path, | 1225 const FilePath& dest_file_path, |
1203 const FileOperationCallback& callback); | 1226 const FileOperationCallback& callback); |
1204 void MoveOnUIThread(const FilePath& src_file_path, | 1227 void MoveOnUIThread(const FilePath& src_file_path, |
1205 const FilePath& dest_file_path, | 1228 const FilePath& dest_file_path, |
1206 const FileOperationCallback& callback); | 1229 const FileOperationCallback& callback); |
1207 void RemoveOnUIThread(const FilePath& file_path, | 1230 void RemoveOnUIThread(const FilePath& file_path, |
1208 bool is_recursive, | 1231 bool is_recursive, |
1209 const FileOperationCallback& callback); | 1232 const FileOperationCallback& callback); |
1210 void CreateDirectoryOnUIThread(const FilePath& directory_path, | 1233 void CreateDirectoryOnUIThread(const FilePath& directory_path, |
1211 bool is_exclusive, | 1234 bool is_exclusive, |
1212 bool is_recursive, | 1235 bool is_recursive, |
1213 const FileOperationCallback& callback); | 1236 const FileOperationCallback& callback); |
1214 void GetFileByPathOnUIThread( | 1237 void GetFileByPathOnUIThread( |
1215 const FilePath& file_path, | 1238 const FilePath& file_path, |
1216 const GetFileCallback& get_file_callback, | 1239 const GetFileCallback& get_file_callback, |
1217 const GetDownloadDataCallback& get_download_data_callback); | 1240 const GetDownloadDataCallback& get_download_data_callback); |
1218 void GetFileByResourceIdOnUIThread( | 1241 void GetFileByResourceIdOnUIThread( |
1219 const std::string& resource_id, | 1242 const std::string& resource_id, |
1220 const GetFileCallback& get_file_callback, | 1243 const GetFileCallback& get_file_callback, |
1221 const GetDownloadDataCallback& get_download_data_callback); | 1244 const GetDownloadDataCallback& get_download_data_callback); |
| 1245 void GetFileInfoByPathAsyncOnUIThread( |
| 1246 const FilePath& file_path, |
| 1247 const GetFileInfoCallback& callback); |
1222 void GetCacheStateOnUIThread(const std::string& resource_id, | 1248 void GetCacheStateOnUIThread(const std::string& resource_id, |
1223 const std::string& md5, | 1249 const std::string& md5, |
1224 const GetCacheStateCallback& callback); | 1250 const GetCacheStateCallback& callback); |
1225 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 1251 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
1226 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, | 1252 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, |
1227 const FileOperationCallback& callback); | 1253 const FileOperationCallback& callback); |
1228 void SetMountedStateOnUIThread( | 1254 void SetMountedStateOnUIThread( |
1229 const FilePath& file_path, | 1255 const FilePath& file_path, |
1230 bool to_mount, | 1256 bool to_mount, |
1231 const SetMountedStateCallback& callback); | 1257 const SetMountedStateCallback& callback); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 }; | 1317 }; |
1292 | 1318 |
1293 // Sets the free disk space getter for testing. | 1319 // Sets the free disk space getter for testing. |
1294 // The existing getter is deleted. | 1320 // The existing getter is deleted. |
1295 void SetFreeDiskSpaceGetterForTesting( | 1321 void SetFreeDiskSpaceGetterForTesting( |
1296 FreeDiskSpaceGetterInterface* getter); | 1322 FreeDiskSpaceGetterInterface* getter); |
1297 | 1323 |
1298 } // namespace gdata | 1324 } // namespace gdata |
1299 | 1325 |
1300 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1326 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |