Commit d3f935d2 authored by Olivier Li's avatar Olivier Li Committed by Commit Bot

Assert run on correct Sequence instead of Thread in LoopbackServer.

This is ground work for having ProfileSyncService's backend task runner use the
ThreadPool.

This class in particular affects LocalSynctTest.Shouldstart when work is done
fully on the Threadpool.

Bug: 1014464
Change-Id: Id91c6b1682648a6fdb38efef5145ab4d6af0b2e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865427
Commit-Queue: Oliver Li <olivierli@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707363}
parent 78b5a541
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/sequence_checker.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
...@@ -255,7 +256,7 @@ std::string LoopbackServer::GenerateNewKeystoreKey() const { ...@@ -255,7 +256,7 @@ std::string LoopbackServer::GenerateNewKeystoreKey() const {
bool LoopbackServer::CreatePermanentBookmarkFolder( bool LoopbackServer::CreatePermanentBookmarkFolder(
const std::string& server_tag, const std::string& server_tag,
const std::string& name) { const std::string& name) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::unique_ptr<LoopbackServerEntity> entity = std::unique_ptr<LoopbackServerEntity> entity =
PersistentPermanentEntity::CreateNew( PersistentPermanentEntity::CreateNew(
syncer::BOOKMARKS, server_tag, name, syncer::BOOKMARKS, server_tag, name,
...@@ -306,7 +307,7 @@ void LoopbackServer::SaveEntity(std::unique_ptr<LoopbackServerEntity> entity) { ...@@ -306,7 +307,7 @@ void LoopbackServer::SaveEntity(std::unique_ptr<LoopbackServerEntity> entity) {
net::HttpStatusCode LoopbackServer::HandleCommand(const string& request, net::HttpStatusCode LoopbackServer::HandleCommand(const string& request,
std::string* response) { std::string* response) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
response->clear(); response->clear();
sync_pb::ClientToServerMessage message; sync_pb::ClientToServerMessage message;
...@@ -663,7 +664,7 @@ bool LoopbackServer::HandleCommitRequest( ...@@ -663,7 +664,7 @@ bool LoopbackServer::HandleCommitRequest(
} }
void LoopbackServer::ClearServerData() { void LoopbackServer::ClearServerData() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
entities_.clear(); entities_.clear();
keystore_keys_.clear(); keystore_keys_.clear();
++store_birthday_; ++store_birthday_;
...@@ -672,13 +673,13 @@ void LoopbackServer::ClearServerData() { ...@@ -672,13 +673,13 @@ void LoopbackServer::ClearServerData() {
} }
std::string LoopbackServer::GetStoreBirthday() const { std::string LoopbackServer::GetStoreBirthday() const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return base::NumberToString(store_birthday_); return base::NumberToString(store_birthday_);
} }
std::vector<sync_pb::SyncEntity> LoopbackServer::GetSyncEntitiesByModelType( std::vector<sync_pb::SyncEntity> LoopbackServer::GetSyncEntitiesByModelType(
ModelType model_type) { ModelType model_type) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::vector<sync_pb::SyncEntity> sync_entities; std::vector<sync_pb::SyncEntity> sync_entities;
for (const auto& kv : entities_) { for (const auto& kv : entities_) {
const LoopbackServerEntity& entity = *kv.second; const LoopbackServerEntity& entity = *kv.second;
...@@ -694,7 +695,7 @@ std::vector<sync_pb::SyncEntity> LoopbackServer::GetSyncEntitiesByModelType( ...@@ -694,7 +695,7 @@ std::vector<sync_pb::SyncEntity> LoopbackServer::GetSyncEntitiesByModelType(
std::vector<sync_pb::SyncEntity> std::vector<sync_pb::SyncEntity>
LoopbackServer::GetPermanentSyncEntitiesByModelType(ModelType model_type) { LoopbackServer::GetPermanentSyncEntitiesByModelType(ModelType model_type) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::vector<sync_pb::SyncEntity> sync_entities; std::vector<sync_pb::SyncEntity> sync_entities;
for (const auto& kv : entities_) { for (const auto& kv : entities_) {
const LoopbackServerEntity& entity = *kv.second; const LoopbackServerEntity& entity = *kv.second;
...@@ -710,7 +711,7 @@ LoopbackServer::GetPermanentSyncEntitiesByModelType(ModelType model_type) { ...@@ -710,7 +711,7 @@ LoopbackServer::GetPermanentSyncEntitiesByModelType(ModelType model_type) {
std::unique_ptr<base::DictionaryValue> std::unique_ptr<base::DictionaryValue>
LoopbackServer::GetEntitiesAsDictionaryValue() { LoopbackServer::GetEntitiesAsDictionaryValue() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::unique_ptr<base::DictionaryValue> dictionary( std::unique_ptr<base::DictionaryValue> dictionary(
new base::DictionaryValue()); new base::DictionaryValue());
...@@ -783,7 +784,7 @@ bool LoopbackServer::ModifyBookmarkEntity( ...@@ -783,7 +784,7 @@ bool LoopbackServer::ModifyBookmarkEntity(
} }
void LoopbackServer::SerializeState(sync_pb::LoopbackServerProto* proto) const { void LoopbackServer::SerializeState(sync_pb::LoopbackServerProto* proto) const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
proto->set_version(kCurrentLoopbackServerProtoVersion); proto->set_version(kCurrentLoopbackServerProtoVersion);
proto->set_store_birthday(store_birthday_); proto->set_store_birthday(store_birthday_);
...@@ -798,7 +799,7 @@ void LoopbackServer::SerializeState(sync_pb::LoopbackServerProto* proto) const { ...@@ -798,7 +799,7 @@ void LoopbackServer::SerializeState(sync_pb::LoopbackServerProto* proto) const {
bool LoopbackServer::DeSerializeState( bool LoopbackServer::DeSerializeState(
const sync_pb::LoopbackServerProto& proto) { const sync_pb::LoopbackServerProto& proto) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(proto.version(), kCurrentLoopbackServerProtoVersion); DCHECK_EQ(proto.version(), kCurrentLoopbackServerProtoVersion);
store_birthday_ = proto.store_birthday(); store_birthday_ = proto.store_birthday();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/threading/thread_checker.h" #include "base/sequence_checker.h"
#include "base/values.h" #include "base/values.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/engine_impl/loopback_server/loopback_server_entity.h" #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h"
...@@ -235,8 +235,8 @@ class LoopbackServer { ...@@ -235,8 +235,8 @@ class LoopbackServer {
// The file used to store the local sync data. // The file used to store the local sync data.
base::FilePath persistent_file_; base::FilePath persistent_file_;
// Used to verify that LoopbackServer is only used from one thread. // Used to verify that LoopbackServer is only used from one sequence.
base::ThreadChecker thread_checker_; SEQUENCE_CHECKER(sequence_checker_);
// Used to observe the completion of commit messages for the sake of testing. // Used to observe the completion of commit messages for the sake of testing.
ObserverForTests* observer_for_tests_; ObserverForTests* observer_for_tests_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment