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

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: rebase 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/drive_resource_metadata.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/drive_resource_metadata.cc
===================================================================
--- chrome/browser/chromeos/gdata/drive_resource_metadata.cc (revision 153571)
+++ chrome/browser/chromeos/gdata/drive_resource_metadata.cc (working copy)
@@ -28,6 +28,12 @@
const char kDBKeyVersion[] = "m:version";
const char kDBKeyResourceIdPrefix[] = "r:";
+// Posts |error| to |callback| asynchronously.
+void PostError(const FileMoveCallback& callback, DriveFileError error) {
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE,
+ base::Bind(callback, error, FilePath()));
+}
+
} // namespace
EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) {
@@ -220,13 +226,35 @@
}
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(!callback.is_null());
+ if (!doc_entry.get()) {
+ 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,
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_resource_metadata.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698