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

Side by Side Diff: chrome/browser/chromeos/drive/drive_resource_metadata.cc

Issue 13876003: chromeos: Stop removing the entry from the storage of DriveResourceMetadata when unnecessary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" 5 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/chromeos/drive/drive.pb.h" 10 #include "chrome/browser/chromeos/drive/drive.pb.h"
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 storage_->PutEntry(updated_entry); 1026 storage_->PutEntry(updated_entry);
1027 } 1027 }
1028 1028
1029 void DriveResourceMetadata::RemoveDirectoryChild( 1029 void DriveResourceMetadata::RemoveDirectoryChild(
1030 const std::string& child_resource_id) { 1030 const std::string& child_resource_id) {
1031 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); 1031 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
1032 1032
1033 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(child_resource_id); 1033 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(child_resource_id);
1034 DCHECK(entry); 1034 DCHECK(entry);
1035 DetachEntryFromDirectory(child_resource_id); 1035 DetachEntryFromDirectory(child_resource_id);
1036 storage_->RemoveEntry(entry->resource_id());
1036 if (entry->file_info().is_directory()) 1037 if (entry->file_info().is_directory())
1037 RemoveDirectoryChildren(child_resource_id); 1038 RemoveDirectoryChildren(child_resource_id);
1038 } 1039 }
1039 1040
1040 void DriveResourceMetadata::DetachEntryFromDirectory( 1041 void DriveResourceMetadata::DetachEntryFromDirectory(
1041 const std::string& child_resource_id) { 1042 const std::string& child_resource_id) {
1042 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); 1043 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
1043 1044
1044 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(child_resource_id); 1045 scoped_ptr<DriveEntryProto> entry = storage_->GetEntry(child_resource_id);
1045 DCHECK(entry); 1046 DCHECK(entry);
1046 1047
1047 // entry must be present in this directory. 1048 // entry must be present in this directory.
1048 DCHECK_EQ(entry->resource_id(), 1049 DCHECK_EQ(entry->resource_id(),
1049 storage_->GetChild(entry->parent_resource_id(), 1050 storage_->GetChild(entry->parent_resource_id(),
1050 entry->base_name())); 1051 entry->base_name()));
1051 // Remove entry from resource map first.
1052 storage_->RemoveEntry(entry->resource_id());
1053 1052
1054 // Then delete it from tree.
1055 storage_->RemoveChild(entry->parent_resource_id(), entry->base_name()); 1053 storage_->RemoveChild(entry->parent_resource_id(), entry->base_name());
1056 } 1054 }
1057 1055
1058 void DriveResourceMetadata::RemoveDirectoryChildren( 1056 void DriveResourceMetadata::RemoveDirectoryChildren(
1059 const std::string& directory_resource_id) { 1057 const std::string& directory_resource_id) {
1060 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread()); 1058 DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
1061 1059
1062 std::vector<std::string> children; 1060 std::vector<std::string> children;
1063 storage_->GetChildren(directory_resource_id, &children); 1061 storage_->GetChildren(directory_resource_id, &children);
1064 for (size_t i = 0; i < children.size(); ++i) 1062 for (size_t i = 0; i < children.size(); ++i)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 storage_->PutEntry( 1192 storage_->PutEntry(
1195 CreateEntryWithProperBaseName(proto.drive_directory().drive_entry())); 1193 CreateEntryWithProperBaseName(proto.drive_directory().drive_entry()));
1196 AddDescendantsFromProto(proto.drive_directory()); 1194 AddDescendantsFromProto(proto.drive_directory());
1197 1195
1198 storage_->SetLargestChangestamp(proto.largest_changestamp()); 1196 storage_->SetLargestChangestamp(proto.largest_changestamp());
1199 1197
1200 return true; 1198 return true;
1201 } 1199 }
1202 1200
1203 } // namespace drive 1201 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698