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

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

Issue 996473005: Revert of [Sync] Refactor AttachmentStore classes. Introduce concept of referrer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/in_memory_attachment_store.h" 5 #include "sync/internal_api/public/attachments/in_memory_attachment_store.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 } 60 }
61 if (!unavailable_attachments->empty()) { 61 if (!unavailable_attachments->empty()) {
62 result_code = AttachmentStore::UNSPECIFIED_ERROR; 62 result_code = AttachmentStore::UNSPECIFIED_ERROR;
63 } 63 }
64 PostCallback(base::Bind(callback, result_code, base::Passed(&result_map), 64 PostCallback(base::Bind(callback, result_code, base::Passed(&result_map),
65 base::Passed(&unavailable_attachments))); 65 base::Passed(&unavailable_attachments)));
66 } 66 }
67 67
68 void InMemoryAttachmentStore::Write( 68 void InMemoryAttachmentStore::Write(
69 AttachmentStore::AttachmentReferrer referrer,
70 const AttachmentList& attachments, 69 const AttachmentList& attachments,
71 const AttachmentStore::WriteCallback& callback) { 70 const AttachmentStore::WriteCallback& callback) {
72 DCHECK(CalledOnValidThread()); 71 DCHECK(CalledOnValidThread());
73 AttachmentList::const_iterator iter = attachments.begin(); 72 AttachmentList::const_iterator iter = attachments.begin();
74 AttachmentList::const_iterator end = attachments.end(); 73 AttachmentList::const_iterator end = attachments.end();
75 for (; iter != end; ++iter) { 74 for (; iter != end; ++iter) {
76 attachments_.insert(std::make_pair(iter->GetId(), *iter)); 75 attachments_.insert(std::make_pair(iter->GetId(), *iter));
77 } 76 }
78 PostCallback(base::Bind(callback, AttachmentStore::SUCCESS)); 77 PostCallback(base::Bind(callback, AttachmentStore::SUCCESS));
79 } 78 }
80 79
81 void InMemoryAttachmentStore::Drop( 80 void InMemoryAttachmentStore::Drop(
82 AttachmentStore::AttachmentReferrer referrer,
83 const AttachmentIdList& ids, 81 const AttachmentIdList& ids,
84 const AttachmentStore::DropCallback& callback) { 82 const AttachmentStore::DropCallback& callback) {
85 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
86 AttachmentStore::Result result = AttachmentStore::SUCCESS; 84 AttachmentStore::Result result = AttachmentStore::SUCCESS;
87 AttachmentIdList::const_iterator ids_iter = ids.begin(); 85 AttachmentIdList::const_iterator ids_iter = ids.begin();
88 AttachmentIdList::const_iterator ids_end = ids.end(); 86 AttachmentIdList::const_iterator ids_end = ids.end();
89 for (; ids_iter != ids_end; ++ids_iter) { 87 for (; ids_iter != ids_end; ++ids_iter) {
90 AttachmentMap::iterator attachments_iter = attachments_.find(*ids_iter); 88 AttachmentMap::iterator attachments_iter = attachments_.find(*ids_iter);
91 if (attachments_iter != attachments_.end()) { 89 if (attachments_iter != attachments_.end()) {
92 attachments_.erase(attachments_iter); 90 attachments_.erase(attachments_iter);
(...skipping 17 matching lines...) Expand all
110 if (attachments_iter != attachments_.end()) { 108 if (attachments_iter != attachments_.end()) {
111 AppendMetadata(metadata_list.get(), attachments_iter->second); 109 AppendMetadata(metadata_list.get(), attachments_iter->second);
112 } else { 110 } else {
113 result_code = AttachmentStore::UNSPECIFIED_ERROR; 111 result_code = AttachmentStore::UNSPECIFIED_ERROR;
114 } 112 }
115 } 113 }
116 PostCallback(base::Bind(callback, result_code, base::Passed(&metadata_list))); 114 PostCallback(base::Bind(callback, result_code, base::Passed(&metadata_list)));
117 } 115 }
118 116
119 void InMemoryAttachmentStore::ReadAllMetadata( 117 void InMemoryAttachmentStore::ReadAllMetadata(
120 AttachmentStore::AttachmentReferrer referrer,
121 const AttachmentStore::ReadMetadataCallback& callback) { 118 const AttachmentStore::ReadMetadataCallback& callback) {
122 DCHECK(CalledOnValidThread()); 119 DCHECK(CalledOnValidThread());
123 AttachmentStore::Result result_code = AttachmentStore::SUCCESS; 120 AttachmentStore::Result result_code = AttachmentStore::SUCCESS;
124 scoped_ptr<AttachmentMetadataList> metadata_list( 121 scoped_ptr<AttachmentMetadataList> metadata_list(
125 new AttachmentMetadataList()); 122 new AttachmentMetadataList());
126 123
127 for (AttachmentMap::const_iterator iter = attachments_.begin(); 124 for (AttachmentMap::const_iterator iter = attachments_.begin();
128 iter != attachments_.end(); ++iter) { 125 iter != attachments_.end(); ++iter) {
129 AppendMetadata(metadata_list.get(), iter->second); 126 AppendMetadata(metadata_list.get(), iter->second);
130 } 127 }
131 PostCallback(base::Bind(callback, result_code, base::Passed(&metadata_list))); 128 PostCallback(base::Bind(callback, result_code, base::Passed(&metadata_list)));
132 } 129 }
133 130
134 } // namespace syncer 131 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698