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

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

Issue 256773005: drive: Handle ApplyEntryMap correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO Created 6 years, 7 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/change_list_processor.h" 5 #include "chrome/browser/chromeos/drive/change_list_processor.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/chromeos/drive/drive.pb.h" 9 #include "chrome/browser/chromeos/drive/drive.pb.h"
10 #include "chrome/browser/chromeos/drive/file_system_util.h" 10 #include "chrome/browser/chromeos/drive/file_system_util.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 it = it_parent; 277 it = it_parent;
278 } 278 }
279 279
280 // Apply the parent first. 280 // Apply the parent first.
281 std::reverse(entries.begin(), entries.end()); 281 std::reverse(entries.begin(), entries.end());
282 for (size_t i = 0; i < entries.size(); ++i) { 282 for (size_t i = 0; i < entries.size(); ++i) {
283 // Skip root entry in the change list. We don't expect servers to send 283 // Skip root entry in the change list. We don't expect servers to send
284 // root entry, but we should better be defensive (see crbug.com/297259). 284 // root entry, but we should better be defensive (see crbug.com/297259).
285 ResourceEntryMap::iterator it = entries[i]; 285 ResourceEntryMap::iterator it = entries[i];
286 if (it->first != root.resource_id()) { 286 if (it->first != root.resource_id()) {
287 // TODO(hashimoto): Handle ApplyEntry errors correctly.
288 FileError error = ApplyEntry(it->second); 287 FileError error = ApplyEntry(it->second);
289 DLOG_IF(WARNING, error != FILE_ERROR_OK) 288 if (error != FILE_ERROR_OK) {
290 << "ApplyEntry failed: " << FileErrorToString(error) 289 LOG(ERROR) << "ApplyEntry failed: " << FileErrorToString(error)
291 << ", title = " << it->second.title(); 290 << ", title = " << it->second.title();
291 return error;
292 }
292 } 293 }
293 entry_map_.erase(it); 294 entry_map_.erase(it);
294 } 295 }
295 } 296 }
296 297
297 // Apply deleted entries. 298 // Apply deleted entries.
298 for (size_t i = 0; i < deleted_resource_ids.size(); ++i) { 299 for (size_t i = 0; i < deleted_resource_ids.size(); ++i) {
299 std::string local_id; 300 std::string local_id;
300 FileError error = resource_metadata_->GetIdByResourceId( 301 FileError error = resource_metadata_->GetIdByResourceId(
301 deleted_resource_ids[i], &local_id); 302 deleted_resource_ids[i], &local_id);
302 if (error == FILE_ERROR_OK) 303 switch (error) {
303 error = resource_metadata_->RemoveEntry(local_id); 304 case FILE_ERROR_OK:
304 305 error = resource_metadata_->RemoveEntry(local_id);
305 DLOG_IF(WARNING, error != FILE_ERROR_OK && error != FILE_ERROR_NOT_FOUND) 306 break;
306 << "Failed to delete: " << FileErrorToString(error) 307 case FILE_ERROR_NOT_FOUND:
307 << ", resource_id = " << deleted_resource_ids[i]; 308 error = FILE_ERROR_OK;
309 break;
310 default:
311 break;
312 }
313 if (error != FILE_ERROR_OK) {
314 LOG(ERROR) << "Failed to delete: " << FileErrorToString(error)
315 << ", resource_id = " << deleted_resource_ids[i];
316 return error;
317 }
308 } 318 }
309 319
310 return FILE_ERROR_OK; 320 return FILE_ERROR_OK;
311 } 321 }
312 322
313 FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { 323 FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) {
314 DCHECK(!entry.deleted()); 324 DCHECK(!entry.deleted());
315 DCHECK(parent_resource_id_map_.count(entry.resource_id())); 325 DCHECK(parent_resource_id_map_.count(entry.resource_id()));
316 const std::string& parent_resource_id = 326 const std::string& parent_resource_id =
317 parent_resource_id_map_[entry.resource_id()]; 327 parent_resource_id_map_[entry.resource_id()];
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 resource_metadata_->GetSubDirectoriesRecursively(local_id, 474 resource_metadata_->GetSubDirectoriesRecursively(local_id,
465 &sub_directories); 475 &sub_directories);
466 changed_dirs_.insert(sub_directories.begin(), sub_directories.end()); 476 changed_dirs_.insert(sub_directories.begin(), sub_directories.end());
467 } 477 }
468 } 478 }
469 } 479 }
470 } 480 }
471 481
472 } // namespace internal 482 } // namespace internal
473 } // namespace drive 483 } // 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