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

Side by Side Diff: sync/api/attachments/fake_attachment_service.cc

Issue 247983002: Keep track of which attachments are referenced by which sync entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rework tests and move AttachmentIdProto creation to avoid violating DEPS. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « sync/api/attachments/fake_attachment_service.h ('k') | sync/api/sync_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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::OnSyncDataAdd(const SyncData& sync_data) { 56 void FakeAttachmentService::StoreAttachments(const AttachmentList& attachments,
57 const StoreCallback& callback) {
57 DCHECK(CalledOnValidThread()); 58 DCHECK(CalledOnValidThread());
58 // TODO(maniscalco): Ensure the linked attachments get persisted in local 59 attachment_store_->Write(attachments,
59 // storage and schedule them for upload to the server (bug 356351). 60 base::Bind(&FakeAttachmentService::WriteDone,
61 weak_ptr_factory_.GetWeakPtr(),
62 callback));
63 // TODO(maniscalco): Ensure the linked attachments are schedule for upload to
64 // the server (bug 356351).
60 } 65 }
61 66
62 void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) { 67 void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) {
63 DCHECK(CalledOnValidThread()); 68 DCHECK(CalledOnValidThread());
64 // TODO(maniscalco): One or more of sync_data's attachments may no longer be 69 // TODO(maniscalco): One or more of sync_data's attachments may no longer be
65 // referenced anywhere. We should probably delete them at this point (bug 70 // referenced anywhere. We should probably delete them at this point (bug
66 // 356351). 71 // 356351).
67 } 72 }
68 73
69 void FakeAttachmentService::OnSyncDataUpdate( 74 void FakeAttachmentService::OnSyncDataUpdate(
(...skipping 24 matching lines...) Expand all
94 AttachmentService::DropResult drop_result = 99 AttachmentService::DropResult drop_result =
95 AttachmentService::DROP_UNSPECIFIED_ERROR; 100 AttachmentService::DROP_UNSPECIFIED_ERROR;
96 if (result == AttachmentStore::SUCCESS) { 101 if (result == AttachmentStore::SUCCESS) {
97 drop_result = AttachmentService::DROP_SUCCESS; 102 drop_result = AttachmentService::DROP_SUCCESS;
98 } 103 }
99 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). 104 // TODO(maniscalco): Deal with case where an error occurred (bug 361251).
100 base::MessageLoop::current()->PostTask(FROM_HERE, 105 base::MessageLoop::current()->PostTask(FROM_HERE,
101 base::Bind(callback, drop_result)); 106 base::Bind(callback, drop_result));
102 } 107 }
103 108
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
104 } // namespace syncer 121 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/api/attachments/fake_attachment_service.h ('k') | sync/api/sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698