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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.cc

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_file_system/drive_backend/sync_engine_initializer. h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer. h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 if (!file_list) { 175 if (!file_list) {
176 NOTREACHED(); 176 NOTREACHED();
177 util::Log(logging::LOG_VERBOSE, FROM_HERE, 177 util::Log(logging::LOG_VERBOSE, FROM_HERE,
178 "[Initialize] Got invalid resource list."); 178 "[Initialize] Got invalid resource list.");
179 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED); 179 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED);
180 return; 180 return;
181 } 181 }
182 182
183 ScopedVector<google_apis::FileResource>* items = file_list->mutable_items(); 183 std::vector<std::unique_ptr<google_apis::FileResource>>* items =
184 for (ScopedVector<google_apis::FileResource>::iterator itr = items->begin(); 184 file_list->mutable_items();
185 itr != items->end(); ++itr) { 185 for (auto& entry : *items) {
186 google_apis::FileResource* entry = *itr;
187
188 // Ignore deleted folder. 186 // Ignore deleted folder.
189 if (entry->labels().is_trashed()) 187 if (entry->labels().is_trashed())
190 continue; 188 continue;
191 189
192 // Pick an orphaned folder or a direct child of the root folder and 190 // Pick an orphaned folder or a direct child of the root folder and
193 // ignore others. 191 // ignore others.
194 DCHECK(!root_folder_id_.empty()); 192 DCHECK(!root_folder_id_.empty());
195 if (!HasNoParents(*entry) && !HasFolderAsParent(*entry, root_folder_id_)) 193 if (!HasNoParents(*entry) && !HasFolderAsParent(*entry, root_folder_id_))
196 continue; 194 continue;
197 195
198 if (entry->shared()) 196 if (entry->shared())
199 continue; 197 continue;
200 198
201 if (!sync_root_folder_ || LessOnCreationTime(*entry, *sync_root_folder_)) { 199 if (!sync_root_folder_ || LessOnCreationTime(*entry, *sync_root_folder_)) {
202 sync_root_folder_.reset(entry); 200 sync_root_folder_ = std::move(entry);
203 *itr = nullptr;
204 } 201 }
205 } 202 }
206 203
207 set_used_network(true); 204 set_used_network(true);
208 // If there are more results, retrieve them. 205 // If there are more results, retrieve them.
209 if (!file_list->next_link().is_empty()) { 206 if (!file_list->next_link().is_empty()) {
210 cancel_callback_ = sync_context_->GetDriveService()->GetRemainingFileList( 207 cancel_callback_ = sync_context_->GetDriveService()->GetRemainingFileList(
211 file_list->next_link(), 208 file_list->next_link(),
212 base::Bind(&SyncEngineInitializer::DidFindSyncRoot, 209 base::Bind(&SyncEngineInitializer::DidFindSyncRoot,
213 weak_ptr_factory_.GetWeakPtr(), 210 weak_ptr_factory_.GetWeakPtr(),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 311 }
315 312
316 if (!file_list) { 313 if (!file_list) {
317 NOTREACHED(); 314 NOTREACHED();
318 util::Log(logging::LOG_VERBOSE, FROM_HERE, 315 util::Log(logging::LOG_VERBOSE, FROM_HERE,
319 "[Initialize] Got invalid initial app-root list."); 316 "[Initialize] Got invalid initial app-root list.");
320 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED); 317 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED);
321 return; 318 return;
322 } 319 }
323 320
324 ScopedVector<google_apis::FileResource>* new_entries = 321 std::vector<std::unique_ptr<google_apis::FileResource>>* new_entries =
325 file_list->mutable_items(); 322 file_list->mutable_items();
326 app_root_folders_.insert(app_root_folders_.end(), 323 app_root_folders_.insert(app_root_folders_.end(),
327 new_entries->begin(), new_entries->end()); 324 std::make_move_iterator(new_entries->begin()),
328 new_entries->weak_clear(); 325 std::make_move_iterator(new_entries->end()));
Avi (use Gerrit) 2017/01/09 17:18:29 Same question here about move + back_iterator and
leonhsl(Using Gerrit) 2017/01/10 04:39:36 Done.
326 new_entries->clear();
329 327
330 set_used_network(true); 328 set_used_network(true);
331 if (!file_list->next_link().is_empty()) { 329 if (!file_list->next_link().is_empty()) {
332 cancel_callback_ = 330 cancel_callback_ =
333 sync_context_->GetDriveService()->GetRemainingFileList( 331 sync_context_->GetDriveService()->GetRemainingFileList(
334 file_list->next_link(), 332 file_list->next_link(),
335 base::Bind(&SyncEngineInitializer::DidListAppRootFolders, 333 base::Bind(&SyncEngineInitializer::DidListAppRootFolders,
336 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token))); 334 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)));
337 return; 335 return;
338 } 336 }
(...skipping 14 matching lines...) Expand all
353 return; 351 return;
354 } 352 }
355 353
356 util::Log(logging::LOG_VERBOSE, FROM_HERE, 354 util::Log(logging::LOG_VERBOSE, FROM_HERE,
357 "[Initialize] Completed successfully."); 355 "[Initialize] Completed successfully.");
358 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_OK); 356 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_OK);
359 } 357 }
360 358
361 } // namespace drive_backend 359 } // namespace drive_backend
362 } // namespace sync_file_system 360 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698