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

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

Issue 10832002: gdata: Upload locally modified file in the correct size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index f78bff979290c849bd99220d1b4cc870a269f167..5574b321c433f0a74bc9cadeeb89f81e08018351 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -315,6 +315,19 @@ void SaveFeedOnBlockingPoolForDebugging(
}
}
+// Gets the file size of |local_file|.
+void GetLocalFileSizeOnBlockingPool(const FilePath& local_file,
+ GDataFileError* error,
+ int64* file_size) {
+ DCHECK(error);
+ DCHECK(file_size);
+
+ *file_size = 0;
+ *error = file_util::GetFileSize(local_file, file_size) ?
+ GDATA_FILE_OK :
+ GDATA_FILE_ERROR_NOT_FOUND;
+}
+
// Gets the file size and the content type of |local_file|.
void GetLocalFileInfoOnBlockingPool(
const FilePath& local_file,
@@ -592,6 +605,17 @@ void PostBlockingPoolSequencedTaskAndReply(
DCHECK(posted);
}
+// Helper function for binding |path| to GetEntryInfoWithFilePathCallback and
+// create GetEntryInfoCallback.
+void RunGetEntryInfoWithFilePathCallback(
satorux1 2012/07/25 19:07:14 this seems to be unused.
kinaba 2012/07/26 01:29:51 Right. Thanks.
+ const GetEntryInfoWithFilePathCallback& callback,
+ const FilePath& path,
+ GDataFileError error,
+ scoped_ptr<GDataEntryProto> entry_proto) {
+ if (!callback.is_null())
+ callback.Run(error, path, entry_proto.Pass());
+}
+
} // namespace
// GDataFileSystem::GetDocumentsParams struct implementation.
@@ -2502,17 +2526,55 @@ void GDataFileSystem::OnGetFileCompleteForUpdateFile(
return;
}
+ // Gets the size of the cache file. Since the file is locally modified, the
+ // file size information stored in GDataEntry is not correct.
+ GDataFileError* get_size_error = new GDataFileError(GDATA_FILE_ERROR_FAILED);
+ int64* file_size = new int64(-1);
+ PostBlockingPoolSequencedTaskAndReply(
+ FROM_HERE,
+ blocking_task_runner_,
+ base::Bind(&GetLocalFileSizeOnBlockingPool,
+ cache_file_path,
+ get_size_error,
+ file_size),
+ base::Bind(&GDataFileSystem::OnGetFileSizeCompleteForUpdateFile,
+ ui_weak_ptr_,
+ callback,
+ resource_id,
+ md5,
+ cache_file_path,
+ base::Owned(get_size_error),
+ base::Owned(file_size)));
+}
+
+void GDataFileSystem::OnGetFileSizeCompleteForUpdateFile(
+ const FileOperationCallback& callback,
+ const std::string& resource_id,
+ const std::string& md5,
+ const FilePath& cache_file_path,
+ GDataFileError* error,
+ int64* file_size) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (*error != GDATA_FILE_OK) {
+ if (!callback.is_null())
+ callback.Run(*error);
+ return;
+ }
+
directory_service_->GetEntryByResourceIdAsync(resource_id,
base::Bind(&GDataFileSystem::OnGetFileCompleteForUpdateFileByEntry,
ui_weak_ptr_,
callback,
md5,
+ *file_size,
cache_file_path));
}
void GDataFileSystem::OnGetFileCompleteForUpdateFileByEntry(
const FileOperationCallback& callback,
const std::string& md5,
+ int64 file_size,
const FilePath& cache_file_path,
GDataEntry* entry) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -2528,7 +2590,7 @@ void GDataFileSystem::OnGetFileCompleteForUpdateFileByEntry(
file->upload_url(),
file->GetFilePath(),
cache_file_path,
- file->file_info().size,
+ file_size,
file->content_mime_type(),
base::Bind(&GDataFileSystem::OnUpdatedFileUploaded,
ui_weak_ptr_,
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698