diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 23:06:08 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 23:06:08 +0000 |
commit | 5252c891ca0f5e1fad81adcd86d7889ecf0abc9f (patch) | |
tree | 3dfbbf52e2072f978683d740a13488860564a553 /sync/test | |
parent | 418feeea43d284ae95dc022d386fe06e4fb78bc8 (diff) | |
download | chromium_src-5252c891ca0f5e1fad81adcd86d7889ecf0abc9f.zip chromium_src-5252c891ca0f5e1fad81adcd86d7889ecf0abc9f.tar.gz chromium_src-5252c891ca0f5e1fad81adcd86d7889ecf0abc9f.tar.bz2 |
Remove sync's ModelSafeWorkerRegistrar
The ModelSafeWorkerRegistrar interface was a wrapper around the
SyncBackendRegistrar. When the sync thread wanted to access the
SyncBackendRegistrar's information regarding currently enabled types or
workers, it would use the ModelSafeWorkerRegistrar interface to do it.
This change removes this implicit inter-thread communication. Where
necessary, it modifies the SyncBackendHost, SyncManager, SyncScheduler
and the SyncSessionContext to ensure that these classes have access to a
fresh copy of the SyncBackendRegistrar's data whenever it is required.
The most biggest consequence of this patch is that the
SyncSessionContext now maintains a copy of the list of ModelSafeWorkers
and routing info, rather than a pointer to the ModelSafeWorkerRegistrar.
Various functions along the path to CleanupDisabledTypes, Configure and
StartSyncingNormally have been updated to ensure that the latest routing
info is made available to the session context.
Future patches may refactor this code to reduce the amount of duplicated
state. This work was intentionally left to future patches to reduce the
risk of the current change. The refactoring should be much easier once
we're convinced that the new, explicit inter-thread communication
mechanisms are no more buggy than the existing code.
BUG=103326
TEST=sync_integration_tests
Review URL: https://chromiumcodereview.appspot.com/10388187
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r-- | sync/test/engine/fake_model_safe_worker_registrar.cc | 42 | ||||
-rw-r--r-- | sync/test/engine/fake_model_safe_worker_registrar.h | 36 | ||||
-rw-r--r-- | sync/test/engine/syncer_command_test.h | 18 |
3 files changed, 8 insertions, 88 deletions
diff --git a/sync/test/engine/fake_model_safe_worker_registrar.cc b/sync/test/engine/fake_model_safe_worker_registrar.cc deleted file mode 100644 index be4a0d9..0000000 --- a/sync/test/engine/fake_model_safe_worker_registrar.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "sync/test/engine/fake_model_safe_worker_registrar.h" - -#include "sync/test/engine/fake_model_worker.h" - -namespace browser_sync { - -FakeModelSafeWorkerRegistrar::FakeModelSafeWorkerRegistrar( - const ModelSafeRoutingInfo& routes) : routes_(routes) { - std::set<ModelSafeGroup> groups; - for (ModelSafeRoutingInfo::const_iterator it = routes_.begin(); - it != routes_.end(); ++it) { - groups.insert(it->second); - } - // Sessions always expect a passive worker to be present. - groups.insert(GROUP_PASSIVE); - - for (std::set<ModelSafeGroup>::const_iterator it = groups.begin(); - it != groups.end(); ++it) { - workers_.push_back(make_scoped_refptr(new FakeModelWorker(*it))); - } -} - -FakeModelSafeWorkerRegistrar::~FakeModelSafeWorkerRegistrar() {} - -void FakeModelSafeWorkerRegistrar::GetWorkers( - std::vector<ModelSafeWorker*>* out) { - for (std::vector<scoped_refptr<ModelSafeWorker> >::const_iterator it = - workers_.begin(); it != workers_.end(); ++it) { - out->push_back(it->get()); - } -} - -void FakeModelSafeWorkerRegistrar::GetModelSafeRoutingInfo( - ModelSafeRoutingInfo* out) { - *out = routes_; -} - -} // namespace browser_sync diff --git a/sync/test/engine/fake_model_safe_worker_registrar.h b/sync/test/engine/fake_model_safe_worker_registrar.h deleted file mode 100644 index 2eff29b..0000000 --- a/sync/test/engine/fake_model_safe_worker_registrar.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SYNC_TEST_ENGINE_FAKE_MODEL_SAFE_WORKER_REGISTRAR_H_ -#define SYNC_TEST_ENGINE_FAKE_MODEL_SAFE_WORKER_REGISTRAR_H_ -#pragma once - -#include <vector> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/ref_counted.h" -#include "sync/engine/model_safe_worker.h" - -namespace browser_sync { - -class FakeModelSafeWorkerRegistrar : public ModelSafeWorkerRegistrar { - public: - explicit FakeModelSafeWorkerRegistrar(const ModelSafeRoutingInfo& routes); - - virtual ~FakeModelSafeWorkerRegistrar(); - virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) OVERRIDE; - virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) OVERRIDE; - - private: - const ModelSafeRoutingInfo routes_; - std::vector<scoped_refptr<ModelSafeWorker> > workers_; - - DISALLOW_COPY_AND_ASSIGN(FakeModelSafeWorkerRegistrar); -}; - -} // namespace browser_sync - -#endif // SYNC_TEST_ENGINE_FAKE_MODEL_SAFE_WORKER_REGISTRAR_H_ - diff --git a/sync/test/engine/syncer_command_test.h b/sync/test/engine/syncer_command_test.h index bfa567f..1fe919b 100644 --- a/sync/test/engine/syncer_command_test.h +++ b/sync/test/engine/syncer_command_test.h @@ -42,8 +42,7 @@ class MockDebugInfoGetter : public browser_sync::sessions::DebugInfoGetter { // SyncerCommands, providing convenient access to a test directory // and a syncer session. class SyncerCommandTestBase : public testing::Test, - public sessions::SyncSession::Delegate, - public ModelSafeWorkerRegistrar { + public sessions::SyncSession::Delegate { public: enum UseMockDirectory { USE_MOCK_DIRECTORY @@ -77,13 +76,14 @@ class SyncerCommandTestBase : public testing::Test, return; } - // ModelSafeWorkerRegistrar implementation. - virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) OVERRIDE { + std::vector<ModelSafeWorker*> GetWorkers() { + std::vector<ModelSafeWorker*> workers; std::vector<scoped_refptr<ModelSafeWorker> >::iterator it; for (it = workers_.begin(); it != workers_.end(); ++it) - out->push_back(*it); + workers.push_back(*it); + return workers; } - virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) OVERRIDE { + void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { ModelSafeRoutingInfo copy(routing_info_); out->swap(copy); } @@ -97,7 +97,6 @@ class SyncerCommandTestBase : public testing::Test, sessions::SyncSessionContext* context() const { return context_.get(); } sessions::SyncSession::Delegate* delegate() { return this; } - ModelSafeWorkerRegistrar* registrar() { return this; } // Lazily create a session requesting all datatypes with no payload. sessions::SyncSession* session() { @@ -110,8 +109,7 @@ class SyncerCommandTestBase : public testing::Test, // Create a session with the provided source. sessions::SyncSession* session(const sessions::SyncSourceInfo& source) { if (!session_.get()) { - std::vector<ModelSafeWorker*> workers; - GetWorkers(&workers); + std::vector<ModelSafeWorker*> workers = GetWorkers(); session_.reset(new sessions::SyncSession(context(), delegate(), source, routing_info_, workers)); } @@ -125,7 +123,7 @@ class SyncerCommandTestBase : public testing::Test, void ResetContext() { context_.reset(new sessions::SyncSessionContext( mock_server_.get(), directory(), - registrar(), &extensions_activity_monitor_, + routing_info_, GetWorkers(), &extensions_activity_monitor_, std::vector<SyncEngineEventListener*>(), &mock_debug_info_getter_, &traffic_recorder_)); |