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

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

Issue 187303006: Update sync API to support attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachmentapi
Patch Set: Remove AttachmentServiceBase for reals. Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/api/attachments/attachment_service_proxy.h"
6
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "sync/api/sync_data.h"
10
11 namespace syncer {
12
13 namespace {
14
15 // These ProxyFooCallback functions are used to invoke a callback in a specific
16 // thread.
17
18 // Invokes |callback| with |result| and |attachments| in the |task_runner|
19 // thread.
20 void ProxyGetOrDownloadCallback(
21 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
22 const AttachmentService::GetOrDownloadCallback& callback,
23 const AttachmentService::GetOrDownloadResult& result,
24 const AttachmentMap& attachments) {
25 task_runner->PostTask(FROM_HERE, base::Bind(callback, result, attachments));
26 }
27
28 // Invokes |callback| with |result| and |attachments| in the |task_runner|
29 // thread.
30 void ProxyDropCallback(
31 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
32 const AttachmentService::DropCallback& callback,
33 const AttachmentService::DropResult& result) {
34 task_runner->PostTask(FROM_HERE, base::Bind(callback, result));
35 }
36
37 } // namespace
38
39 AttachmentServiceProxy::AttachmentServiceProxy() {}
40
41 AttachmentServiceProxy::AttachmentServiceProxy(
42 const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
43 base::WeakPtr<syncer::AttachmentService> wrapped)
44 : wrapped_task_runner_(wrapped_task_runner), wrapped_(wrapped) {
45 DCHECK(wrapped_task_runner_);
46 }
47
48 AttachmentServiceProxy::~AttachmentServiceProxy() {}
49
50 void AttachmentServiceProxy::GetOrDownloadAttachments(
51 const AttachmentIdList& attachment_ids,
52 const GetOrDownloadCallback& callback) {
53 DCHECK(wrapped_task_runner_);
54 GetOrDownloadCallback proxy_callback = base::Bind(
55 &ProxyGetOrDownloadCallback, base::MessageLoopProxy::current(), callback);
56 wrapped_task_runner_->PostTask(
57 FROM_HERE,
58 base::Bind(&AttachmentService::GetOrDownloadAttachments,
59 wrapped_,
60 attachment_ids,
61 proxy_callback));
62 }
63
64 void AttachmentServiceProxy::DropAttachments(
65 const AttachmentIdList& attachment_ids,
66 const DropCallback& callback) {
67 DCHECK(wrapped_task_runner_);
68 DropCallback proxy_callback = base::Bind(
69 &ProxyDropCallback, base::MessageLoopProxy::current(), callback);
70 wrapped_task_runner_->PostTask(FROM_HERE,
71 base::Bind(&AttachmentService::DropAttachments,
72 wrapped_,
73 attachment_ids,
74 proxy_callback));
75 }
76
77 void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) {
78 DCHECK(wrapped_task_runner_);
79 wrapped_task_runner_->PostTask(
80 FROM_HERE,
81 base::Bind(&AttachmentService::OnSyncDataAdd, wrapped_, sync_data));
82 }
83
84 void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) {
85 DCHECK(wrapped_task_runner_);
86 wrapped_task_runner_->PostTask(
87 FROM_HERE,
88 base::Bind(&AttachmentService::OnSyncDataDelete, wrapped_, sync_data));
89 }
90
91 void AttachmentServiceProxy::OnSyncDataUpdate(
92 const AttachmentIdList& old_attachment_ids,
93 const SyncData& updated_sync_data) {
94 DCHECK(wrapped_task_runner_);
95 wrapped_task_runner_->PostTask(
96 FROM_HERE,
97 base::Bind(&AttachmentService::OnSyncDataUpdate,
98 wrapped_,
99 old_attachment_ids,
100 updated_sync_data));
101 }
102
103 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698