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

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

Issue 601553004: Refactor FakeAttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Newline Created 6 years, 2 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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "sync/api/attachments/attachment.h" 13 #include "sync/api/attachments/attachment.h"
14 #include "sync/api/attachments/fake_attachment_store.h"
15 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" 14 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h"
16 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" 15 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h"
17 16
18 namespace syncer { 17 namespace syncer {
19 18
20 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. 19 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls.
21 // GetOrDownloadState tracks completion of these calls and posts callback for 20 // GetOrDownloadState tracks completion of these calls and posts callback for
22 // consumer once all attachments are either retrieved or reported unavailable. 21 // consumer once all attachments are either retrieved or reported unavailable.
23 class AttachmentServiceImpl::GetOrDownloadState 22 class AttachmentServiceImpl::GetOrDownloadState
24 : public base::RefCounted<GetOrDownloadState>, 23 : public base::RefCounted<GetOrDownloadState>,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 137 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
139 } 138 }
140 139
141 AttachmentServiceImpl::~AttachmentServiceImpl() { 140 AttachmentServiceImpl::~AttachmentServiceImpl() {
142 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
143 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 142 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
144 } 143 }
145 144
146 // Static. 145 // Static.
147 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { 146 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() {
148 scoped_refptr<syncer::AttachmentStore> attachment_store( 147 scoped_refptr<syncer::AttachmentStore> attachment_store =
149 new syncer::FakeAttachmentStore(base::ThreadTaskRunnerHandle::Get())); 148 AttachmentStore::CreateInMemoryStore();
150 scoped_ptr<AttachmentUploader> attachment_uploader( 149 scoped_ptr<AttachmentUploader> attachment_uploader(
151 new FakeAttachmentUploader); 150 new FakeAttachmentUploader);
152 scoped_ptr<AttachmentDownloader> attachment_downloader( 151 scoped_ptr<AttachmentDownloader> attachment_downloader(
153 new FakeAttachmentDownloader()); 152 new FakeAttachmentDownloader());
154 scoped_ptr<syncer::AttachmentService> attachment_service( 153 scoped_ptr<syncer::AttachmentService> attachment_service(
155 new syncer::AttachmentServiceImpl(attachment_store, 154 new syncer::AttachmentServiceImpl(attachment_store,
156 attachment_uploader.Pass(), 155 attachment_uploader.Pass(),
157 attachment_downloader.Pass(), 156 attachment_downloader.Pass(),
158 NULL, 157 NULL,
159 base::TimeDelta(), 158 base::TimeDelta(),
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 base::Bind(&AttachmentServiceImpl::UploadDone, 320 base::Bind(&AttachmentServiceImpl::UploadDone,
322 weak_ptr_factory_.GetWeakPtr())); 321 weak_ptr_factory_.GetWeakPtr()));
323 } 322 }
324 } 323 }
325 324
326 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) { 325 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) {
327 upload_task_queue_->SetTimerForTest(timer.Pass()); 326 upload_task_queue_->SetTimerForTest(timer.Pass());
328 } 327 }
329 328
330 } // namespace syncer 329 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698