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

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: rebase, revert version-up. 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 43d0bbfc2f19c37b9bf90beeeb747c0641ca0fb8..06e156e133647d8cc6d588744600ace191bf4032 100644
--- a/chrome/browser/chromeos/drive/drive_resource_metadata.cc
+++ b/chrome/browser/chromeos/drive/drive_resource_metadata.cc
@@ -388,8 +388,8 @@ void DriveResourceMetadata::RefreshEntry(
// Update data.
if (entry != root_.get()) {
- DriveDirectory* old_parent = GetParent(entry->parent_resource_id());
- DriveDirectory* new_parent = GetParent(entry_proto.parent_resource_id());
+ DriveDirectory* old_parent = GetDirectory(entry->parent_resource_id());
+ DriveDirectory* new_parent = GetDirectory(entry_proto.parent_resource_id());
if (!old_parent || !new_parent) {
PostGetEntryInfoWithFilePathCallbackError(
@@ -399,6 +399,9 @@ void DriveResourceMetadata::RefreshEntry(
// Remove from the old parent and add to the new parent.
old_parent->RemoveChild(entry);
+ // FromProto(entry_proto) imports the fields from |entry_proto|. Note that
+ // this assumes |entry_proto| contains metadata only about the entry itself.
hashimoto 2013/03/12 07:55:17 This comment seems to be redundant. Only DriveDire
Haruki Sato 2013/03/12 08:17:23 Thank you for the good explanation. Seemsl like I
+ // i.e. no children protos included.
entry->FromProto(entry_proto);
new_parent->AddEntry(entry); // Transfers ownership.
} else {
@@ -461,7 +464,7 @@ void DriveResourceMetadata::AddEntry(const DriveEntryProto& entry_proto,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback.is_null());
- DriveDirectory* parent = GetParent(entry_proto.parent_resource_id());
+ DriveDirectory* parent = GetDirectory(entry_proto.parent_resource_id());
if (!parent) {
PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_NOT_FOUND);
return;
@@ -481,12 +484,10 @@ void DriveResourceMetadata::AddEntry(const DriveEntryProto& entry_proto,
base::Bind(callback, DRIVE_FILE_OK, GetFilePath(added_entry->proto())));
}
-DriveDirectory* DriveResourceMetadata::GetParent(
+DriveDirectory* DriveResourceMetadata::GetDirectory(
const std::string& parent_resource_id) {
hashimoto 2013/03/12 07:55:17 nit: s/parent_resource_id/resource_id/?
Haruki Sato 2013/03/12 08:17:23 Done. Thanks.
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