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

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

Issue 10827262: gdata: Remove use of FindEntryByPathSync() from MoveEntryFromRootDirectory() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 03f4849cfa83ac714e12dc26db3061433aa2f272..cce26614221f536a79ef27e93a5f13292aa20af1 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -1235,27 +1235,49 @@ void GDataFileSystem::MoveEntryFromRootDirectory(
DCHECK(!callback.is_null());
DCHECK_EQ(kGDataRootDirectory, file_path.DirName().value());
- GDataEntry* entry = directory_service_->FindEntryByPathSync(file_path);
- GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(dir_path);
- if (error == GDATA_FILE_OK) {
- if (!entry || !dir_entry) {
- error = GDATA_FILE_ERROR_NOT_FOUND;
- } else {
- if (!dir_entry->AsGDataDirectory())
- error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
- }
+ // Return if there is an error or |dir_path| is the root directory.
+ if (error != GDATA_FILE_OK || dir_path == FilePath(kGDataRootDirectory)) {
+ callback.Run(error);
+ return;
}
- // Returns if there is an error or |dir_path| is the root directory.
- if (error != GDATA_FILE_OK ||
- dir_entry->resource_id() == kGDataRootDirectoryResourceId) {
- callback.Run(error);
+ directory_service_->GetEntryInfoPairByPaths(
+ file_path,
+ dir_path,
+ base::Bind(
+ &GDataFileSystem::MoveEntryFromRootDirectoryAfterGetEntryInfoPair,
+ ui_weak_ptr_,
+ callback));
+}
+
+void GDataFileSystem::MoveEntryFromRootDirectoryAfterGetEntryInfoPair(
+ const FileOperationCallback& callback,
+ scoped_ptr<EntryInfoPairResult> result) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(!callback.is_null());
+ DCHECK(result.get());
+
+ if (result->first.error != GDATA_FILE_OK) {
+ callback.Run(result->first.error);
+ return;
+ } else if (result->second.error != GDATA_FILE_OK) {
+ callback.Run(result->second.error);
+ return;
+ }
+
+ scoped_ptr<GDataEntryProto> src_proto = result->first.proto.Pass();
achuithb 2012/08/10 08:46:42 I would've used GDataEntryProto* instead of scoped
+ scoped_ptr<GDataEntryProto> dir_proto = result->second.proto.Pass();
+
+ if (!dir_proto->file_info().is_directory()) {
+ callback.Run(GDATA_FILE_ERROR_NOT_A_DIRECTORY);
return;
}
+ const FilePath& file_path = result->first.path;
+ const FilePath& dir_path = result->second.path;
documents_service_->AddResourceToDirectory(
- dir_entry->content_url(),
- entry->edit_url(),
+ GURL(dir_proto->content_url()),
+ GURL(src_proto->edit_url()),
base::Bind(&GDataFileSystem::OnMoveEntryFromRootDirectoryCompleted,
ui_weak_ptr_,
callback,
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698