Index: chrome/browser/chromeos/gdata/gdata_file_system.h |
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.h b/chrome/browser/chromeos/gdata/gdata_file_system.h |
index f3ddd15f918e2e212c853c0ac7180034a68573d5..fa39f3b9abd507f8234c7f9375afa43212dfcc62 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h |
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h |
@@ -76,6 +76,11 @@ typedef base::Callback<void(base::PlatformFileError error, |
GDataFileType file_type)> |
GetFileCallback; |
+// Callback for SetMountedState. |
+typedef base::Callback<void(base::PlatformFileError error, |
+ const FilePath& file_path)> |
+ SetMountedStateCallback; |
+ |
// Used for file operations like removing files. |
typedef base::Callback<void(base::PlatformFileError error, |
base::ListValue* feed_list)> |
@@ -192,6 +197,7 @@ class GDataFileSystemInterface { |
enum CachedFileOrigin { |
CACHED_FILE_FROM_SERVER = 0, |
CACHED_FILE_LOCALLY_MODIFIED, |
+ CACHED_FILE_MOUNTED, |
}; |
// Enum defining type of file operation e.g. copy or move, etc. |
@@ -358,6 +364,10 @@ class GDataFileSystemInterface { |
virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, |
GDataFileProperties* properties) = 0; |
+ // Returns true if the given path is under gdata cache directory, i.e. |
+ // <user_profile_dir>/GCache/v1 |
+ virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; |
+ |
// Returns the tmp sub-directory under gdata cache directory, i.e. |
// <user_profile_dir>/GCache/v1/tmp |
virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
@@ -393,6 +403,12 @@ class GDataFileSystemInterface { |
virtual void SetPinState(const FilePath& file_path, bool to_pin, |
const FileOperationCallback& callback) = 0; |
+ // Marks or unmarks a file as locally mounted. |
+ // When marked as mounted, the file is prevented from being modified |
+ // or evicted from cache. |
+ virtual void SetMountedState(const FilePath& file_path, bool to_mount, |
+ const SetMountedStateCallback& callback) = 0; |
+ |
// Creates a new file from |entry| under |virtual_dir_path|. Stored its |
// content from |file_content_path| into the cache. |
virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
@@ -456,6 +472,7 @@ class GDataFileSystem : public GDataFileSystemInterface, |
const GetCacheStateCallback& callback) OVERRIDE; |
virtual bool GetFileInfoByPath(const FilePath& gdata_file_path, |
GDataFileProperties* properties) OVERRIDE; |
+ virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; |
virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; |
@@ -471,6 +488,10 @@ class GDataFileSystem : public GDataFileSystemInterface, |
// Calls private Pin or Unpin methods with |callback|. |
virtual void SetPinState(const FilePath& file_path, bool pin, |
const FileOperationCallback& callback) OVERRIDE; |
+ virtual void SetMountedState( |
+ const FilePath& file_path, |
+ bool to_mount, |
+ const SetMountedStateCallback& callback) OVERRIDE; |
virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
DocumentEntry* entry, |
const FilePath& file_content_path, |
@@ -1159,6 +1180,19 @@ class GDataFileSystem : public GDataFileSystemInterface, |
FileOperationType file_operation_type, |
base::PlatformFileError* error); |
+ // Task posted from SetMountedState to modify cache state on the IO thread |
+ // pool, which involves the following: |
+ // - moves |source_path| to |dest_path|, where |
+ // if we're mounting: |source_path| is the unmounted path and has .<md5> |
+ // extension, and |dest_path| is the mounted path in persistent dir |
+ // and has .<md5>.mounted extension; |
+ // if we're unmounting: the opposite is true for the two paths, i.e. |
+ // |dest_path| is the mounted path and |source_path| the unmounted path. |
+ void SetMountedStateOnIOThreadPool(const FilePath& file_path, |
+ bool to_mount, |
+ base::PlatformFileError* error, |
+ FilePath* cache_file_path); |
+ |
// Task posted from MarkDirtyInCache to modify cache state on the IO thread |
// pool, which involves the following: |
// - moves |source_path| to |dest_path| in persistent dir, where |