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

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: 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. 287 // TODO(hashimoto): Handle ApplyEntry errors correctly.
kinaba 2014/04/28 08:28:52 nit: Do you still need this TODO comment?
hashimoto 2014/04/28 09:30:54 Done.
288 FileError error = ApplyEntry(it->second); 288 FileError error = ApplyEntry(it->second);
289 DLOG_IF(WARNING, error != FILE_ERROR_OK) 289 if (error != FILE_ERROR_OK) {
290 << "ApplyEntry failed: " << FileErrorToString(error) 290 LOG(ERROR) << "ApplyEntry failed: " << FileErrorToString(error)
291 << ", title = " << it->second.title(); 291 << ", title = " << it->second.title();
292 return error;
293 }
292 } 294 }
293 entry_map_.erase(it); 295 entry_map_.erase(it);
294 } 296 }
295 } 297 }
296 298
297 // Apply deleted entries. 299 // Apply deleted entries.
298 for (size_t i = 0; i < deleted_resource_ids.size(); ++i) { 300 for (size_t i = 0; i < deleted_resource_ids.size(); ++i) {
299 std::string local_id; 301 std::string local_id;
300 FileError error = resource_metadata_->GetIdByResourceId( 302 FileError error = resource_metadata_->GetIdByResourceId(
301 deleted_resource_ids[i], &local_id); 303 deleted_resource_ids[i], &local_id);
302 if (error == FILE_ERROR_OK) 304 switch (error) {
303 error = resource_metadata_->RemoveEntry(local_id); 305 case FILE_ERROR_OK:
304 306 error = resource_metadata_->RemoveEntry(local_id);
305 DLOG_IF(WARNING, error != FILE_ERROR_OK && error != FILE_ERROR_NOT_FOUND) 307 break;
306 << "Failed to delete: " << FileErrorToString(error) 308 case FILE_ERROR_NOT_FOUND:
307 << ", resource_id = " << deleted_resource_ids[i]; 309 error = FILE_ERROR_OK;
310 break;
311 default:
312 break;
313 }
314 if (error != FILE_ERROR_OK) {
315 LOG(ERROR) << "Failed to delete: " << FileErrorToString(error)
316 << ", resource_id = " << deleted_resource_ids[i];
317 return error;
318 }
308 } 319 }
309 320
310 return FILE_ERROR_OK; 321 return FILE_ERROR_OK;
311 } 322 }
312 323
313 FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) { 324 FileError ChangeListProcessor::ApplyEntry(const ResourceEntry& entry) {
314 DCHECK(!entry.deleted()); 325 DCHECK(!entry.deleted());
315 DCHECK(parent_resource_id_map_.count(entry.resource_id())); 326 DCHECK(parent_resource_id_map_.count(entry.resource_id()));
316 const std::string& parent_resource_id = 327 const std::string& parent_resource_id =
317 parent_resource_id_map_[entry.resource_id()]; 328 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, 475 resource_metadata_->GetSubDirectoriesRecursively(local_id,
465 &sub_directories); 476 &sub_directories);
466 changed_dirs_.insert(sub_directories.begin(), sub_directories.end()); 477 changed_dirs_.insert(sub_directories.begin(), sub_directories.end());
467 } 478 }
468 } 479 }
469 } 480 }
470 } 481 }
471 482
472 } // namespace internal 483 } // namespace internal
473 } // namespace drive 484 } // 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