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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.h

Issue 9742002: Wired GDataFileSystem::GetFile() method with internal cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
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..b8e60a7a191e8515c549764841f3d9634409f3ed 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 passes to intermediate callbacks during
kuan 2012/03/20 03:22:19 nit: s/passes/passed/
zel 2012/03/20 04:31:17 Done.
+ // 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,15 @@ 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.
+ void OnStoreToCache(base::PlatformFileError error,
kuan 2012/03/20 03:22:19 for internal StoreToCache() calls, there's already
zel 2012/03/20 04:31:17 Renamed to OnDownloadStoredToCache. We could remov
+ const std::string& resource_id,
+ const std::string& md5);
// Callback for handling file upload initialization requests.
void OnUploadLocationReceived(
@@ -585,8 +615,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 +720,16 @@ 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);
kuan 2012/03/20 03:22:19 nit: only 4 spaces needed for indentation.
zel 2012/03/20 04:31:17 Done.
+
// 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_;

Powered by Google App Engine
This is Rietveld 408576698