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

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

Issue 2613223002: Remove ScopedVector from base::JSONValueConverter (Closed)
Patch Set: Rebase and address comments from mmenke@ 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 std::move(file_list->mutable_items()->begin(),
83 file_list->items().begin(), 85 file_list->mutable_items()->end(), std::back_inserter(candidates));
84 file_list->items().end()); 86 file_list->mutable_items()->clear();
85 file_list->mutable_items()->weak_clear();
86 87
87 if (!file_list->next_link().is_empty()) { 88 if (!file_list->next_link().is_empty()) {
88 drive_service_->GetRemainingFileList( 89 drive_service_->GetRemainingFileList(
89 file_list->next_link(), 90 file_list->next_link(),
90 base::Bind(&FolderCreator::DidListFolders, 91 base::Bind(&FolderCreator::DidListFolders,
91 weak_ptr_factory_.GetWeakPtr(), callback, 92 weak_ptr_factory_.GetWeakPtr(), callback,
92 base::Passed(&candidates))); 93 base::Passed(&candidates)));
93 return; 94 return;
94 } 95 }
95 96
(...skipping 24 matching lines...) Expand all
120 if (!metadata_database_->FindFileByFileID(file_id, nullptr)) { 121 if (!metadata_database_->FindFileByFileID(file_id, nullptr)) {
121 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND); 122 callback.Run(std::string(), SYNC_FILE_ERROR_NOT_FOUND);
122 return; 123 return;
123 } 124 }
124 125
125 callback.Run(file_id, status); 126 callback.Run(file_id, status);
126 } 127 }
127 128
128 } // namespace drive_backend 129 } // namespace drive_backend
129 } // namespace sync_file_system 130 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698