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

Unified Diff: sync/api/attachments/attachment_service_proxy.cc

Issue 213003004: Replace calls to 3-arg SyncData::CreateLocalData with 5-arg version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Changes from self-review. 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 side-by-side diff with in-line comments
Download patch
Index: sync/api/attachments/attachment_service_proxy.cc
diff --git a/sync/api/attachments/attachment_service_proxy.cc b/sync/api/attachments/attachment_service_proxy.cc
index 065f467b54688c60edf42effc0494320285fe03a..49056aa1ebd1f44d410c515602fb9e5d101078cb 100644
--- a/sync/api/attachments/attachment_service_proxy.cc
+++ b/sync/api/attachments/attachment_service_proxy.cc
@@ -40,11 +40,20 @@ AttachmentServiceProxy::AttachmentServiceProxy() {}
AttachmentServiceProxy::AttachmentServiceProxy(
const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
- base::WeakPtr<syncer::AttachmentService> wrapped)
- : wrapped_task_runner_(wrapped_task_runner), wrapped_(wrapped) {
+ const base::WeakPtr<syncer::AttachmentService>& wrapped)
+ : wrapped_task_runner_(wrapped_task_runner),
+ core_(new ForwardingCore(wrapped)) {
DCHECK(wrapped_task_runner_);
}
+AttachmentServiceProxy::AttachmentServiceProxy(
+ const scoped_refptr<base::SequencedTaskRunner>& wrapped_task_runner,
+ const scoped_refptr<ForwardingCore>& core)
+ : wrapped_task_runner_(wrapped_task_runner), core_(core) {
+ DCHECK(wrapped_task_runner_);
+ DCHECK(core_);
+}
+
AttachmentServiceProxy::~AttachmentServiceProxy() {}
void AttachmentServiceProxy::GetOrDownloadAttachments(
@@ -56,7 +65,7 @@ void AttachmentServiceProxy::GetOrDownloadAttachments(
wrapped_task_runner_->PostTask(
FROM_HERE,
base::Bind(&AttachmentService::GetOrDownloadAttachments,
- wrapped_,
+ core_,
attachment_ids,
proxy_callback));
}
@@ -69,7 +78,7 @@ void AttachmentServiceProxy::DropAttachments(
&ProxyDropCallback, base::MessageLoopProxy::current(), callback);
wrapped_task_runner_->PostTask(FROM_HERE,
base::Bind(&AttachmentService::DropAttachments,
- wrapped_,
+ core_,
attachment_ids,
proxy_callback));
}
@@ -78,14 +87,14 @@ void AttachmentServiceProxy::OnSyncDataAdd(const SyncData& sync_data) {
DCHECK(wrapped_task_runner_);
wrapped_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&AttachmentService::OnSyncDataAdd, wrapped_, sync_data));
+ base::Bind(&AttachmentService::OnSyncDataAdd, core_, sync_data));
}
void AttachmentServiceProxy::OnSyncDataDelete(const SyncData& sync_data) {
DCHECK(wrapped_task_runner_);
wrapped_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&AttachmentService::OnSyncDataDelete, wrapped_, sync_data));
+ base::Bind(&AttachmentService::OnSyncDataDelete, core_, sync_data));
}
void AttachmentServiceProxy::OnSyncDataUpdate(
@@ -95,9 +104,58 @@ void AttachmentServiceProxy::OnSyncDataUpdate(
wrapped_task_runner_->PostTask(
FROM_HERE,
base::Bind(&AttachmentService::OnSyncDataUpdate,
- wrapped_,
+ core_,
old_attachment_ids,
updated_sync_data));
}
+AttachmentServiceProxy::ForwardingCore::ForwardingCore(
+ const base::WeakPtr<syncer::AttachmentService>& wrapped)
+ : wrapped_(wrapped) {}
+
+AttachmentServiceProxy::ForwardingCore::~ForwardingCore() {}
+
+void AttachmentServiceProxy::ForwardingCore::GetOrDownloadAttachments(
+ const AttachmentIdList& attachment_ids,
+ const GetOrDownloadCallback& callback) {
+ if (!wrapped_) {
+ return;
+ }
+ wrapped_->GetOrDownloadAttachments(attachment_ids, callback);
+}
+
+void AttachmentServiceProxy::ForwardingCore::DropAttachments(
+ const AttachmentIdList& attachment_ids,
+ const DropCallback& callback) {
+ if (!wrapped_) {
+ return;
+ }
+ wrapped_->DropAttachments(attachment_ids, callback);
+}
+
+void AttachmentServiceProxy::ForwardingCore::OnSyncDataAdd(
+ const SyncData& sync_data) {
+ if (!wrapped_) {
+ return;
+ }
+ wrapped_->OnSyncDataAdd(sync_data);
+}
+
+void AttachmentServiceProxy::ForwardingCore::OnSyncDataDelete(
+ const SyncData& sync_data) {
+ if (!wrapped_) {
+ return;
+ }
+ wrapped_->OnSyncDataDelete(sync_data);
+}
+
+void AttachmentServiceProxy::ForwardingCore::OnSyncDataUpdate(
+ const AttachmentIdList& old_attachment_ids,
+ const SyncData& updated_sync_data) {
+ if (!wrapped_) {
+ return;
+ }
+ wrapped_->OnSyncDataUpdate(old_attachment_ids, updated_sync_data);
+}
+
} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698