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 "sync/api/attachments/fake_attachment_service.h" | 5 #include "sync/api/attachments/fake_attachment_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
10 #include "sync/api/attachments/attachment.h" | 10 #include "sync/api/attachments/attachment.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 void FakeAttachmentService::DropAttachments( | 46 void FakeAttachmentService::DropAttachments( |
47 const AttachmentIdList& attachment_ids, | 47 const AttachmentIdList& attachment_ids, |
48 const DropCallback& callback) { | 48 const DropCallback& callback) { |
49 DCHECK(CalledOnValidThread()); | 49 DCHECK(CalledOnValidThread()); |
50 attachment_store_->Drop(attachment_ids, | 50 attachment_store_->Drop(attachment_ids, |
51 base::Bind(&FakeAttachmentService::DropDone, | 51 base::Bind(&FakeAttachmentService::DropDone, |
52 weak_ptr_factory_.GetWeakPtr(), | 52 weak_ptr_factory_.GetWeakPtr(), |
53 callback)); | 53 callback)); |
54 } | 54 } |
55 | 55 |
56 void FakeAttachmentService::StoreAttachments(const AttachmentList& attachments, | 56 void FakeAttachmentService::OnSyncDataAdd(const SyncData& sync_data) { |
57 const StoreCallback& callback) { | |
58 DCHECK(CalledOnValidThread()); | 57 DCHECK(CalledOnValidThread()); |
59 attachment_store_->Write(attachments, | 58 // TODO(maniscalco): Ensure the linked attachments get persisted in local |
60 base::Bind(&FakeAttachmentService::WriteDone, | 59 // storage and schedule them for upload to the server (bug 356351). |
61 weak_ptr_factory_.GetWeakPtr(), | |
62 callback)); | |
63 // TODO(maniscalco): Ensure the linked attachments are schedule for upload to | |
64 // the server (bug 356351). | |
65 } | 60 } |
66 | 61 |
67 void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) { | 62 void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) { |
68 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
69 // TODO(maniscalco): One or more of sync_data's attachments may no longer be | 64 // TODO(maniscalco): One or more of sync_data's attachments may no longer be |
70 // referenced anywhere. We should probably delete them at this point (bug | 65 // referenced anywhere. We should probably delete them at this point (bug |
71 // 356351). | 66 // 356351). |
72 } | 67 } |
73 | 68 |
74 void FakeAttachmentService::OnSyncDataUpdate( | 69 void FakeAttachmentService::OnSyncDataUpdate( |
(...skipping 24 matching lines...) Expand all Loading... |
99 AttachmentService::DropResult drop_result = | 94 AttachmentService::DropResult drop_result = |
100 AttachmentService::DROP_UNSPECIFIED_ERROR; | 95 AttachmentService::DROP_UNSPECIFIED_ERROR; |
101 if (result == AttachmentStore::SUCCESS) { | 96 if (result == AttachmentStore::SUCCESS) { |
102 drop_result = AttachmentService::DROP_SUCCESS; | 97 drop_result = AttachmentService::DROP_SUCCESS; |
103 } | 98 } |
104 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). | 99 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). |
105 base::MessageLoop::current()->PostTask(FROM_HERE, | 100 base::MessageLoop::current()->PostTask(FROM_HERE, |
106 base::Bind(callback, drop_result)); | 101 base::Bind(callback, drop_result)); |
107 } | 102 } |
108 | 103 |
109 void FakeAttachmentService::WriteDone(const StoreCallback& callback, | |
110 const AttachmentStore::Result& result) { | |
111 AttachmentService::StoreResult store_result = | |
112 AttachmentService::STORE_UNSPECIFIED_ERROR; | |
113 if (result == AttachmentStore::SUCCESS) { | |
114 store_result = AttachmentService::STORE_SUCCESS; | |
115 } | |
116 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). | |
117 base::MessageLoop::current()->PostTask(FROM_HERE, | |
118 base::Bind(callback, store_result)); | |
119 } | |
120 | |
121 } // namespace syncer | 104 } // namespace syncer |
OLD | NEW |