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 4587bf1dd67d48c7f01648ed5c31e89b5b11064c..737c586f5f6f9121614738e48a964236fd13455f 100644 |
| --- a/chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| +++ b/chrome/browser/chromeos/drive/drive_resource_metadata.cc |
| @@ -185,9 +185,6 @@ DriveResourceMetadata::DriveResourceMetadata() |
| largest_changestamp_(0), |
| origin_(UNINITIALIZED), |
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| - root_ = CreateDriveDirectory().Pass(); |
| - if (!google_apis::util::IsDriveV2ApiEnabled()) |
| - InitializeRootEntry(kDriveRootDirectoryResourceId); |
| } |
| DriveResourceMetadata::~DriveResourceMetadata() { |
| @@ -221,6 +218,8 @@ scoped_ptr<DriveDirectory> DriveResourceMetadata::CreateDriveDirectory() { |
| } |
| void DriveResourceMetadata::InitializeRootEntry(const std::string& root_id) { |
| + DCHECK(saved_root_resource_id_.empty()); |
| + saved_root_resource_id_ = root_id; |
|
satorux1
2012/10/23 06:54:50
do we need this? I think we can get the same value
kochi
2012/10/23 07:44:35
This was introduced to keep the root resource ID f
|
| root_ = CreateDriveDirectory().Pass(); |
| root_->set_title(kDriveRootDirectory); |
| root_->SetBaseNameFromTitle(); |
| @@ -353,7 +352,7 @@ void DriveResourceMetadata::RemoveEntryFromParent( |
| DCHECK(!callback.is_null()); |
| // Disallow deletion of root. |
| - if (resource_id == kDriveRootDirectoryResourceId) { |
| + if (resource_id == root_->resource_id()) { |
| PostFileMoveCallbackError(callback, DRIVE_FILE_ERROR_ACCESS_DENIED); |
| return; |
| } |
| @@ -611,6 +610,7 @@ void DriveResourceMetadata::InitFromDB( |
| DCHECK(!db_path.empty()); |
| DCHECK(blocking_task_runner); |
| DCHECK(!callback.is_null()); |
| + DCHECK(!saved_root_resource_id_.empty()); |
| if (resource_metadata_db_.get()) { |
| callback.Run(DRIVE_FILE_ERROR_IN_USE); |
| @@ -641,7 +641,6 @@ void DriveResourceMetadata::InitResourceMap( |
| DCHECK(!resource_metadata_db_.get()); |
| DCHECK(!callback.is_null()); |
| - |
| SerializedMap* serialized_resources = &create_params->serialized_resources; |
| resource_metadata_db_ = create_params->db.Pass(); |
| if (serialized_resources->empty()) { |
| @@ -710,7 +709,7 @@ void DriveResourceMetadata::InitResourceMap( |
| } else { |
| NOTREACHED() << "Parent is not a directory " << parent->resource_id(); |
| } |
| - } else if (entry->resource_id() == kDriveRootDirectoryResourceId) { |
| + } else if (entry->resource_id() == saved_root_resource_id_) { |
|
satorux1
2012/10/23 06:54:50
why not root_->resource_id() ?
kochi
2012/10/23 07:44:35
As mentioned in the previous comment.
We already c
|
| root_.reset(entry->AsDriveDirectory()); |
| DCHECK(root_.get()); |
| AddEntryToResourceMap(root_.get()); |
| @@ -772,6 +771,10 @@ void DriveResourceMetadata::SaveToDB() { |
| serialized_resources)); |
| } |
| +const std::string& DriveResourceMetadata::root_resource_id() const { |
| + return root_->resource_id(); |
| +} |
| + |
| void DriveResourceMetadata::SerializeToString( |
| std::string* serialized_proto) const { |
| DriveRootDirectoryProto proto; |