OLD | NEW |
---|---|
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/list_changes_task.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 if (!change_list) { | 71 if (!change_list) { |
72 NOTREACHED(); | 72 NOTREACHED(); |
73 token->RecordLog("Got invalid change list."); | 73 token->RecordLog("Got invalid change list."); |
74 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED); | 74 SyncTaskManager::NotifyTaskDone(std::move(token), SYNC_STATUS_FAILED); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 std::vector<google_apis::ChangeResource*> changes; | 78 change_list_.reserve(change_list_.size() + |
79 change_list->mutable_items()->release(&changes); | 79 change_list->mutable_items()->size()); |
80 | 80 std::move(change_list->mutable_items()->begin(), |
81 change_list_.reserve(change_list_.size() + changes.size()); | 81 change_list->mutable_items()->end(), |
82 for (size_t i = 0; i < changes.size(); ++i) | 82 std::back_inserter(change_list_)); |
83 change_list_.push_back(changes[i]); | 83 change_list->mutable_items()->clear(); |
Avi (use Gerrit)
2017/01/09 17:18:29
And a move + back_inserter again...
leonhsl(Using Gerrit)
2017/01/10 04:39:36
:)
| |
84 | 84 |
85 if (!change_list->next_link().is_empty()) { | 85 if (!change_list->next_link().is_empty()) { |
86 drive_service()->GetRemainingChangeList( | 86 drive_service()->GetRemainingChangeList( |
87 change_list->next_link(), | 87 change_list->next_link(), |
88 base::Bind( | 88 base::Bind( |
89 &ListChangesTask::DidListChanges, | 89 &ListChangesTask::DidListChanges, |
90 weak_ptr_factory_.GetWeakPtr(), | 90 weak_ptr_factory_.GetWeakPtr(), |
91 base::Passed(&token))); | 91 base::Passed(&token))); |
92 return; | 92 return; |
93 } | 93 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 return sync_context_->GetMetadataDatabase(); | 139 return sync_context_->GetMetadataDatabase(); |
140 } | 140 } |
141 | 141 |
142 drive::DriveServiceInterface* ListChangesTask::drive_service() { | 142 drive::DriveServiceInterface* ListChangesTask::drive_service() { |
143 set_used_network(true); | 143 set_used_network(true); |
144 return sync_context_->GetDriveService(); | 144 return sync_context_->GetDriveService(); |
145 } | 145 } |
146 | 146 |
147 } // namespace drive_backend | 147 } // namespace drive_backend |
148 } // namespace sync_file_system | 148 } // namespace sync_file_system |
OLD | NEW |