| 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" |
| 11 #include "chrome/browser/chromeos/drive/drive.pb.h" | 11 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 12 #include "chrome/browser/chromeos/drive/file_cache.h" | 12 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" | 13 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 14 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
| 15 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 16 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 16 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 17 #include "chrome/browser/chromeos/drive/sync/entry_update_performer.h" | 17 #include "chrome/browser/chromeos/drive/sync/entry_update_performer.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "google_apis/drive/task_util.h" | 19 #include "google_apis/drive/task_util.h" |
| 20 | 20 |
| 21 using content::BrowserThread; | 21 using content::BrowserThread; |
| 22 | 22 |
| 23 namespace drive { | 23 namespace drive { |
| 24 namespace internal { | 24 namespace internal { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return metadata->GetResourceEntryById(entry.parent_local_id(), parent); | 132 return metadata->GetResourceEntryById(entry.parent_local_id(), parent); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 SyncClient::SyncTask::SyncTask() | 137 SyncClient::SyncTask::SyncTask() |
| 138 : state(SUSPENDED), context(BACKGROUND), should_run_again(false) {} | 138 : state(SUSPENDED), context(BACKGROUND), should_run_again(false) {} |
| 139 SyncClient::SyncTask::~SyncTask() {} | 139 SyncClient::SyncTask::~SyncTask() {} |
| 140 | 140 |
| 141 SyncClient::SyncClient(base::SequencedTaskRunner* blocking_task_runner, | 141 SyncClient::SyncClient(base::SequencedTaskRunner* blocking_task_runner, |
| 142 file_system::OperationObserver* observer, | 142 file_system::OperationDelegate* delegate, |
| 143 JobScheduler* scheduler, | 143 JobScheduler* scheduler, |
| 144 ResourceMetadata* metadata, | 144 ResourceMetadata* metadata, |
| 145 FileCache* cache, | 145 FileCache* cache, |
| 146 LoaderController* loader_controller, | 146 LoaderController* loader_controller, |
| 147 const base::FilePath& temporary_file_directory) | 147 const base::FilePath& temporary_file_directory) |
| 148 : blocking_task_runner_(blocking_task_runner), | 148 : blocking_task_runner_(blocking_task_runner), |
| 149 operation_observer_(observer), | 149 operation_delegate_(delegate), |
| 150 metadata_(metadata), | 150 metadata_(metadata), |
| 151 cache_(cache), | 151 cache_(cache), |
| 152 download_operation_(new file_system::DownloadOperation( | 152 download_operation_(new file_system::DownloadOperation( |
| 153 blocking_task_runner, | 153 blocking_task_runner, |
| 154 observer, | 154 delegate, |
| 155 scheduler, | 155 scheduler, |
| 156 metadata, | 156 metadata, |
| 157 cache, | 157 cache, |
| 158 temporary_file_directory)), | 158 temporary_file_directory)), |
| 159 entry_update_performer_(new EntryUpdatePerformer(blocking_task_runner, | 159 entry_update_performer_(new EntryUpdatePerformer(blocking_task_runner, |
| 160 observer, | 160 delegate, |
| 161 scheduler, | 161 scheduler, |
| 162 metadata, | 162 metadata, |
| 163 cache, | 163 cache, |
| 164 loader_controller)), | 164 loader_controller)), |
| 165 delay_(base::TimeDelta::FromSeconds(kDelaySeconds)), | 165 delay_(base::TimeDelta::FromSeconds(kDelaySeconds)), |
| 166 long_delay_(base::TimeDelta::FromSeconds(kLongDelaySeconds)), | 166 long_delay_(base::TimeDelta::FromSeconds(kLongDelaySeconds)), |
| 167 weak_ptr_factory_(this) { | 167 weak_ptr_factory_(this) { |
| 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 case FILE_ERROR_NO_CONNECTION: | 436 case FILE_ERROR_NO_CONNECTION: |
| 437 // Run the task again so that we'll retry once the connection is back. | 437 // Run the task again so that we'll retry once the connection is back. |
| 438 it->second.should_run_again = true; | 438 it->second.should_run_again = true; |
| 439 it->second.context = ClientContext(BACKGROUND); | 439 it->second.context = ClientContext(BACKGROUND); |
| 440 break; | 440 break; |
| 441 case FILE_ERROR_SERVICE_UNAVAILABLE: | 441 case FILE_ERROR_SERVICE_UNAVAILABLE: |
| 442 // Run the task again so that we'll retry once the service is back. | 442 // Run the task again so that we'll retry once the service is back. |
| 443 it->second.should_run_again = true; | 443 it->second.should_run_again = true; |
| 444 it->second.context = ClientContext(BACKGROUND); | 444 it->second.context = ClientContext(BACKGROUND); |
| 445 retry_delay = long_delay_; | 445 retry_delay = long_delay_; |
| 446 operation_observer_->OnDriveSyncError( | 446 operation_delegate_->OnDriveSyncError( |
| 447 file_system::DRIVE_SYNC_ERROR_SERVICE_UNAVAILABLE, local_id); | 447 file_system::DRIVE_SYNC_ERROR_SERVICE_UNAVAILABLE, local_id); |
| 448 break; | 448 break; |
| 449 default: | 449 default: |
| 450 operation_observer_->OnDriveSyncError( | 450 operation_delegate_->OnDriveSyncError( |
| 451 file_system::DRIVE_SYNC_ERROR_MISC, local_id); | 451 file_system::DRIVE_SYNC_ERROR_MISC, local_id); |
| 452 LOG(WARNING) << "Failed: type = " << type << ", id = " << local_id | 452 LOG(WARNING) << "Failed: type = " << type << ", id = " << local_id |
| 453 << ": " << FileErrorToString(error); | 453 << ": " << FileErrorToString(error); |
| 454 } | 454 } |
| 455 | 455 |
| 456 for (size_t i = 0; i < it->second.waiting_callbacks.size(); ++i) { | 456 for (size_t i = 0; i < it->second.waiting_callbacks.size(); ++i) { |
| 457 base::MessageLoopProxy::current()->PostTask( | 457 base::MessageLoopProxy::current()->PostTask( |
| 458 FROM_HERE, base::Bind(it->second.waiting_callbacks[i], error)); | 458 FROM_HERE, base::Bind(it->second.waiting_callbacks[i], error)); |
| 459 } | 459 } |
| 460 it->second.waiting_callbacks.clear(); | 460 it->second.waiting_callbacks.clear(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 486 base::PostTaskAndReplyWithResult( | 486 base::PostTaskAndReplyWithResult( |
| 487 blocking_task_runner_, | 487 blocking_task_runner_, |
| 488 FROM_HERE, | 488 FROM_HERE, |
| 489 base::Bind(&FileCache::Unpin, base::Unretained(cache_), local_id), | 489 base::Bind(&FileCache::Unpin, base::Unretained(cache_), local_id), |
| 490 base::Bind(&util::EmptyFileOperationCallback)); | 490 base::Bind(&util::EmptyFileOperationCallback)); |
| 491 } | 491 } |
| 492 } | 492 } |
| 493 | 493 |
| 494 } // namespace internal | 494 } // namespace internal |
| 495 } // namespace drive | 495 } // namespace drive |
| OLD | NEW |