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) |
| @@ -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, |