summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authormaniscalco <maniscalco@chromium.org>2015-03-03 16:47:12 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-04 00:48:36 +0000
commitf9648891191bb34bce0a4c4d0110d82dc23b9ee6 (patch)
treeaaee4e673fdb500a8fad4ba059ef61972722a540 /sync
parent718dcc5bac721772b56655db19a0d6a745c21d25 (diff)
downloadchromium_src-f9648891191bb34bce0a4c4d0110d82dc23b9ee6.zip
chromium_src-f9648891191bb34bce0a4c4d0110d82dc23b9ee6.tar.gz
chromium_src-f9648891191bb34bce0a4c4d0110d82dc23b9ee6.tar.bz2
[Sync] Remove DropAttachments from AttachmentService and SyncData
AttachmentService and SyncData no longer need to provide a drop method beecause model type code can drop attachments using its AttachmentStore. BUG= Review URL: https://codereview.chromium.org/973513002 Cr-Commit-Position: refs/heads/master@{#318981}
Diffstat (limited to 'sync')
-rw-r--r--sync/api/sync_data.cc6
-rw-r--r--sync/api/sync_data.h9
-rw-r--r--sync/api/sync_data_unittest.cc4
-rw-r--r--sync/internal_api/attachments/attachment_service_impl.cc22
-rw-r--r--sync/internal_api/attachments/attachment_service_proxy.cc31
-rw-r--r--sync/internal_api/attachments/attachment_service_proxy_unittest.cc24
-rw-r--r--sync/internal_api/public/attachments/attachment_service.h13
-rw-r--r--sync/internal_api/public/attachments/attachment_service_impl.h4
-rw-r--r--sync/internal_api/public/attachments/attachment_service_proxy.h4
9 files changed, 3 insertions, 114 deletions
diff --git a/sync/api/sync_data.cc b/sync/api/sync_data.cc
index 7fbdbc2..0dd567d 100644
--- a/sync/api/sync_data.cc
+++ b/sync/api/sync_data.cc
@@ -218,10 +218,4 @@ void SyncDataRemote::GetOrDownloadAttachments(
attachment_service_.GetOrDownloadAttachments(attachment_ids, callback);
}
-void SyncDataRemote::DropAttachments(
- const AttachmentIdList& attachment_ids,
- const AttachmentService::DropCallback& callback) {
- attachment_service_.DropAttachments(attachment_ids, callback);
-}
-
} // namespace syncer
diff --git a/sync/api/sync_data.h b/sync/api/sync_data.h
index 4e5acd3..6815896 100644
--- a/sync/api/sync_data.h
+++ b/sync/api/sync_data.h
@@ -190,15 +190,6 @@ class SYNC_EXPORT SyncDataRemote : public SyncData {
void GetOrDownloadAttachments(
const AttachmentIdList& attachment_ids,
const AttachmentService::GetOrDownloadCallback& callback);
-
- // Drop (delete from local storage) the attachments associated with this
- // SyncData specified in |attachment_ids|. This method will not delete
- // attachments from the server.
- //
- // |callback| will be invoked when the operation is complete (successfully
- // or otherwise).
- void DropAttachments(const AttachmentIdList& attachment_ids,
- const AttachmentService::DropCallback& callback);
};
// gmock printer helper.
diff --git a/sync/api/sync_data_unittest.cc b/sync/api/sync_data_unittest.cc
index a0a83cd..94c3f4c 100644
--- a/sync/api/sync_data_unittest.cc
+++ b/sync/api/sync_data_unittest.cc
@@ -117,8 +117,8 @@ TEST_F(SyncDataTest, CreateRemoteData) {
EXPECT_TRUE(data.GetAttachmentIds().empty());
}
-// TODO(maniscalco): Add test cases that verify GetLocalAttachmentsForUpload and
-// DropAttachments calls are passed through to the underlying AttachmentService.
+// TODO(maniscalco): Add test cases that verify GetLocalAttachmentsForUpload
+// calls are passed through to the underlying AttachmentService.
} // namespace
diff --git a/sync/internal_api/attachments/attachment_service_impl.cc b/sync/internal_api/attachments/attachment_service_impl.cc
index dab7aa7..cc04408 100644
--- a/sync/internal_api/attachments/attachment_service_impl.cc
+++ b/sync/internal_api/attachments/attachment_service_impl.cc
@@ -176,16 +176,6 @@ void AttachmentServiceImpl::GetOrDownloadAttachments(
state));
}
-void AttachmentServiceImpl::DropAttachments(
- const AttachmentIdList& attachment_ids,
- const DropCallback& callback) {
- DCHECK(CalledOnValidThread());
- attachment_store_->Drop(attachment_ids,
- base::Bind(&AttachmentServiceImpl::DropDone,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
-}
-
void AttachmentServiceImpl::ReadDone(
const scoped_refptr<GetOrDownloadState>& state,
const AttachmentStore::Result& result,
@@ -234,18 +224,6 @@ void AttachmentServiceImpl::WriteDone(
}
}
-void AttachmentServiceImpl::DropDone(const DropCallback& callback,
- const AttachmentStore::Result& result) {
- AttachmentService::DropResult drop_result =
- AttachmentService::DROP_UNSPECIFIED_ERROR;
- if (result == AttachmentStore::SUCCESS) {
- drop_result = AttachmentService::DROP_SUCCESS;
- }
- // TODO(maniscalco): Deal with case where an error occurred (bug 361251).
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, drop_result));
-}
-
void AttachmentServiceImpl::UploadDone(
const AttachmentUploader::UploadResult& result,
const AttachmentId& attachment_id) {
diff --git a/sync/internal_api/attachments/attachment_service_proxy.cc b/sync/internal_api/attachments/attachment_service_proxy.cc
index 6b1040b..92104ce 100644
--- a/sync/internal_api/attachments/attachment_service_proxy.cc
+++ b/sync/internal_api/attachments/attachment_service_proxy.cc
@@ -26,15 +26,6 @@ void ProxyGetOrDownloadCallback(
FROM_HERE, base::Bind(callback, result, base::Passed(&attachments)));
}
-// Invokes |callback| with |result| and |attachments| in the |task_runner|
-// thread.
-void ProxyDropCallback(
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- const AttachmentService::DropCallback& callback,
- const AttachmentService::DropResult& result) {
- task_runner->PostTask(FROM_HERE, base::Bind(callback, result));
-}
-
} // namespace
AttachmentServiceProxy::AttachmentServiceProxy() {
@@ -78,19 +69,6 @@ void AttachmentServiceProxy::GetOrDownloadAttachments(
proxy_callback));
}
-void AttachmentServiceProxy::DropAttachments(
- const AttachmentIdList& attachment_ids,
- const DropCallback& callback) {
- DCHECK(wrapped_task_runner_.get());
- DropCallback proxy_callback = base::Bind(
- &ProxyDropCallback, base::ThreadTaskRunnerHandle::Get(), callback);
- wrapped_task_runner_->PostTask(FROM_HERE,
- base::Bind(&AttachmentService::DropAttachments,
- core_,
- attachment_ids,
- proxy_callback));
-}
-
void AttachmentServiceProxy::UploadAttachments(
const AttachmentIdSet& attachment_ids) {
DCHECK(wrapped_task_runner_.get());
@@ -120,15 +98,6 @@ void AttachmentServiceProxy::Core::GetOrDownloadAttachments(
wrapped_->GetOrDownloadAttachments(attachment_ids, callback);
}
-void AttachmentServiceProxy::Core::DropAttachments(
- const AttachmentIdList& attachment_ids,
- const DropCallback& callback) {
- if (!wrapped_) {
- return;
- }
- wrapped_->DropAttachments(attachment_ids, callback);
-}
-
void AttachmentServiceProxy::Core::UploadAttachments(
const AttachmentIdSet& attachment_ids) {
if (!wrapped_) {
diff --git a/sync/internal_api/attachments/attachment_service_proxy_unittest.cc b/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
index 2353d26..41af1b23 100644
--- a/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
+++ b/sync/internal_api/attachments/attachment_service_proxy_unittest.cc
@@ -48,14 +48,6 @@ class StubAttachmentService : public AttachmentService,
base::Passed(&attachments)));
}
- void DropAttachments(const AttachmentIdList& attachment_ids,
- const DropCallback& callback) override {
- CalledOnValidThread();
- Increment();
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(callback, AttachmentService::DROP_SUCCESS));
- }
-
void UploadAttachments(const AttachmentIdSet& attachments_ids) override {
CalledOnValidThread();
Increment();
@@ -101,10 +93,7 @@ class AttachmentServiceProxyTest : public testing::Test,
callback_get_or_download =
base::Bind(&AttachmentServiceProxyTest::IncrementGetOrDownload,
base::Unretained(this));
- callback_drop = base::Bind(&AttachmentServiceProxyTest::IncrementDrop,
- base::Unretained(this));
count_callback_get_or_download = 0;
- count_callback_drop = 0;
}
void TearDown() override {
@@ -124,12 +113,6 @@ class AttachmentServiceProxyTest : public testing::Test,
++count_callback_get_or_download;
}
- // a DropCallback
- void IncrementDrop(const AttachmentService::DropResult&) {
- CalledOnValidThread();
- ++count_callback_drop;
- }
-
void WaitForStubThread() {
base::WaitableEvent done(false, false);
stub_thread->message_loop()->PostTask(
@@ -144,12 +127,9 @@ class AttachmentServiceProxyTest : public testing::Test,
scoped_ptr<AttachmentServiceProxy> proxy;
AttachmentService::GetOrDownloadCallback callback_get_or_download;
- AttachmentService::DropCallback callback_drop;
// number of times callback_get_or_download was invoked
int count_callback_get_or_download;
- // number of times callback_drop was invoked
- int count_callback_drop;
};
TEST_F(AttachmentServiceProxyTest, GetStore) {
@@ -161,11 +141,10 @@ TEST_F(AttachmentServiceProxyTest, GetStore) {
// thread.
TEST_F(AttachmentServiceProxyTest, MethodsAreProxied) {
proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download);
- proxy->DropAttachments(AttachmentIdList(), callback_drop);
proxy->UploadAttachments(AttachmentIdSet());
// Wait for the posted calls to execute in the stub thread.
WaitForStubThread();
- EXPECT_EQ(3, stub->GetCallCount());
+ EXPECT_EQ(2, stub->GetCallCount());
// At this point the stub thread has finished executed the calls. However, the
// result callbacks it has posted may not have executed yet. Wait a second
// time to ensure the stub thread has executed the posted result callbacks.
@@ -173,7 +152,6 @@ TEST_F(AttachmentServiceProxyTest, MethodsAreProxied) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, count_callback_get_or_download);
- EXPECT_EQ(1, count_callback_drop);
}
// Verify that it's safe to use an AttachmentServiceProxy even after its wrapped
diff --git a/sync/internal_api/public/attachments/attachment_service.h b/sync/internal_api/public/attachments/attachment_service.h
index 758f960..944a71f 100644
--- a/sync/internal_api/public/attachments/attachment_service.h
+++ b/sync/internal_api/public/attachments/attachment_service.h
@@ -36,15 +36,6 @@ class SYNC_EXPORT AttachmentService {
void(const GetOrDownloadResult&, scoped_ptr<AttachmentMap> attachments)>
GetOrDownloadCallback;
- // The result of a DropAttachments operation.
- enum DropResult {
- DROP_SUCCESS, // No error, all attachments dropped.
- DROP_UNSPECIFIED_ERROR, // An unspecified error occurred. Some or all
- // attachments may not have been dropped.
- };
-
- typedef base::Callback<void(const DropResult&)> DropCallback;
-
// An interface that embedder code implements to be notified about different
// events that originate from AttachmentService.
// This interface will be called from the same thread AttachmentService was
@@ -71,10 +62,6 @@ class SYNC_EXPORT AttachmentService {
const AttachmentIdList& attachment_ids,
const GetOrDownloadCallback& callback) = 0;
- // See SyncData::DropAttachments.
- virtual void DropAttachments(const AttachmentIdList& attachment_ids,
- const DropCallback& callback) = 0;
-
// Schedules the attachments identified by |attachment_ids| to be uploaded to
// the server.
//
diff --git a/sync/internal_api/public/attachments/attachment_service_impl.h b/sync/internal_api/public/attachments/attachment_service_impl.h
index c9992c0..e35f548 100644
--- a/sync/internal_api/public/attachments/attachment_service_impl.h
+++ b/sync/internal_api/public/attachments/attachment_service_impl.h
@@ -62,8 +62,6 @@ class SYNC_EXPORT AttachmentServiceImpl
AttachmentStore* GetStore() override;
void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
const GetOrDownloadCallback& callback) override;
- void DropAttachments(const AttachmentIdList& attachment_ids,
- const DropCallback& callback) override;
void UploadAttachments(const AttachmentIdSet& attachment_ids) override;
// NetworkChangeObserver implementation.
@@ -85,8 +83,6 @@ class SYNC_EXPORT AttachmentServiceImpl
void WriteDone(const scoped_refptr<GetOrDownloadState>& state,
const Attachment& attachment,
const AttachmentStore::Result& result);
- void DropDone(const DropCallback& callback,
- const AttachmentStore::Result& result);
void UploadDone(const AttachmentUploader::UploadResult& result,
const AttachmentId& attachment_id);
void DownloadDone(const scoped_refptr<GetOrDownloadState>& state,
diff --git a/sync/internal_api/public/attachments/attachment_service_proxy.h b/sync/internal_api/public/attachments/attachment_service_proxy.h
index cab107e..3a96660 100644
--- a/sync/internal_api/public/attachments/attachment_service_proxy.h
+++ b/sync/internal_api/public/attachments/attachment_service_proxy.h
@@ -56,8 +56,6 @@ class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService {
AttachmentStore* GetStore() override;
void GetOrDownloadAttachments(const AttachmentIdList& attachment_ids,
const GetOrDownloadCallback& callback) override;
- void DropAttachments(const AttachmentIdList& attachment_ids,
- const DropCallback& callback) override;
void UploadAttachments(const AttachmentIdSet& attachment_ids) override;
protected:
@@ -85,8 +83,6 @@ class SYNC_EXPORT AttachmentServiceProxy : public AttachmentService {
void GetOrDownloadAttachments(
const AttachmentIdList& attachment_ids,
const GetOrDownloadCallback& callback) override;
- void DropAttachments(const AttachmentIdList& attachment_ids,
- const DropCallback& callback) override;
void UploadAttachments(const AttachmentIdSet& attachment_ids) override;
protected: