Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Side by Side Diff: sync/internal_api/attachments/attachment_service_impl.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "sync/internal_api/public/attachments/attachment_service_impl.h" 5 #include "sync/internal_api/public/attachments/attachment_service_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 #include "sync/api/attachments/attachment.h" 15 #include "sync/api/attachments/attachment.h"
15 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" 16 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
16 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" 17 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h"
17 18
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 111 }
111 } 112 }
112 113
113 AttachmentServiceImpl::AttachmentServiceImpl( 114 AttachmentServiceImpl::AttachmentServiceImpl(
114 scoped_ptr<AttachmentStoreForSync> attachment_store, 115 scoped_ptr<AttachmentStoreForSync> attachment_store,
115 scoped_ptr<AttachmentUploader> attachment_uploader, 116 scoped_ptr<AttachmentUploader> attachment_uploader,
116 scoped_ptr<AttachmentDownloader> attachment_downloader, 117 scoped_ptr<AttachmentDownloader> attachment_downloader,
117 Delegate* delegate, 118 Delegate* delegate,
118 const base::TimeDelta& initial_backoff_delay, 119 const base::TimeDelta& initial_backoff_delay,
119 const base::TimeDelta& max_backoff_delay) 120 const base::TimeDelta& max_backoff_delay)
120 : attachment_store_(attachment_store.Pass()), 121 : attachment_store_(std::move(attachment_store)),
121 attachment_uploader_(attachment_uploader.Pass()), 122 attachment_uploader_(std::move(attachment_uploader)),
122 attachment_downloader_(attachment_downloader.Pass()), 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_.reset(new TaskQueue<AttachmentId>(
(...skipping 14 matching lines...) Expand all
147 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { 148 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() {
148 scoped_ptr<syncer::AttachmentStore> attachment_store = 149 scoped_ptr<syncer::AttachmentStore> attachment_store =
149 AttachmentStore::CreateInMemoryStore(); 150 AttachmentStore::CreateInMemoryStore();
150 scoped_ptr<AttachmentUploader> attachment_uploader( 151 scoped_ptr<AttachmentUploader> attachment_uploader(
151 new FakeAttachmentUploader); 152 new FakeAttachmentUploader);
152 scoped_ptr<AttachmentDownloader> attachment_downloader( 153 scoped_ptr<AttachmentDownloader> attachment_downloader(
153 new FakeAttachmentDownloader()); 154 new FakeAttachmentDownloader());
154 scoped_ptr<syncer::AttachmentService> attachment_service( 155 scoped_ptr<syncer::AttachmentService> attachment_service(
155 new syncer::AttachmentServiceImpl( 156 new syncer::AttachmentServiceImpl(
156 attachment_store->CreateAttachmentStoreForSync(), 157 attachment_store->CreateAttachmentStoreForSync(),
157 attachment_uploader.Pass(), attachment_downloader.Pass(), NULL, 158 std::move(attachment_uploader), std::move(attachment_downloader),
158 base::TimeDelta(), base::TimeDelta())); 159 NULL, base::TimeDelta(), base::TimeDelta()));
159 return attachment_service.Pass(); 160 return attachment_service;
160 } 161 }
161 162
162 void AttachmentServiceImpl::GetOrDownloadAttachments( 163 void AttachmentServiceImpl::GetOrDownloadAttachments(
163 const AttachmentIdList& attachment_ids, 164 const AttachmentIdList& attachment_ids,
164 const GetOrDownloadCallback& callback) { 165 const GetOrDownloadCallback& callback) {
165 DCHECK(CalledOnValidThread()); 166 DCHECK(CalledOnValidThread());
166 scoped_refptr<GetOrDownloadState> state( 167 scoped_refptr<GetOrDownloadState> state(
167 new GetOrDownloadState(attachment_ids, callback)); 168 new GetOrDownloadState(attachment_ids, callback));
168 // SetModelTypeReference() makes attachments visible for model type. 169 // SetModelTypeReference() makes attachments visible for model type.
169 // Needed when attachment doesn't have model type reference, but still 170 // Needed when attachment doesn't have model type reference, but still
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 AttachmentMap::const_iterator end = attachments->end(); 321 AttachmentMap::const_iterator end = attachments->end();
321 for (; iter != end; ++iter) { 322 for (; iter != end; ++iter) {
322 attachment_uploader_->UploadAttachment( 323 attachment_uploader_->UploadAttachment(
323 iter->second, 324 iter->second,
324 base::Bind(&AttachmentServiceImpl::UploadDone, 325 base::Bind(&AttachmentServiceImpl::UploadDone,
325 weak_ptr_factory_.GetWeakPtr())); 326 weak_ptr_factory_.GetWeakPtr()));
326 } 327 }
327 } 328 }
328 329
329 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) { 330 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) {
330 upload_task_queue_->SetTimerForTest(timer.Pass()); 331 upload_task_queue_->SetTimerForTest(std::move(timer));
331 } 332 }
332 333
333 } // namespace syncer 334 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698