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

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

Issue 710073003: Store attachment crc in AttachmentStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Add comment in attachment_util.h. Created 6 years, 1 month 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/fake_attachment_downloader.h" 5 #include "sync/internal_api/public/attachments/fake_attachment_downloader.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/internal_api/public/attachments/attachment_util.h"
9 10
10 namespace syncer { 11 namespace syncer {
11 12
12 FakeAttachmentDownloader::FakeAttachmentDownloader() { 13 FakeAttachmentDownloader::FakeAttachmentDownloader() {
13 } 14 }
14 15
15 FakeAttachmentDownloader::~FakeAttachmentDownloader() { 16 FakeAttachmentDownloader::~FakeAttachmentDownloader() {
16 DCHECK(CalledOnValidThread()); 17 DCHECK(CalledOnValidThread());
17 } 18 }
18 19
19 void FakeAttachmentDownloader::DownloadAttachment( 20 void FakeAttachmentDownloader::DownloadAttachment(
20 const AttachmentId& attachment_id, 21 const AttachmentId& attachment_id,
21 const DownloadCallback& callback) { 22 const DownloadCallback& callback) {
22 DCHECK(CalledOnValidThread()); 23 DCHECK(CalledOnValidThread());
23 // This is happy fake downloader, it always successfully downloads empty 24 // This is happy fake downloader, it always successfully downloads empty
24 // attachment. 25 // attachment.
25 scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes()); 26 scoped_refptr<base::RefCountedMemory> data(new base::RefCountedBytes());
26 scoped_ptr<Attachment> attachment; 27 scoped_ptr<Attachment> attachment;
28 const uint32_t crc32c = ComputeCrc32c(data);
27 attachment.reset( 29 attachment.reset(
28 new Attachment(Attachment::CreateWithId(attachment_id, data))); 30 new Attachment(Attachment::CreateFromParts(attachment_id, data, crc32c)));
29 base::MessageLoop::current()->PostTask( 31 base::MessageLoop::current()->PostTask(
30 FROM_HERE, 32 FROM_HERE,
31 base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment))); 33 base::Bind(callback, DOWNLOAD_SUCCESS, base::Passed(&attachment)));
32 } 34 }
33 35
34 } // namespace syncer 36 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/attachment_util.cc ('k') | sync/internal_api/attachments/on_disk_attachment_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698