| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 void SyncClient::OnCacheUnpinned(const std::string& resource_id, | 132 void SyncClient::OnCacheUnpinned(const std::string& resource_id, |
| 133 const std::string& md5) { | 133 const std::string& md5) { |
| 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 135 | 135 |
| 136 // Remove the resource_id if it's in the queue. This can happen if the | 136 // Remove the resource_id if it's in the queue. This can happen if the |
| 137 // user cancels pinning before the file is fetched. | 137 // user cancels pinning before the file is fetched. |
| 138 pending_fetch_list_.erase(resource_id); | 138 pending_fetch_list_.erase(resource_id); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void SyncClient::OnCacheCommitted(const std::string& resource_id) { | 141 void SyncClient::AddFetchTask(const std::string& resource_id) { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 |
| 144 AddTaskToQueue(FETCH, resource_id); |
| 145 } |
| 146 |
| 147 void SyncClient::AddUploadTask(const std::string& resource_id) { |
| 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 143 | 149 |
| 144 AddTaskToQueue(UPLOAD, resource_id); | 150 AddTaskToQueue(UPLOAD, resource_id); |
| 145 } | 151 } |
| 146 | 152 |
| 147 void SyncClient::AddTaskToQueue(SyncType type, | 153 void SyncClient::AddTaskToQueue(SyncType type, |
| 148 const std::string& resource_id) { | 154 const std::string& resource_id) { |
| 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 150 | 156 |
| 151 // If the same task is already queued, ignore this task. | 157 // If the same task is already queued, ignore this task. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 DVLOG(1) << "Uploaded " << resource_id; | 349 DVLOG(1) << "Uploaded " << resource_id; |
| 344 } else { | 350 } else { |
| 345 // TODO(satorux): We should re-queue if the error is recoverable. | 351 // TODO(satorux): We should re-queue if the error is recoverable. |
| 346 LOG(WARNING) << "Failed to upload " << resource_id << ": " | 352 LOG(WARNING) << "Failed to upload " << resource_id << ": " |
| 347 << FileErrorToString(error); | 353 << FileErrorToString(error); |
| 348 } | 354 } |
| 349 } | 355 } |
| 350 | 356 |
| 351 } // namespace internal | 357 } // namespace internal |
| 352 } // namespace drive | 358 } // namespace drive |
| OLD | NEW |