OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sync/api/attachments/fake_attachment_service.h" |
| 6 |
| 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "sync/api/attachments/fake_attachment_store.h" |
| 9 |
| 10 namespace syncer { |
| 11 |
| 12 FakeAttachmentService::FakeAttachmentService( |
| 13 scoped_ptr<AttachmentStore> attachment_store) |
| 14 : attachment_store_(attachment_store.Pass()), weak_ptr_factory_(this) { |
| 15 DCHECK(CalledOnValidThread()); |
| 16 DCHECK(attachment_store_); |
| 17 } |
| 18 |
| 19 FakeAttachmentService::~FakeAttachmentService() { |
| 20 DCHECK(CalledOnValidThread()); |
| 21 } |
| 22 |
| 23 // Static. |
| 24 scoped_ptr<syncer::AttachmentServiceBase> |
| 25 FakeAttachmentService::CreateForTest() { |
| 26 scoped_ptr<syncer::AttachmentStore> attachment_store( |
| 27 new syncer::FakeAttachmentStore(scoped_refptr<base::SequencedTaskRunner>( |
| 28 new base::TestSimpleTaskRunner))); |
| 29 scoped_ptr<syncer::AttachmentServiceBase> attachment_service( |
| 30 new syncer::FakeAttachmentService(attachment_store.Pass())); |
| 31 return attachment_service.Pass(); |
| 32 } |
| 33 |
| 34 void FakeAttachmentService::GetOrDownloadAttachments( |
| 35 const AttachmentIdList& attachment_ids, |
| 36 const GetOrDownloadCallback& callback) { |
| 37 DCHECK(CalledOnValidThread()); |
| 38 // TODO(maniscalco): Fire off a bunch of AttachmentStore operations. Invoke |
| 39 // callback after all have completed (bug 356351). |
| 40 } |
| 41 |
| 42 void FakeAttachmentService::DropAttachments( |
| 43 const AttachmentIdList& attachment_ids, |
| 44 const DropCallback& callback) { |
| 45 DCHECK(CalledOnValidThread()); |
| 46 // TODO(maniscalco): Fire off a bunch of AttachmentStore operations. Invoke |
| 47 // callback after all have completed (bug 356351). |
| 48 } |
| 49 |
| 50 void FakeAttachmentService::OnSyncDataAdd(const SyncData& sync_data) { |
| 51 DCHECK(CalledOnValidThread()); |
| 52 // TODO(maniscalco): Ensure the linked attachments get persisted in local |
| 53 // storage and schedule them for upload to the server (bug 356351). |
| 54 } |
| 55 |
| 56 void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) { |
| 57 DCHECK(CalledOnValidThread()); |
| 58 // TODO(maniscalco): One or more of sync_data's attachments may no longer be |
| 59 // referenced anywhere. We should probably delete them at this point (bug |
| 60 // 356351). |
| 61 } |
| 62 |
| 63 void FakeAttachmentService::OnSyncDataUpdate( |
| 64 const AttachmentIdList& old_attachment_ids, |
| 65 const SyncData& updated_sync_data) { |
| 66 DCHECK(CalledOnValidThread()); |
| 67 // TODO(maniscalco): At this point we need to ensure we write all new |
| 68 // attachments referenced by updated_sync_data to local storage and schedule |
| 69 // them up upload to the server. We also need to remove any no unreferenced |
| 70 // attachments from local storage (bug 356351). |
| 71 } |
| 72 |
| 73 base::WeakPtr<AttachmentServiceBase> FakeAttachmentService::AsWeakPtr() { |
| 74 return weak_ptr_factory_.GetWeakPtr(); |
| 75 } |
| 76 |
| 77 } // namespace syncer |
OLD | NEW |