summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-07 16:53:52 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-07 16:53:52 +0000
commit67b88f18235ecee5ae80ed7abf67fbf3ec7d2a15 (patch)
treeb68239ec554825cf33b59aa0000b25e924ef805c
parentecb51d973fbbc299c73bf5e99ea6f6432a84a943 (diff)
downloadchromium_src-67b88f18235ecee5ae80ed7abf67fbf3ec7d2a15.zip
chromium_src-67b88f18235ecee5ae80ed7abf67fbf3ec7d2a15.tar.gz
chromium_src-67b88f18235ecee5ae80ed7abf67fbf3ec7d2a15.tar.bz2
drive: Simplify DriveFileSystem::UpdateFileByResourceId()
DriveResourceMetadata::GetEntryInfoByResourceId() was called twice. BUG=143873 TEST=unit_tests Review URL: https://chromiumcodereview.appspot.com/10911132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155404 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system.cc61
-rw-r--r--chrome/browser/chromeos/gdata/drive_file_system.h24
2 files changed, 27 insertions, 58 deletions
diff --git a/chrome/browser/chromeos/gdata/drive_file_system.cc b/chrome/browser/chromeos/gdata/drive_file_system.cc
index 67e0732..ef80212 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system.cc
+++ b/chrome/browser/chromeos/gdata/drive_file_system.cc
@@ -1991,7 +1991,7 @@ void DriveFileSystem::UpdateFileByResourceIdOnUIThread(
void DriveFileSystem::UpdateFileByEntryInfo(
const FileOperationCallback& callback,
DriveFileError error,
- const FilePath& /* dive_file_path */,
+ const FilePath& drive_file_path,
scoped_ptr<DriveEntryProto> entry_proto) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
@@ -2007,18 +2007,22 @@ void DriveFileSystem::UpdateFileByEntryInfo(
return;
}
+ // Extract a pointer before we call Pass() so we can use it below.
+ DriveEntryProto* entry_proto_ptr = entry_proto.get();
cache_->GetFileOnUIThread(
- entry_proto->resource_id(),
- entry_proto->file_specific_info().file_md5(),
+ entry_proto_ptr->resource_id(),
+ entry_proto_ptr->file_specific_info().file_md5(),
base::Bind(&DriveFileSystem::OnGetFileCompleteForUpdateFile,
ui_weak_ptr_,
- entry_proto->resource_id(),
- callback));
+ callback,
+ drive_file_path,
+ base::Passed(&entry_proto)));
}
void DriveFileSystem::OnGetFileCompleteForUpdateFile(
- const std::string& resource_id,
const FileOperationCallback& callback,
+ const FilePath& drive_file_path,
+ scoped_ptr<DriveEntryProto> entry_proto,
DriveFileError error,
const FilePath& cache_file_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -2043,7 +2047,8 @@ void DriveFileSystem::OnGetFileCompleteForUpdateFile(
base::Bind(&DriveFileSystem::OnGetFileSizeCompleteForUpdateFile,
ui_weak_ptr_,
callback,
- resource_id,
+ drive_file_path,
+ base::Passed(&entry_proto),
cache_file_path,
base::Owned(get_size_error),
base::Owned(file_size)));
@@ -2051,55 +2056,27 @@ void DriveFileSystem::OnGetFileCompleteForUpdateFile(
void DriveFileSystem::OnGetFileSizeCompleteForUpdateFile(
const FileOperationCallback& callback,
- const std::string& resource_id,
+ const FilePath& drive_file_path,
+ scoped_ptr<DriveEntryProto> entry_proto,
const FilePath& cache_file_path,
DriveFileError* error,
int64* file_size) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
+ // |entry_proto| has been checked in UpdateFileByEntryInfo().
+ DCHECK(entry_proto.get());
+ DCHECK(!entry_proto->file_info().is_directory());
if (*error != DRIVE_FILE_OK) {
callback.Run(*error);
return;
}
- // TODO(satorux): GetEntryInfoByResourceId() is called twice for
- // UpdateFileByResourceIdOnUIThread(). crbug.com/143873
- resource_metadata_->GetEntryInfoByResourceId(
- resource_id,
- base::Bind(&DriveFileSystem::OnGetFileCompleteForUpdateFileByEntry,
- ui_weak_ptr_,
- callback,
- *file_size,
- cache_file_path));
-}
-
-void DriveFileSystem::OnGetFileCompleteForUpdateFileByEntry(
- const FileOperationCallback& callback,
- int64 file_size,
- const FilePath& cache_file_path,
- DriveFileError error,
- const FilePath& drive_file_path,
- scoped_ptr<DriveEntryProto> entry_proto) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
-
- if (error != DRIVE_FILE_OK) {
- callback.Run(error);
- return;
- }
-
- DCHECK(entry_proto.get());
- if (entry_proto->file_info().is_directory()) {
- callback.Run(DRIVE_FILE_ERROR_NOT_FOUND);
- return;
- }
-
uploader_->UploadExistingFile(
GURL(entry_proto->upload_url()),
drive_file_path,
cache_file_path,
- file_size,
+ *file_size,
entry_proto->file_specific_info().content_mime_type(),
base::Bind(&DriveFileSystem::OnUpdatedFileUploaded,
ui_weak_ptr_,
@@ -2996,7 +2973,7 @@ void DriveFileSystem::OnGetEntryInfoCompleteForOpenFile(
}
DCHECK(!entry_proto->resource_id().empty());
- // Extract a pointer before we calling Pass() so we can use it below.
+ // Extract a pointer before we call Pass() so we can use it below.
DriveEntryProto* entry_proto_ptr = entry_proto.get();
GetResolvedFileByPath(
file_path,
diff --git a/chrome/browser/chromeos/gdata/drive_file_system.h b/chrome/browser/chromeos/gdata/drive_file_system.h
index 08ddfbf..57dcc4c 100644
--- a/chrome/browser/chromeos/gdata/drive_file_system.h
+++ b/chrome/browser/chromeos/gdata/drive_file_system.h
@@ -726,30 +726,22 @@ class DriveFileSystem : public DriveFileSystemInterface,
// Called when DriveCache::GetFileOnUIThread() is completed for
// UpdateFileByResourceId().
// |callback| must not be null.
- void OnGetFileCompleteForUpdateFile(const std::string& resource_id,
- const FileOperationCallback& callback,
+ void OnGetFileCompleteForUpdateFile(const FileOperationCallback& callback,
+ const FilePath& drive_file_path,
+ scoped_ptr<DriveEntryProto> entry_proto,
DriveFileError error,
const FilePath& cache_file_path);
// Part of UpdateFileByResourceId().
// Callback for getting the size of the cache file in the blocking pool.
// |callback| must not be null.
- void OnGetFileSizeCompleteForUpdateFile(const FileOperationCallback& callback,
- const std::string& resource_id,
- const FilePath& cache_file_path,
- DriveFileError* error,
- int64* file_size);
-
- // Part of UpdateFileByResourceId().
- // Callback for DriveRootDirectory::GetEntryInfoByResourceId.
- // |callback| must not be null.
- void OnGetFileCompleteForUpdateFileByEntry(
+ void OnGetFileSizeCompleteForUpdateFile(
const FileOperationCallback& callback,
- int64 file_size,
- const FilePath& cache_file_path,
- DriveFileError error,
const FilePath& drive_file_path,
- scoped_ptr<DriveEntryProto> entry_proto);
+ scoped_ptr<DriveEntryProto> entry_proto,
+ const FilePath& cache_file_path,
+ DriveFileError* error,
+ int64* file_size);
// Part of UpdateFileByResourceId().
// Called when DriveUploader::UploadUpdatedFile() is completed for