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

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

Issue 12585003: drive: Add showroot=true to WAPI feed URLs and ignore "no parent" entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update unittests. Created 7 years, 9 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/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;

Powered by Google App Engine
This is Rietveld 408576698