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

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

Issue 10876075: AddEntryToDirectory now takes a FilePath and scoped_ptr<DocumentEntry> (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: delete FindEntryCallback 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/drive_resource_metadata.cc
===================================================================
--- chrome/browser/chromeos/gdata/drive_resource_metadata.cc (revision 153316)
+++ chrome/browser/chromeos/gdata/drive_resource_metadata.cc (working copy)
@@ -42,6 +42,11 @@
EntryInfoPairResult::~EntryInfoPairResult() {
}
+void PostError(const FileMoveCallback& callback, DriveFileError error) {
hashimoto 2012/08/27 20:36:41 Move this to the anonymous namespace.
achuithb 2012/08/27 21:20:34 Sorry thought I had. Done.
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE,
+ base::Bind(callback, error, FilePath()));
+}
+
// ResourceMetadataDB implementation.
// Params for ResourceMetadataDB::Create.
@@ -220,13 +225,36 @@
}
void DriveResourceMetadata::AddEntryToDirectory(
- DriveDirectory* directory,
- DriveEntry* new_entry,
+ const FilePath& directory_path,
+ scoped_ptr<DocumentEntry> doc_entry,
const FileMoveCallback& callback) {
- DCHECK(directory);
- DCHECK(new_entry);
+ DCHECK(!directory_path.empty());
+ DCHECK(doc_entry.get());
DCHECK(!callback.is_null());
+ if (!doc_entry.get()) {
hashimoto 2012/08/27 20:36:41 Can we remove this since we have DCHECK(doc_entry.
achuithb 2012/08/27 21:20:34 I think we need this. Removed the DCHECK. We are g
+ PostError(callback, DRIVE_FILE_ERROR_FAILED);
+ return;
+ }
+
+ DriveEntry* new_entry = FromDocumentEntry(*doc_entry);
+ if (!new_entry) {
+ PostError(callback, DRIVE_FILE_ERROR_FAILED);
+ return;
+ }
+
+ DriveEntry* dir_entry = FindEntryByPathSync(directory_path);
+ if (!dir_entry) {
+ PostError(callback, DRIVE_FILE_ERROR_NOT_FOUND);
+ return;
+ }
+
+ DriveDirectory* directory = dir_entry->AsDriveDirectory();
+ if (!directory) {
+ PostError(callback, DRIVE_FILE_ERROR_NOT_A_DIRECTORY);
+ return;
+ }
+
directory->AddEntry(new_entry);
DVLOG(1) << "AddEntryToDirectory " << new_entry->GetFilePath().value();
base::MessageLoopProxy::current()->PostTask(FROM_HERE,

Powered by Google App Engine
This is Rietveld 408576698