Chromium Code Reviews| 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) |
| @@ -28,6 +28,11 @@ |
| const char kDBKeyVersion[] = "m:version"; |
| const char kDBKeyResourceIdPrefix[] = "r:"; |
| +void PostError(const FileMoveCallback& callback, DriveFileError error) { |
|
satorux1
2012/08/27 22:45:57
function comment missing. this seems to be used to
achuithb
2012/08/27 23:10:03
Done.
|
| + base::MessageLoopProxy::current()->PostTask(FROM_HERE, |
| + base::Bind(callback, error, FilePath())); |
| +} |
| + |
| } // namespace |
| EntryInfoResult::EntryInfoResult() : error(DRIVE_FILE_ERROR_FAILED) { |
| @@ -220,13 +225,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, |