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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/folder_creator.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/folder_creator.h" 5 #include "chrome/browser/sync_file_system/drive_backend/folder_creator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" 10 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 google_apis::DriveApiErrorCode error, 49 google_apis::DriveApiErrorCode error,
50 std::unique_ptr<google_apis::FileResource> entry) { 50 std::unique_ptr<google_apis::FileResource> entry) {
51 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); 51 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error);
52 if (status != SYNC_STATUS_OK) { 52 if (status != SYNC_STATUS_OK) {
53 callback.Run(std::string(), status); 53 callback.Run(std::string(), status);
54 return; 54 return;
55 } 55 }
56 56
57 drive_service_->SearchByTitle( 57 drive_service_->SearchByTitle(
58 title_, parent_folder_id_, 58 title_, parent_folder_id_,
59 base::Bind(&FolderCreator::DidListFolders, 59 base::Bind(
60 weak_ptr_factory_.GetWeakPtr(), callback, 60 &FolderCreator::DidListFolders, weak_ptr_factory_.GetWeakPtr(),
61 base::Passed(ScopedVector<google_apis::FileResource>()))); 61 callback,
62 base::Passed(
63 std::vector<std::unique_ptr<google_apis::FileResource>>())));
62 } 64 }
63 65
64 void FolderCreator::DidListFolders( 66 void FolderCreator::DidListFolders(
65 const FileIDCallback& callback, 67 const FileIDCallback& callback,
66 ScopedVector<google_apis::FileResource> candidates, 68 std::vector<std::unique_ptr<google_apis::FileResource>> candidates,
67 google_apis::DriveApiErrorCode error, 69 google_apis::DriveApiErrorCode error,
68 std::unique_ptr<google_apis::FileList> file_list) { 70 std::unique_ptr<google_apis::FileList> file_list) {
69 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); 71 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error);
70 if (status != SYNC_STATUS_OK) { 72 if (status != SYNC_STATUS_OK) {
71 callback.Run(std::string(), status); 73 callback.Run(std::string(), status);
72 return; 74 return;
73 } 75 }
74 76
75 if (!file_list) { 77 if (!file_list) {
76 NOTREACHED(); 78 NOTREACHED();
77 callback.Run(std::string(), SYNC_STATUS_FAILED); 79 callback.Run(std::string(), SYNC_STATUS_FAILED);
78 return; 80 return;
79 } 81 }
80 82
81 candidates.reserve(candidates.size() + file_list->items().size()); 83 candidates.reserve(candidates.size() + file_list->items().size());
82 candidates.insert(candidates.end(), 84 candidates.insert(candidates.end(), std::make_move_iterator(
83 file_list->items().begin(), 85 file_list->mutable_items()->begin()),
84 file_list->items().end()); 86 std::make_move_iterator(file_list->mutable_items()->end()));
Avi (use Gerrit) 2017/01/09 17:18:29 nit: Why not move + back_inserter like above?
leonhsl(Using Gerrit) 2017/01/10 04:39:36 Done. I was keeping the old code calling candidate
Avi (use Gerrit) 2017/01/10 04:48:40 They should be equivalent, though move_inserter al
85 file_list->mutable_items()->weak_clear(); 87 file_list->mutable_items()->clear();
86 88
87 if (!file_list->next_link().is_empty()) { 89 if (!file_list->next_link().is_empty()) {
88 drive_service_->GetRemainingFileList( 90 drive_service_->GetRemainingFileList(
89 file_list->next_link(), 91 file_list->next_link(),
90 base::Bind(&FolderCreator::DidListFolders, 92 base::Bind(&FolderCreator::DidListFolders,
91 weak_ptr_factory_.GetWeakPtr(), callback, 93 weak_ptr_factory_.GetWeakPtr(), callback,
92 base::Passed(&candidates))); 94 base::Passed(&candidates)));
93 return; 95 return;
94 } 96 }
95 97
(...skipping 24 matching lines...) Expand all
120 if (!metadata_database_->FindFileByFileID(file_id, nullptr)) { 122 if (!metadata_database_->FindFileByFileID(file_id, nullptr)) {
121 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND); 123 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND);
122 return; 124 return;
123 } 125 }
124 126
125 callback.Run(file_id, status); 127 callback.Run(file_id, status);
126 } 128 }
127 129
128 } // namespace drive_backend 130 } // namespace drive_backend
129 } // namespace sync_file_system 131 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698