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

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

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