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

Unified Diff: components/sync/model/attachments/attachment_service_proxy_unittest.cc

Issue 2915453002: Deprecate NonThreadSafe in components/sync in favor of SequenceChecker. (Closed)
Patch Set: fix comment Created 3 years, 7 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: components/sync/model/attachments/attachment_service_proxy_unittest.cc
diff --git a/components/sync/model/attachments/attachment_service_proxy_unittest.cc b/components/sync/model/attachments/attachment_service_proxy_unittest.cc
index 52faba4475a8aad71ab75f0183153b308b9a081b..13bee5a21073115fa3ba24bee62af1e3ea843dda 100644
--- a/components/sync/model/attachments/attachment_service_proxy_unittest.cc
+++ b/components/sync/model/attachments/attachment_service_proxy_unittest.cc
@@ -12,10 +12,10 @@
#include "base/memory/ref_counted_memory.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
-#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/sync/base/model_type.h"
@@ -26,21 +26,22 @@ namespace syncer {
// A stub implementation of AttachmentService that counts the number of times
// its methods are invoked.
-class StubAttachmentService : public AttachmentService,
- public base::NonThreadSafe {
+class StubAttachmentService : public AttachmentService {
public:
StubAttachmentService() : call_count_(0), weak_ptr_factory_(this) {
// DetachFromThread because we will be constructed in one thread and
// used/destroyed in another.
- DetachFromThread();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
}
- ~StubAttachmentService() override {}
+ ~StubAttachmentService() override {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ }
void GetOrDownloadAttachments(
const AttachmentIdList& attachment_ids,
const GetOrDownloadCallback& callback) override {
- CalledOnValidThread();
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Increment();
std::unique_ptr<AttachmentMap> attachments(new AttachmentMap());
base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -50,7 +51,7 @@ class StubAttachmentService : public AttachmentService,
}
void UploadAttachments(const AttachmentIdList& attachments_ids) override {
- CalledOnValidThread();
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
Increment();
}
@@ -76,15 +77,16 @@ class StubAttachmentService : public AttachmentService,
base::AutoLock lock(mutex_);
++call_count_;
}
+
+ SEQUENCE_CHECKER(sequence_checker_);
};
-class AttachmentServiceProxyTest : public testing::Test,
- public base::NonThreadSafe {
+class AttachmentServiceProxyTest : public testing::Test {
protected:
AttachmentServiceProxyTest() {}
void SetUp() override {
- CalledOnValidThread();
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
stub_thread_ =
base::MakeUnique<base::Thread>("attachment service stub thread");
stub_thread_->Start();
@@ -111,7 +113,7 @@ class AttachmentServiceProxyTest : public testing::Test,
// a GetOrDownloadCallback
void IncrementGetOrDownload(const AttachmentService::GetOrDownloadResult&,
std::unique_ptr<AttachmentMap>) {
- CalledOnValidThread();
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
++count_callback_get_or_download_;
}
@@ -133,6 +135,8 @@ class AttachmentServiceProxyTest : public testing::Test,
// number of times callback_get_or_download_ was invoked
int count_callback_get_or_download_;
+
+ SEQUENCE_CHECKER(sequence_checker_);
};
// Verify that each of AttachmentServiceProxy's methods are invoked on the stub.
« no previous file with comments | « components/sync/engine_impl/sync_scheduler_impl.cc ('k') | components/sync/model_impl/attachments/attachment_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698