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 "chrome/browser/chromeos/drive/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void SyncClient::StartTask(SyncType type, const std::string& resource_id) { | 177 void SyncClient::StartTask(SyncType type, const std::string& resource_id) { |
178 switch (type) { | 178 switch (type) { |
179 case FETCH: | 179 case FETCH: |
180 // Check if the resource has been removed from the start list. | 180 // Check if the resource has been removed from the start list. |
181 if (pending_fetch_list_.find(resource_id) != pending_fetch_list_.end()) { | 181 if (pending_fetch_list_.find(resource_id) != pending_fetch_list_.end()) { |
182 DVLOG(1) << "Fetching " << resource_id; | 182 DVLOG(1) << "Fetching " << resource_id; |
183 pending_fetch_list_.erase(resource_id); | 183 pending_fetch_list_.erase(resource_id); |
184 | 184 |
185 file_system_->GetFileByResourceId( | 185 file_system_->GetFileByResourceId( |
186 resource_id, | 186 resource_id, |
187 DriveClientContext(BACKGROUND), | 187 ClientContext(BACKGROUND), |
188 base::Bind(&SyncClient::OnFetchFileComplete, | 188 base::Bind(&SyncClient::OnFetchFileComplete, |
189 weak_ptr_factory_.GetWeakPtr(), | 189 weak_ptr_factory_.GetWeakPtr(), |
190 resource_id), | 190 resource_id), |
191 google_apis::GetContentCallback()); | 191 google_apis::GetContentCallback()); |
192 } else { | 192 } else { |
193 // Cancel the task. | 193 // Cancel the task. |
194 fetch_list_.erase(resource_id); | 194 fetch_list_.erase(resource_id); |
195 } | 195 } |
196 break; | 196 break; |
197 case UPLOAD: | 197 case UPLOAD: |
198 DVLOG(1) << "Uploading " << resource_id; | 198 DVLOG(1) << "Uploading " << resource_id; |
199 file_system_->UpdateFileByResourceId( | 199 file_system_->UpdateFileByResourceId( |
200 resource_id, | 200 resource_id, |
201 DriveClientContext(BACKGROUND), | 201 ClientContext(BACKGROUND), |
202 base::Bind(&SyncClient::OnUploadFileComplete, | 202 base::Bind(&SyncClient::OnUploadFileComplete, |
203 weak_ptr_factory_.GetWeakPtr(), | 203 weak_ptr_factory_.GetWeakPtr(), |
204 resource_id)); | 204 resource_id)); |
205 break; | 205 break; |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void SyncClient::OnGetResourceIdsOfBacklog( | 209 void SyncClient::OnGetResourceIdsOfBacklog( |
210 const std::vector<std::string>* to_fetch, | 210 const std::vector<std::string>* to_fetch, |
211 const std::vector<std::string>* to_upload) { | 211 const std::vector<std::string>* to_upload) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 DVLOG(1) << "Uploaded " << resource_id; | 334 DVLOG(1) << "Uploaded " << resource_id; |
335 } else { | 335 } else { |
336 // TODO(satorux): We should re-queue if the error is recoverable. | 336 // TODO(satorux): We should re-queue if the error is recoverable. |
337 LOG(WARNING) << "Failed to upload " << resource_id << ": " | 337 LOG(WARNING) << "Failed to upload " << resource_id << ": " |
338 << FileErrorToString(error); | 338 << FileErrorToString(error); |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 } // namespace internal | 342 } // namespace internal |
343 } // namespace drive | 343 } // namespace drive |
OLD | NEW |