| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync/model_impl/attachments/attachment_service_impl.h" | 5 #include "components/sync/model_impl/attachments/attachment_service_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "components/sync/engine/attachments/fake_attachment_downloader.h" | 16 #include "components/sync/engine/attachments/fake_attachment_downloader.h" |
| 16 #include "components/sync/engine/attachments/fake_attachment_uploader.h" | 17 #include "components/sync/engine/attachments/fake_attachment_uploader.h" |
| 17 #include "components/sync/model/attachments/attachment.h" | 18 #include "components/sync/model/attachments/attachment.h" |
| 18 | 19 |
| 19 namespace syncer { | 20 namespace syncer { |
| 20 | 21 |
| 21 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. | 22 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 attachment_downloader_(std::move(attachment_downloader)), | 123 attachment_downloader_(std::move(attachment_downloader)), |
| 123 delegate_(delegate), | 124 delegate_(delegate), |
| 124 weak_ptr_factory_(this) { | 125 weak_ptr_factory_(this) { |
| 125 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| 126 DCHECK(attachment_store_.get()); | 127 DCHECK(attachment_store_.get()); |
| 127 | 128 |
| 128 // TODO(maniscalco): Observe network connectivity change events. When the | 129 // TODO(maniscalco): Observe network connectivity change events. When the |
| 129 // network becomes disconnected, consider suspending queue dispatch. When | 130 // network becomes disconnected, consider suspending queue dispatch. When |
| 130 // connectivity is restored, consider clearing any dispatch backoff (bug | 131 // connectivity is restored, consider clearing any dispatch backoff (bug |
| 131 // 411981). | 132 // 411981). |
| 132 upload_task_queue_.reset(new TaskQueue<AttachmentId>( | 133 upload_task_queue_ = base::MakeUnique<TaskQueue<AttachmentId>>( |
| 133 base::Bind(&AttachmentServiceImpl::BeginUpload, | 134 base::Bind(&AttachmentServiceImpl::BeginUpload, |
| 134 weak_ptr_factory_.GetWeakPtr()), | 135 weak_ptr_factory_.GetWeakPtr()), |
| 135 initial_backoff_delay, max_backoff_delay)); | 136 initial_backoff_delay, max_backoff_delay); |
| 136 | 137 |
| 137 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | 138 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| 138 } | 139 } |
| 139 | 140 |
| 140 AttachmentServiceImpl::~AttachmentServiceImpl() { | 141 AttachmentServiceImpl::~AttachmentServiceImpl() { |
| 141 DCHECK(CalledOnValidThread()); | 142 DCHECK(CalledOnValidThread()); |
| 142 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 143 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void AttachmentServiceImpl::GetOrDownloadAttachments( | 146 void AttachmentServiceImpl::GetOrDownloadAttachments( |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 weak_ptr_factory_.GetWeakPtr())); | 304 weak_ptr_factory_.GetWeakPtr())); |
| 304 } | 305 } |
| 305 } | 306 } |
| 306 | 307 |
| 307 void AttachmentServiceImpl::SetTimerForTest( | 308 void AttachmentServiceImpl::SetTimerForTest( |
| 308 std::unique_ptr<base::Timer> timer) { | 309 std::unique_ptr<base::Timer> timer) { |
| 309 upload_task_queue_->SetTimerForTest(std::move(timer)); | 310 upload_task_queue_->SetTimerForTest(std::move(timer)); |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace syncer | 313 } // namespace syncer |
| OLD | NEW |