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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 GDataFileBase* file)> | 64 GDataFileBase* file)> |
65 FindFileCallback; | 65 FindFileCallback; |
66 | 66 |
67 // Used to get files from the file system. | 67 // Used to get files from the file system. |
68 typedef base::Callback<void(base::PlatformFileError error, | 68 typedef base::Callback<void(base::PlatformFileError error, |
69 const FilePath& file_path, | 69 const FilePath& file_path, |
70 const std::string& mime_type, | 70 const std::string& mime_type, |
71 GDataFileType file_type)> | 71 GDataFileType file_type)> |
72 GetFileCallback; | 72 GetFileCallback; |
73 | 73 |
74 // Callback for SetMountedState. | |
75 typedef base::Callback<void(base::PlatformFileError error, | |
76 const FilePath& file_path)> | |
77 SetMountedStateCallback; | |
78 | |
74 // Used for file operations like removing files. | 79 // Used for file operations like removing files. |
75 typedef base::Callback<void(base::PlatformFileError error, | 80 typedef base::Callback<void(base::PlatformFileError error, |
76 base::ListValue* feed_list)> | 81 base::ListValue* feed_list)> |
77 GetJsonDocumentCallback; | 82 GetJsonDocumentCallback; |
78 | 83 |
79 // Used to get available space for the account from GData. | 84 // Used to get available space for the account from GData. |
80 typedef base::Callback<void(base::PlatformFileError error, | 85 typedef base::Callback<void(base::PlatformFileError error, |
81 int bytes_total, | 86 int bytes_total, |
82 int bytes_used)> | 87 int bytes_used)> |
83 GetAvailableSpaceCallback; | 88 GetAvailableSpaceCallback; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 virtual void Initialize() = 0; | 181 virtual void Initialize() = 0; |
177 | 182 |
178 // Adds and removes the observer. | 183 // Adds and removes the observer. |
179 virtual void AddObserver(Observer* observer) = 0; | 184 virtual void AddObserver(Observer* observer) = 0; |
180 virtual void RemoveObserver(Observer* observer) = 0; | 185 virtual void RemoveObserver(Observer* observer) = 0; |
181 | 186 |
182 // Enum defining origin of a cached file. | 187 // Enum defining origin of a cached file. |
183 enum CachedFileOrigin { | 188 enum CachedFileOrigin { |
184 CACHED_FILE_FROM_SERVER = 0, | 189 CACHED_FILE_FROM_SERVER = 0, |
185 CACHED_FILE_LOCALLY_MODIFIED, | 190 CACHED_FILE_LOCALLY_MODIFIED, |
191 CACHED_FILE_MOUNTED, | |
186 }; | 192 }; |
187 | 193 |
188 // Enum defining type of file operation e.g. copy or move, etc. | 194 // Enum defining type of file operation e.g. copy or move, etc. |
189 // For now, it's used for StoreToCache. | 195 // For now, it's used for StoreToCache. |
190 enum FileOperationType { | 196 enum FileOperationType { |
191 FILE_OPERATION_MOVE = 0, | 197 FILE_OPERATION_MOVE = 0, |
192 FILE_OPERATION_COPY, | 198 FILE_OPERATION_COPY, |
193 }; | 199 }; |
194 | 200 |
195 // Authenticates the user by fetching the auth token as | 201 // Authenticates the user by fetching the auth token as |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 // otherwise. | 355 // otherwise. |
350 virtual void GetCacheState(const std::string& resource_id, | 356 virtual void GetCacheState(const std::string& resource_id, |
351 const std::string& md5, | 357 const std::string& md5, |
352 const GetCacheStateCallback& callback) = 0; | 358 const GetCacheStateCallback& callback) = 0; |
353 | 359 |
354 // Finds file object by |file_path| and returns its key |properties|. | 360 // Finds file object by |file_path| and returns its key |properties|. |
355 // Returns true if file was found. | 361 // Returns true if file was found. |
356 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 362 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
357 GDataFileProperties* properties) = 0; | 363 GDataFileProperties* properties) = 0; |
358 | 364 |
365 // Returns true if the given path is under gdata cache directory, i.e. | |
366 // <user_profile_dir>/GCache/v1 | |
367 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; | |
368 | |
359 // Returns the tmp sub-directory under gdata cache directory, i.e. | 369 // Returns the tmp sub-directory under gdata cache directory, i.e. |
360 // <user_profile_dir>/GCache/v1/tmp | 370 // <user_profile_dir>/GCache/v1/tmp |
361 virtual FilePath GetGDataCacheTmpDirectory() const = 0; | 371 virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
362 | 372 |
363 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. | 373 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. |
364 // <user_profile_dir>/GCache/v1/tmp/downloads/ | 374 // <user_profile_dir>/GCache/v1/tmp/downloads/ |
365 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; | 375 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; |
366 | 376 |
367 // Returns the tmp documents sub-directory under gdata cache directory, i.e. | 377 // Returns the tmp documents sub-directory under gdata cache directory, i.e. |
368 // <user_profile_dir>/GCache/v1/tmp/documents/ | 378 // <user_profile_dir>/GCache/v1/tmp/documents/ |
(...skipping 15 matching lines...) Expand all Loading... | |
384 CachedFileOrigin file_orign) const = 0; | 394 CachedFileOrigin file_orign) const = 0; |
385 | 395 |
386 // Fetches the user's Account Metadata to find out current quota information | 396 // Fetches the user's Account Metadata to find out current quota information |
387 // and returns it to the callback. | 397 // and returns it to the callback. |
388 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 398 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
389 | 399 |
390 // Pin or unpin file. | 400 // Pin or unpin file. |
391 virtual void SetPinState(const FilePath& file_path, bool to_pin, | 401 virtual void SetPinState(const FilePath& file_path, bool to_pin, |
392 const FileOperationCallback& callback) = 0; | 402 const FileOperationCallback& callback) = 0; |
393 | 403 |
404 // Mark or unmark a file as locally mounted. | |
satorux1
2012/04/18 23:29:04
nit: Marks or Unmarks
| |
405 // When marked as mounted, the file is prevented from being modified | |
406 // or evicted from cache. | |
407 virtual void SetMountedState(const FilePath& file_path, bool to_mount, | |
408 const SetMountedStateCallback& callback) = 0; | |
409 | |
394 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 410 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
395 // content from |file_content_path| into the cache. | 411 // content from |file_content_path| into the cache. |
396 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 412 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
397 DocumentEntry* entry, | 413 DocumentEntry* entry, |
398 const FilePath& file_content_path, | 414 const FilePath& file_content_path, |
399 FileOperationType cache_operation) = 0; | 415 FileOperationType cache_operation) = 0; |
400 | 416 |
401 // Returns true if hosted documents should be hidden. | 417 // Returns true if hosted documents should be hidden. |
402 virtual bool hide_hosted_documents() = 0; | 418 virtual bool hide_hosted_documents() = 0; |
403 }; | 419 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; | 466 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; |
451 virtual void AddOperationObserver( | 467 virtual void AddOperationObserver( |
452 GDataOperationRegistry::Observer* observer) OVERRIDE; | 468 GDataOperationRegistry::Observer* observer) OVERRIDE; |
453 virtual void RemoveOperationObserver( | 469 virtual void RemoveOperationObserver( |
454 GDataOperationRegistry::Observer* observer) OVERRIDE; | 470 GDataOperationRegistry::Observer* observer) OVERRIDE; |
455 virtual void GetCacheState(const std::string& resource_id, | 471 virtual void GetCacheState(const std::string& resource_id, |
456 const std::string& md5, | 472 const std::string& md5, |
457 const GetCacheStateCallback& callback) OVERRIDE; | 473 const GetCacheStateCallback& callback) OVERRIDE; |
458 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 474 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
459 GDataFileProperties* properties) OVERRIDE; | 475 GDataFileProperties* properties) OVERRIDE; |
476 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; | |
460 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; | 477 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
461 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; | 478 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
462 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; | 479 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; |
463 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; | 480 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; |
464 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; | 481 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; |
465 virtual FilePath GetCacheFilePath( | 482 virtual FilePath GetCacheFilePath( |
466 const std::string& resource_id, | 483 const std::string& resource_id, |
467 const std::string& md5, | 484 const std::string& md5, |
468 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | 485 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
469 CachedFileOrigin file_orign) const OVERRIDE; | 486 CachedFileOrigin file_orign) const OVERRIDE; |
470 virtual void GetAvailableSpace( | 487 virtual void GetAvailableSpace( |
471 const GetAvailableSpaceCallback& callback) OVERRIDE; | 488 const GetAvailableSpaceCallback& callback) OVERRIDE; |
472 // Calls private Pin or Unpin methods with |callback|. | 489 // Calls private Pin or Unpin methods with |callback|. |
473 virtual void SetPinState(const FilePath& file_path, bool pin, | 490 virtual void SetPinState(const FilePath& file_path, bool pin, |
474 const FileOperationCallback& callback) OVERRIDE; | 491 const FileOperationCallback& callback) OVERRIDE; |
492 virtual void SetMountedState( | |
493 const FilePath& file_path, | |
494 bool to_mount, | |
495 const SetMountedStateCallback& callback) OVERRIDE; | |
475 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 496 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
476 DocumentEntry* entry, | 497 DocumentEntry* entry, |
477 const FilePath& file_content_path, | 498 const FilePath& file_content_path, |
478 FileOperationType cache_operation) OVERRIDE; | 499 FileOperationType cache_operation) OVERRIDE; |
479 virtual bool hide_hosted_documents() OVERRIDE; | 500 virtual bool hide_hosted_documents() OVERRIDE; |
480 | 501 |
481 // content::NotificationObserver implementation. | 502 // content::NotificationObserver implementation. |
482 virtual void Observe(int type, | 503 virtual void Observe(int type, |
483 const content::NotificationSource& source, | 504 const content::NotificationSource& source, |
484 const content::NotificationDetails& details) OVERRIDE; | 505 const content::NotificationDetails& details) OVERRIDE; |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 // Task posted from Unpin to modify cache state on the IO thread pool, which | 1193 // Task posted from Unpin to modify cache state on the IO thread pool, which |
1173 // involves the following: | 1194 // involves the following: |
1174 // - moves |source_path| to |dest_path| in tmp dir if file is | 1195 // - moves |source_path| to |dest_path| in tmp dir if file is |
1175 // not dirty | 1196 // not dirty |
1176 // - deletes symlink from pinned dir | 1197 // - deletes symlink from pinned dir |
1177 void UnpinOnIOThreadPool(const std::string& resource_id, | 1198 void UnpinOnIOThreadPool(const std::string& resource_id, |
1178 const std::string& md5, | 1199 const std::string& md5, |
1179 FileOperationType file_operation_type, | 1200 FileOperationType file_operation_type, |
1180 base::PlatformFileError* error); | 1201 base::PlatformFileError* error); |
1181 | 1202 |
1203 // Task posted from SetMountedState to modify cache state on the IO thread | |
1204 // pool, which involves the following: | |
1205 // - moves |source_path| to |dest_path| | |
1206 void SetMountedStateOnIOThreadPool(const FilePath& file_path, | |
1207 bool to_mount, | |
1208 base::PlatformFileError* error, | |
1209 FilePath* cache_file_path); | |
1210 | |
1182 // Task posted from MarkDirtyInCache to modify cache state on the IO thread | 1211 // Task posted from MarkDirtyInCache to modify cache state on the IO thread |
1183 // pool, which involves the following: | 1212 // pool, which involves the following: |
1184 // - moves |source_path| to |dest_path| in persistent dir, where | 1213 // - moves |source_path| to |dest_path| in persistent dir, where |
1185 // |source_path| has .<md5> extension and |dest_path| has .local extension | 1214 // |source_path| has .<md5> extension and |dest_path| has .local extension |
1186 // - if file is pinned, updates symlink in pinned dir to reference dirty file | 1215 // - if file is pinned, updates symlink in pinned dir to reference dirty file |
1187 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id, | 1216 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id, |
1188 const std::string& md5, | 1217 const std::string& md5, |
1189 FileOperationType file_operation_type, | 1218 FileOperationType file_operation_type, |
1190 base::PlatformFileError* error, | 1219 base::PlatformFileError* error, |
1191 FilePath* cache_file_path); | 1220 FilePath* cache_file_path); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 }; | 1403 }; |
1375 | 1404 |
1376 // Sets the free disk space getter for testing. | 1405 // Sets the free disk space getter for testing. |
1377 // The existing getter is deleted. | 1406 // The existing getter is deleted. |
1378 void SetFreeDiskSpaceGetterForTesting( | 1407 void SetFreeDiskSpaceGetterForTesting( |
1379 FreeDiskSpaceGetterInterface* getter); | 1408 FreeDiskSpaceGetterInterface* getter); |
1380 | 1409 |
1381 } // namespace gdata | 1410 } // namespace gdata |
1382 | 1411 |
1383 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1412 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |