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

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

Issue 10828219: gdata: Remove use of FindEntryByPathSync() from CopyOnUIThread() (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
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 c809f8643d1afb3b9623c2f83098e1dde97399d8..4b98c12ed7f2eef9375ba2f346ef20957f056384 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -933,39 +933,58 @@ void GDataFileSystem::CopyOnUIThread(const FilePath& src_file_path,
const FileOperationCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- GDataFileError error = GDATA_FILE_OK;
- FilePath dest_parent_path = dest_file_path.DirName();
+ directory_service_->GetEntryInfoPairByPaths(
+ src_file_path,
+ dest_file_path.DirName(),
+ base::Bind(&GDataFileSystem::CopyOnUIThreadAfterGetEntryInfoPair,
+ ui_weak_ptr_,
+ src_file_path,
+ dest_file_path,
+ callback));
+}
- std::string src_file_resource_id;
+void GDataFileSystem::CopyOnUIThreadAfterGetEntryInfoPair(
+ const FilePath& src_file_path,
+ const FilePath& dest_file_path,
+ const FileOperationCallback& callback,
+ scoped_ptr<EntryInfoPairResult> result) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(result.get());
+
+ GDataFileError error = GDATA_FILE_OK;
bool src_file_is_hosted_document = false;
achuithb 2012/08/09 00:29:28 These auto vars seem unnecessary to me. I think it
satorux1 2012/08/09 08:33:03 I'm all for minimized scope, but these cannot be m
achuithb 2012/08/09 11:16:46 Hmm, what am I missing? It looks to me like these
satorux1 2012/08/09 16:51:50 Now I see your point. It seems to me that the awkw
+ std::string src_file_resource_id;
- GDataEntry* src_entry = directory_service_->FindEntryByPathSync(
- src_file_path);
- GDataEntry* dest_parent = directory_service_->FindEntryByPathSync(
- dest_parent_path);
- if (!src_entry || !dest_parent) {
- error = GDATA_FILE_ERROR_NOT_FOUND;
- } else if (!dest_parent->AsGDataDirectory()) {
- error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
- } else if (!src_entry->AsGDataFile()) {
- // TODO(benchan): Implement copy for directories. In the interim,
- // we handle recursive directory copy in the file manager.
- error = GDATA_FILE_ERROR_INVALID_OPERATION;
+ if (result->first.error != GDATA_FILE_OK) {
+ error = result->first.error;
+ } else if (result->second.error != GDATA_FILE_OK) {
+ error = result->second.error;
} else {
- src_file_resource_id = src_entry->resource_id();
- src_file_is_hosted_document =
- src_entry->AsGDataFile()->is_hosted_document();
+ scoped_ptr<GDataEntryProto> src_file_proto = result->first.proto.Pass();
achuithb 2012/08/09 11:16:46 This seems rather weird to me. We are destroying t
satorux1 2012/08/09 16:51:50 That's a good point. With the new code, this weird
+ scoped_ptr<GDataEntryProto> dest_parent_proto =
+ result->second.proto.Pass();
+
+ if (!dest_parent_proto->file_info().is_directory()) {
+ error = GDATA_FILE_ERROR_NOT_A_DIRECTORY;
+ } else if (src_file_proto->file_info().is_directory()) {
+ // TODO(benchan): Implement copy for directories. In the interim,
achuithb 2012/08/09 00:29:28 Can we update this TODO with an engineer current o
satorux1 2012/08/09 08:33:03 Done.
+ // we handle recursive directory copy in the file manager.
+ error = GDATA_FILE_ERROR_INVALID_OPERATION;
+ } else {
+ src_file_resource_id = src_file_proto->resource_id();
+ src_file_is_hosted_document =
+ src_file_proto->file_specific_info().is_hosted_document();
+ }
}
if (error != GDATA_FILE_OK) {
if (!callback.is_null())
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, error));
-
+ callback.Run(error);
return;
}
if (src_file_is_hosted_document) {
- CopyDocumentToDirectory(dest_parent_path,
+ CopyDocumentToDirectory(dest_file_path.DirName(),
src_file_resource_id,
// Drop the document extension, which should not be
// in the document title.

Powered by Google App Engine
This is Rietveld 408576698