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

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

Issue 278273002: drive: Change the return type of ResourceMetadata's methods to FileError (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
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 new_entry.set_local_id(local_id); 347 new_entry.set_local_id(local_id);
348 error = resource_metadata_->RefreshEntry(new_entry); 348 error = resource_metadata_->RefreshEntry(new_entry);
349 } else { 349 } else {
350 if (entry.file_info().is_directory()) { 350 if (entry.file_info().is_directory()) {
351 // No need to refresh, but update the changestamp. 351 // No need to refresh, but update the changestamp.
352 new_entry = existing_entry; 352 new_entry = existing_entry;
353 new_entry.mutable_directory_specific_info()->set_changestamp( 353 new_entry.mutable_directory_specific_info()->set_changestamp(
354 new_entry.directory_specific_info().changestamp()); 354 new_entry.directory_specific_info().changestamp());
355 error = resource_metadata_->RefreshEntry(new_entry); 355 error = resource_metadata_->RefreshEntry(new_entry);
356 } 356 }
357 DVLOG(1) << "Change was discarded for: " 357 DVLOG(1) << "Change was discarded for: " << entry.resource_id();
358 << resource_metadata_->GetFilePath(local_id).value();
359 } 358 }
360 break; 359 break;
361 case FILE_ERROR_NOT_FOUND: { // Adding a new entry. 360 case FILE_ERROR_NOT_FOUND: { // Adding a new entry.
362 std::string local_id; 361 std::string local_id;
363 error = resource_metadata_->AddEntry(new_entry, &local_id); 362 error = resource_metadata_->AddEntry(new_entry, &local_id);
364 break; 363 break;
365 } 364 }
366 default: 365 default:
367 return error; 366 return error;
368 } 367 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return FILE_ERROR_OK; 450 return FILE_ERROR_OK;
452 } 451 }
453 452
454 void ChangeListProcessor::UpdateChangedDirs(const ResourceEntry& entry) { 453 void ChangeListProcessor::UpdateChangedDirs(const ResourceEntry& entry) {
455 DCHECK(!entry.resource_id().empty()); 454 DCHECK(!entry.resource_id().empty());
456 455
457 std::string local_id; 456 std::string local_id;
458 base::FilePath file_path; 457 base::FilePath file_path;
459 if (resource_metadata_->GetIdByResourceId( 458 if (resource_metadata_->GetIdByResourceId(
460 entry.resource_id(), &local_id) == FILE_ERROR_OK) 459 entry.resource_id(), &local_id) == FILE_ERROR_OK)
461 file_path = resource_metadata_->GetFilePath(local_id); 460 resource_metadata_->GetFilePath(local_id, &file_path);
462 461
463 if (!file_path.empty()) { 462 if (!file_path.empty()) {
464 // Notify parent. 463 // Notify parent.
465 changed_dirs_.insert(file_path.DirName()); 464 changed_dirs_.insert(file_path.DirName());
466 465
467 if (entry.file_info().is_directory()) { 466 if (entry.file_info().is_directory()) {
468 // Notify self if entry is a directory. 467 // Notify self if entry is a directory.
469 changed_dirs_.insert(file_path); 468 changed_dirs_.insert(file_path);
470 469
471 // Notify all descendants if it is a directory deletion. 470 // Notify all descendants if it is a directory deletion.
472 if (entry.deleted()) { 471 if (entry.deleted()) {
473 std::set<base::FilePath> sub_directories; 472 std::set<base::FilePath> sub_directories;
474 resource_metadata_->GetSubDirectoriesRecursively(local_id, 473 resource_metadata_->GetSubDirectoriesRecursively(local_id,
475 &sub_directories); 474 &sub_directories);
476 changed_dirs_.insert(sub_directories.begin(), sub_directories.end()); 475 changed_dirs_.insert(sub_directories.begin(), sub_directories.end());
477 } 476 }
478 } 477 }
479 } 478 }
480 } 479 }
481 480
482 } // namespace internal 481 } // namespace internal
483 } // namespace drive 482 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698