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 e34d1dda23a3ffbc8e17b00d99538638c70cb38a..59fe639bd4d19b2b3ea2437a6ec0cf0b6e5ce7ea 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_file_system.h |
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.h |
@@ -268,10 +268,14 @@ class GDataFileSystem : public ProfileKeyedService { |
const std::string& md5, |
const GetCacheStateCallback& callback); |
- // Finds file object by |file_path| and returns its |file_info|. |
- // Returns true if file was found. |
+ // Finds file object by |file_path| and returns its |file_info| and optionally |
+ // its |resource_id|, |md5| and |content_url| properties. Returns true if file |
+ // was found. |
bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
- base::PlatformFileInfo* file_info); |
+ base::PlatformFileInfo* file_info, |
+ std::string* resource_id, |
+ std::string* md5, |
+ GURL* content_url); |
// Returns the tmp sub-directory under gdata cache directory, i.e. |
// <user_profile_dir>/GCache/v1/tmp |
@@ -321,6 +325,27 @@ class GDataFileSystem : public ProfileKeyedService { |
FileOperationCallback callback; |
}; |
+ // Defines set of parameters passed to intermediate callbacks during |
+ // execution of GetFile() method. |
+ struct GetFileFromCacheParams { |
+ GetFileFromCacheParams(const FilePath& virtual_file_path, |
+ const FilePath& local_tmp_path, |
+ const GURL& content_url, |
+ const std::string& resource_id, |
+ const std::string& md5, |
+ scoped_refptr<base::MessageLoopProxy> proxy, |
+ const GetFileCallback& callback); |
+ ~GetFileFromCacheParams(); |
+ |
+ FilePath virtual_file_path; |
+ FilePath local_tmp_path; |
+ GURL content_url; |
+ std::string resource_id; |
+ std::string md5; |
+ scoped_refptr<base::MessageLoopProxy> proxy; |
+ const GetFileCallback callback; |
+ }; |
+ |
// Callback similar to FileOperationCallback but with a given |
// |file_path|. |
typedef base::Callback<void(base::PlatformFileError error, |
@@ -456,10 +481,16 @@ class GDataFileSystem : public ProfileKeyedService { |
// Callback for handling file downloading requests. |
void OnFileDownloaded( |
- const GetFileCallback& callback, |
+ const GetFileFromCacheParams& params, |
GDataErrorCode status, |
const GURL& content_url, |
- const FilePath& temp_file); |
+ const FilePath& downloaded_file_path); |
+ |
+ // Callback for handling internal StoreToCache() calls after downloading |
+ // file content. |
+ void OnDownloadStoredToCache(base::PlatformFileError error, |
+ const std::string& resource_id, |
+ const std::string& md5); |
// Callback for handling file upload initialization requests. |
void OnUploadLocationReceived( |
@@ -585,8 +616,6 @@ class GDataFileSystem : public ProfileKeyedService { |
// Initializes cache if it has not been initialized. |
// Upon completion, |callback| is invoked on the thread where this method was |
// called. |
- // TODO(kuan): When URLFetcher can save response to a specified file (as |
- // opposed to only temporary file currently), remove |source_path| parameter. |
void StoreToCache(const std::string& resource_id, |
const std::string& md5, |
const FilePath& source_path, |
@@ -692,6 +721,15 @@ class GDataFileSystem : public ProfileKeyedService { |
mode_t mode_bits, |
const CacheOperationCallback& callback); |
+ // Helper function for internally handling responses from GetFromCache() |
+ // calls during processing of GetFile() request. |
+ void OnGetFileFromCache(const GetFileFromCacheParams& params, |
+ base::PlatformFileError error, |
+ const std::string& resource_id, |
+ const std::string& md5, |
+ const FilePath& gdata_file_path, |
+ const FilePath& cache_file_path); |
+ |
// Callback for GetCacheState that gets cache state of file corresponding to |
// |resource_id| and |md5|. |
void OnGetCacheState(const std::string& resource_id, |
@@ -713,7 +751,7 @@ class GDataFileSystem : public ProfileKeyedService { |
void FindFileByPathOnCallingThread(const FilePath& search_file_path, |
const FindFileCallback& callback); |
- scoped_ptr<GDataRootDirectory> root_; |
+ scoped_ptr<GDataRootDirectory> root_; |
base::Lock lock_; |