Chromium Code Reviews| Index: chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| diff --git a/chrome/browser/chromeos/drive/drive_resource_metadata.cc b/chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| index fbdf510949d941d281a1cc3c5efcba1c1e1a24b5..dc1d7a809314855754c0357b492f102d59cebf61 100644 |
| --- a/chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| @@ -515,14 +515,17 @@ void DriveResourceMetadata::RefreshEntry( |
| DriveEntry* old_entry = GetEntryByResourceId(drive_entry->resource_id()); |
| DriveDirectory* old_parent = NULL; |
| + DriveDirectory* new_parent = NULL; |
| if (old_entry && !old_entry->parent_resource_id().empty()) { |
|
hashimoto
2013/03/11 09:32:17
Can't this parent_resource_id().empty() check be r
Haruki Sato
2013/03/11 14:15:35
Yes, assuming all non-root entry has parent_resour
|
| old_parent = GetEntryByResourceId( |
| old_entry->parent_resource_id())->AsDriveDirectory(); |
| + new_parent = entry_proto.parent_resource_id().empty() ? NULL : |
| + GetParent(entry_proto.parent_resource_id()); |
|
hashimoto
2013/03/11 09:32:17
Why do you allow entry_proto.parent_resource_id()
Haruki Sato
2013/03/11 14:15:35
Done. And we can simplify it. Thanks.
|
| } |
| - DriveDirectory* new_parent = GetParent(entry_proto.parent_resource_id()); |
| scoped_ptr<DriveEntryProto> result_entry_proto(new DriveEntryProto); |
| // We special case root here because old_parent of root is null. |
| + // Note that this also catches "old_entry == NULL" case. |
| if ((!old_parent || !new_parent) && old_entry != root_.get()) { |
| drive_entry->ToProtoFull(result_entry_proto.get()); |
| base::MessageLoopProxy::current()->PostTask( |
| @@ -624,9 +627,7 @@ void DriveResourceMetadata::AddEntry(const DriveEntryProto& entry_proto, |
| DriveDirectory* DriveResourceMetadata::GetParent( |
|
hashimoto
2013/03/11 09:32:17
Could you rename this method to GetDirectory() whi
Haruki Sato
2013/03/11 14:15:35
Done.
|
| const std::string& parent_resource_id) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - |
| - if (parent_resource_id.empty()) |
| - return root_.get(); |
| + DCHECK(!parent_resource_id.empty()); |
| DriveEntry* entry = GetEntryByResourceId(parent_resource_id); |
| return entry ? entry->AsDriveDirectory() : NULL; |