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

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

Issue 343073003: Files.app: Provide detailed change information on onDirectoryChanged event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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_change.h"
10 #include "chrome/browser/chromeos/drive/file_system_util.h" 11 #include "chrome/browser/chromeos/drive/file_system_util.h"
11 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" 12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
12 #include "chrome/browser/chromeos/drive/resource_metadata.h" 13 #include "chrome/browser/chromeos/drive/resource_metadata.h"
13 #include "chrome/browser/drive/drive_api_util.h" 14 #include "chrome/browser/drive/drive_api_util.h"
14 #include "google_apis/drive/drive_api_parser.h" 15 #include "google_apis/drive/drive_api_parser.h"
15 16
16 namespace drive { 17 namespace drive {
17 namespace internal { 18 namespace internal {
18 19
19 namespace { 20 namespace {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ++entries_index; 107 ++entries_index;
107 } 108 }
108 } 109 }
109 entries_.resize(entries_index); 110 entries_.resize(entries_index);
110 parent_resource_ids_.resize(entries_index); 111 parent_resource_ids_.resize(entries_index);
111 } 112 }
112 113
113 ChangeList::~ChangeList() {} 114 ChangeList::~ChangeList() {}
114 115
115 ChangeListProcessor::ChangeListProcessor(ResourceMetadata* resource_metadata) 116 ChangeListProcessor::ChangeListProcessor(ResourceMetadata* resource_metadata)
116 : resource_metadata_(resource_metadata) { 117 : resource_metadata_(resource_metadata), changed_files_(new FileChange) {
117 } 118 }
118 119
119 ChangeListProcessor::~ChangeListProcessor() { 120 ChangeListProcessor::~ChangeListProcessor() {
120 } 121 }
121 122
122 FileError ChangeListProcessor::Apply( 123 FileError ChangeListProcessor::Apply(
123 scoped_ptr<google_apis::AboutResource> about_resource, 124 scoped_ptr<google_apis::AboutResource> about_resource,
124 ScopedVector<ChangeList> change_lists, 125 ScopedVector<ChangeList> change_lists,
125 bool is_delta_update) { 126 bool is_delta_update) {
126 DCHECK(about_resource); 127 DCHECK(about_resource);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 void ChangeListProcessor::UpdateChangedDirs(const ResourceEntry& entry) { 474 void ChangeListProcessor::UpdateChangedDirs(const ResourceEntry& entry) {
474 DCHECK(!entry.resource_id().empty()); 475 DCHECK(!entry.resource_id().empty());
475 476
476 std::string local_id; 477 std::string local_id;
477 base::FilePath file_path; 478 base::FilePath file_path;
478 if (resource_metadata_->GetIdByResourceId( 479 if (resource_metadata_->GetIdByResourceId(
479 entry.resource_id(), &local_id) == FILE_ERROR_OK) 480 entry.resource_id(), &local_id) == FILE_ERROR_OK)
480 resource_metadata_->GetFilePath(local_id, &file_path); 481 resource_metadata_->GetFilePath(local_id, &file_path);
481 482
482 if (!file_path.empty()) { 483 if (!file_path.empty()) {
483 // Notify parent. 484 FileChange::ChangeType type =
484 changed_dirs_.insert(file_path.DirName()); 485 entry.deleted() ? FileChange::DELETE : FileChange::ADD_OR_UPDATE;
485 486 changed_files_->Update(file_path, entry, type);
486 if (entry.file_info().is_directory()) {
487 // Notify self if entry is a directory.
488 changed_dirs_.insert(file_path);
489
490 // Notify all descendants if it is a directory deletion.
491 if (entry.deleted()) {
492 std::set<base::FilePath> sub_directories;
493 resource_metadata_->GetSubDirectoriesRecursively(local_id,
494 &sub_directories);
495 changed_dirs_.insert(sub_directories.begin(), sub_directories.end());
496 }
497 }
498 } 487 }
499 } 488 }
500 489
501 } // namespace internal 490 } // namespace internal
502 } // namespace drive 491 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_processor.h ('k') | chrome/browser/chromeos/drive/change_list_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698