OLD | NEW |
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 "components/drive/change_list_processor.h" | 5 #include "components/drive/change_list_processor.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
8 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
9 #include "base/synchronization/cancellation_flag.h" | 11 #include "base/synchronization/cancellation_flag.h" |
10 #include "components/drive/drive.pb.h" | 12 #include "components/drive/drive.pb.h" |
11 #include "components/drive/drive_api_util.h" | 13 #include "components/drive/drive_api_util.h" |
12 #include "components/drive/file_change.h" | 14 #include "components/drive/file_change.h" |
13 #include "components/drive/file_system_core_util.h" | 15 #include "components/drive/file_system_core_util.h" |
14 #include "components/drive/resource_entry_conversion.h" | 16 #include "components/drive/resource_entry_conversion.h" |
15 #include "components/drive/resource_metadata.h" | 17 #include "components/drive/resource_metadata.h" |
16 #include "google_apis/drive/drive_api_parser.h" | 18 #include "google_apis/drive/drive_api_parser.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 125 |
124 ChangeListProcessor::~ChangeListProcessor() { | 126 ChangeListProcessor::~ChangeListProcessor() { |
125 } | 127 } |
126 | 128 |
127 FileError ChangeListProcessor::Apply( | 129 FileError ChangeListProcessor::Apply( |
128 scoped_ptr<google_apis::AboutResource> about_resource, | 130 scoped_ptr<google_apis::AboutResource> about_resource, |
129 ScopedVector<ChangeList> change_lists, | 131 ScopedVector<ChangeList> change_lists, |
130 bool is_delta_update) { | 132 bool is_delta_update) { |
131 DCHECK(about_resource); | 133 DCHECK(about_resource); |
132 | 134 |
133 int64 largest_changestamp = 0; | 135 int64_t largest_changestamp = 0; |
134 if (is_delta_update) { | 136 if (is_delta_update) { |
135 if (!change_lists.empty()) { | 137 if (!change_lists.empty()) { |
136 // The changestamp appears in the first page of the change list. | 138 // The changestamp appears in the first page of the change list. |
137 // The changestamp does not appear in the full resource list. | 139 // The changestamp does not appear in the full resource list. |
138 largest_changestamp = change_lists[0]->largest_changestamp(); | 140 largest_changestamp = change_lists[0]->largest_changestamp(); |
139 DCHECK_GE(change_lists[0]->largest_changestamp(), 0); | 141 DCHECK_GE(change_lists[0]->largest_changestamp(), 0); |
140 } | 142 } |
141 } else { | 143 } else { |
142 largest_changestamp = about_resource->largest_change_id(); | 144 largest_changestamp = about_resource->largest_change_id(); |
143 | 145 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 194 } |
193 | 195 |
194 // Shouldn't record histograms when processing delta update. | 196 // Shouldn't record histograms when processing delta update. |
195 if (!is_delta_update) | 197 if (!is_delta_update) |
196 uma_stats.UpdateFileCountUmaHistograms(); | 198 uma_stats.UpdateFileCountUmaHistograms(); |
197 | 199 |
198 return FILE_ERROR_OK; | 200 return FILE_ERROR_OK; |
199 } | 201 } |
200 | 202 |
201 FileError ChangeListProcessor::ApplyEntryMap( | 203 FileError ChangeListProcessor::ApplyEntryMap( |
202 int64 changestamp, | 204 int64_t changestamp, |
203 scoped_ptr<google_apis::AboutResource> about_resource) { | 205 scoped_ptr<google_apis::AboutResource> about_resource) { |
204 DCHECK(about_resource); | 206 DCHECK(about_resource); |
205 | 207 |
206 // Create the entry for "My Drive" directory with the latest changestamp. | 208 // Create the entry for "My Drive" directory with the latest changestamp. |
207 ResourceEntry root; | 209 ResourceEntry root; |
208 FileError error = resource_metadata_->GetResourceEntryByPath( | 210 FileError error = resource_metadata_->GetResourceEntryByPath( |
209 util::GetDriveMyDriveRootPath(), &root); | 211 util::GetDriveMyDriveRootPath(), &root); |
210 if (error != FILE_ERROR_OK) { | 212 if (error != FILE_ERROR_OK) { |
211 LOG(ERROR) << "Failed to get root entry: " << FileErrorToString(error); | 213 LOG(ERROR) << "Failed to get root entry: " << FileErrorToString(error); |
212 return error; | 214 return error; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 if (!file_path.empty()) { | 495 if (!file_path.empty()) { |
494 FileChange::ChangeType type = entry.deleted() | 496 FileChange::ChangeType type = entry.deleted() |
495 ? FileChange::CHANGE_TYPE_DELETE | 497 ? FileChange::CHANGE_TYPE_DELETE |
496 : FileChange::CHANGE_TYPE_ADD_OR_UPDATE; | 498 : FileChange::CHANGE_TYPE_ADD_OR_UPDATE; |
497 changed_files_->Update(file_path, entry, type); | 499 changed_files_->Update(file_path, entry, type); |
498 } | 500 } |
499 } | 501 } |
500 | 502 |
501 } // namespace internal | 503 } // namespace internal |
502 } // namespace drive | 504 } // namespace drive |
OLD | NEW |