summaryrefslogtreecommitdiffstats
path: root/sync/engine
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 03:11:06 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-11 03:11:06 +0000
commitf8197029e47adb3512609ec18f5aa7f3059befd3 (patch)
tree55aca64c9cf27ff7a9dc0cbc3a401ae27692dfba /sync/engine
parent2db1e9f2c1502d384c9e5f849cfc85eec7875787 (diff)
downloadchromium_src-f8197029e47adb3512609ec18f5aa7f3059befd3.zip
chromium_src-f8197029e47adb3512609ec18f5aa7f3059befd3.tar.gz
chromium_src-f8197029e47adb3512609ec18f5aa7f3059befd3.tar.bz2
sync: Consistently refcount ModelSafeWorkers
Certain interfaces in sync had signatures that included vectors of raw pointers to ModelSafeWorkers. The use of raw pointers to refcounted objects looks a lot like a bug waiting to happen. This CL replaces any use of std::vector<ModelSafeWorker*> with std::vector<scoped_refptr<ModelSafeWorker> >. This is not expected to alter sync behavior in any significant way. BUG=332251 Review URL: https://codereview.chromium.org/130193002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r--sync/engine/sync_scheduler_unittest.cc10
-rw-r--r--sync/engine/syncer_unittest.cc14
2 files changed, 6 insertions, 18 deletions
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
index e587655..97d9ab8 100644
--- a/sync/engine/sync_scheduler_unittest.cc
+++ b/sync/engine/sync_scheduler_unittest.cc
@@ -125,17 +125,11 @@ class SyncSchedulerTest : public testing::Test {
workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_DB)));
workers_.push_back(make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE)));
- std::vector<ModelSafeWorker*> workers;
- for (std::vector<scoped_refptr<FakeModelWorker> >::iterator it =
- workers_.begin(); it != workers_.end(); ++it) {
- workers.push_back(it->get());
- }
-
connection_.reset(new MockConnectionManager(directory(),
&cancelation_signal_));
connection_->SetServerReachable();
context_.reset(new SyncSessionContext(
- connection_.get(), directory(), workers,
+ connection_.get(), directory(), workers_,
extensions_activity_.get(),
std::vector<SyncEngineEventListener*>(), NULL, NULL,
true, // enable keystore encryption
@@ -229,7 +223,7 @@ class SyncSchedulerTest : public testing::Test {
scoped_ptr<SyncSchedulerImpl> scheduler_;
MockSyncer* syncer_;
MockDelayProvider* delay_;
- std::vector<scoped_refptr<FakeModelWorker> > workers_;
+ std::vector<scoped_refptr<ModelSafeWorker> > workers_;
scoped_refptr<ExtensionsActivity> extensions_activity_;
ModelSafeRoutingInfo routing_info_;
base::WeakPtrFactory<SyncSchedulerTest> weak_ptr_factory_;
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index 19aff7c..951d443c 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -154,10 +154,6 @@ class SyncerTest : public testing::Test,
const sessions::SyncSessionSnapshot& snapshot) OVERRIDE {
}
- void GetWorkers(std::vector<ModelSafeWorker*>* out) {
- out->push_back(worker_.get());
- }
-
void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
// We're just testing the sync engine here, so we shunt everything to
// the SyncerThread. Datatypes which aren't enabled aren't in the map.
@@ -215,19 +211,17 @@ class SyncerTest : public testing::Test,
EnableDatatype(NIGORI);
EnableDatatype(PREFERENCES);
EnableDatatype(NIGORI);
- worker_ = new FakeModelWorker(GROUP_PASSIVE);
+ workers_.push_back(scoped_refptr<ModelSafeWorker>(
+ new FakeModelWorker(GROUP_PASSIVE)));
std::vector<SyncEngineEventListener*> listeners;
listeners.push_back(this);
ModelSafeRoutingInfo routing_info;
- std::vector<ModelSafeWorker*> workers;
-
GetModelSafeRoutingInfo(&routing_info);
- GetWorkers(&workers);
context_.reset(
new SyncSessionContext(
- mock_server_.get(), directory(), workers,
+ mock_server_.get(), directory(), workers_,
extensions_activity_,
listeners, debug_info_getter_.get(), &traffic_recorder_,
true, // enable keystore encryption
@@ -504,7 +498,7 @@ class SyncerTest : public testing::Test,
base::TimeDelta last_long_poll_interval_received_;
base::TimeDelta last_sessions_commit_delay_seconds_;
int last_client_invalidation_hint_buffer_size_;
- scoped_refptr<ModelSafeWorker> worker_;
+ std::vector<scoped_refptr<ModelSafeWorker> > workers_;
ModelTypeSet enabled_datatypes_;
TrafficRecorder traffic_recorder_;