summaryrefslogtreecommitdiffstats
path: root/sync/test
diff options
context:
space:
mode:
authorearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-25 19:12:17 +0000
committerearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-25 19:12:17 +0000
commitbfd80f0bbc586d6254724530c1dbe376fd18e7eb (patch)
treef2bbe743018b4bc5ffef0c67e7a45805ac520aa5 /sync/test
parentaaffe1b11632e13935ef54148bfd6373e2c08cd7 (diff)
downloadchromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.zip
chromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.tar.gz
chromium_src-bfd80f0bbc586d6254724530c1dbe376fd18e7eb.tar.bz2
Revert 213642 "Lock-free shutdown of profile sync service. Chang..."
Reverting due to memory leaks. BUG=264325 > Lock-free shutdown of profile sync service. Changes include: > * Disconnect non-frontend processor/associator to stop accessing directory > so that sync backend can be shut down without waiting. > * Change non-frontend controller so that creation/destruction of > processor/associator doesn't depend on valid controller. So > scoped wait on stopping controller can be removed. > * Move sync thread to PSS. It's created when starting first backend and > destroyed on last browser thread. > > BUG=19757 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=210333 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=210955 > > Review URL: https://chromiumcodereview.appspot.com/16770005 TBR=haitaol@chromium.org Review URL: https://codereview.chromium.org/20374005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213671 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r--sync/test/engine/fake_sync_scheduler.cc6
-rw-r--r--sync/test/engine/fake_sync_scheduler.h5
-rw-r--r--sync/test/engine/syncer_command_test.cc2
-rw-r--r--sync/test/engine/syncer_command_test.h6
-rw-r--r--sync/test/fake_extensions_activity_monitor.cc31
-rw-r--r--sync/test/fake_extensions_activity_monitor.h33
6 files changed, 75 insertions, 8 deletions
diff --git a/sync/test/engine/fake_sync_scheduler.cc b/sync/test/engine/fake_sync_scheduler.cc
index 585248e..200edb0 100644
--- a/sync/test/engine/fake_sync_scheduler.cc
+++ b/sync/test/engine/fake_sync_scheduler.cc
@@ -6,14 +6,16 @@
namespace syncer {
-FakeSyncScheduler::FakeSyncScheduler() {}
+FakeSyncScheduler::FakeSyncScheduler()
+ : created_on_loop_(base::MessageLoop::current()) {}
FakeSyncScheduler::~FakeSyncScheduler() {}
void FakeSyncScheduler::Start(Mode mode) {
}
-void FakeSyncScheduler::RequestStop() {
+void FakeSyncScheduler::RequestStop(const base::Closure& callback) {
+ created_on_loop_->PostTask(FROM_HERE, callback);
}
void FakeSyncScheduler::ScheduleLocalNudge(
diff --git a/sync/test/engine/fake_sync_scheduler.h b/sync/test/engine/fake_sync_scheduler.h
index 29757e2..97deb91 100644
--- a/sync/test/engine/fake_sync_scheduler.h
+++ b/sync/test/engine/fake_sync_scheduler.h
@@ -20,7 +20,7 @@ class FakeSyncScheduler : public SyncScheduler {
virtual ~FakeSyncScheduler();
virtual void Start(Mode mode) OVERRIDE;
- virtual void RequestStop() OVERRIDE;
+ virtual void RequestStop(const base::Closure& callback) OVERRIDE;
virtual void ScheduleLocalNudge(
const base::TimeDelta& desired_delay,
ModelTypeSet types,
@@ -58,6 +58,9 @@ class FakeSyncScheduler : public SyncScheduler {
virtual void OnShouldStopSyncingPermanently() OVERRIDE;
virtual void OnSyncProtocolError(
const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
+
+ private:
+ base::MessageLoop* const created_on_loop_;
};
} // namespace syncer
diff --git a/sync/test/engine/syncer_command_test.cc b/sync/test/engine/syncer_command_test.cc
index 68edbbd..833ed9a 100644
--- a/sync/test/engine/syncer_command_test.cc
+++ b/sync/test/engine/syncer_command_test.cc
@@ -17,8 +17,6 @@ SyncerCommandTestBase::~SyncerCommandTestBase() {
}
void SyncerCommandTestBase::SetUp() {
- extensions_activity_ = new ExtensionsActivity();
-
// The session always expects there to be a passive worker.
workers()->push_back(
make_scoped_refptr(new FakeModelWorker(GROUP_PASSIVE)));
diff --git a/sync/test/engine/syncer_command_test.h b/sync/test/engine/syncer_command_test.h
index 89c2aba..93106b9 100644
--- a/sync/test/engine/syncer_command_test.h
+++ b/sync/test/engine/syncer_command_test.h
@@ -22,7 +22,7 @@
#include "sync/test/engine/fake_model_worker.h"
#include "sync/test/engine/mock_connection_manager.h"
#include "sync/test/engine/test_directory_setter_upper.h"
-#include "sync/util/extensions_activity.h"
+#include "sync/test/fake_extensions_activity_monitor.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -131,7 +131,7 @@ class SyncerCommandTestBase : public testing::Test,
void ResetContext() {
context_.reset(new sessions::SyncSessionContext(
mock_server_.get(), directory(),
- GetWorkers(), extensions_activity_.get(),
+ GetWorkers(), &extensions_activity_monitor_,
std::vector<SyncEngineEventListener*>(),
&mock_debug_info_getter_,
&traffic_recorder_,
@@ -210,7 +210,7 @@ class SyncerCommandTestBase : public testing::Test,
std::vector<scoped_refptr<ModelSafeWorker> > workers_;
ModelSafeRoutingInfo routing_info_;
NiceMock<MockDebugInfoGetter> mock_debug_info_getter_;
- scoped_refptr<ExtensionsActivity> extensions_activity_;
+ FakeExtensionsActivityMonitor extensions_activity_monitor_;
TrafficRecorder traffic_recorder_;
DISALLOW_COPY_AND_ASSIGN(SyncerCommandTestBase);
};
diff --git a/sync/test/fake_extensions_activity_monitor.cc b/sync/test/fake_extensions_activity_monitor.cc
new file mode 100644
index 0000000..9fb20a6
--- /dev/null
+++ b/sync/test/fake_extensions_activity_monitor.cc
@@ -0,0 +1,31 @@
+// 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/fake_extensions_activity_monitor.h"
+
+#include "base/logging.h"
+
+namespace syncer {
+
+FakeExtensionsActivityMonitor::FakeExtensionsActivityMonitor() {}
+
+FakeExtensionsActivityMonitor::~FakeExtensionsActivityMonitor() {
+ DCHECK(CalledOnValidThread());
+}
+
+void FakeExtensionsActivityMonitor::GetAndClearRecords(Records* buffer) {
+ DCHECK(CalledOnValidThread());
+ buffer->clear();
+ buffer->swap(records_);
+}
+
+void FakeExtensionsActivityMonitor::PutRecords(const Records& records) {
+ DCHECK(CalledOnValidThread());
+ for (Records::const_iterator i = records.begin(); i != records.end(); ++i) {
+ records_[i->first].extension_id = i->second.extension_id;
+ records_[i->first].bookmark_write_count += i->second.bookmark_write_count;
+ }
+}
+
+} // namespace syncer
diff --git a/sync/test/fake_extensions_activity_monitor.h b/sync/test/fake_extensions_activity_monitor.h
new file mode 100644
index 0000000..a0702e1
--- /dev/null
+++ b/sync/test/fake_extensions_activity_monitor.h
@@ -0,0 +1,33 @@
+// 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_FAKE_EXTENSIONS_ACTIVITY_MONITOR_H_
+#define SYNC_TEST_FAKE_EXTENSIONS_ACTIVITY_MONITOR_H_
+
+#include "base/compiler_specific.h"
+#include "base/threading/non_thread_safe.h"
+#include "sync/util/extensions_activity_monitor.h"
+
+namespace syncer {
+
+// Fake non-thread-safe implementation of ExtensionsActivityMonitor
+// suitable to be used in single-threaded sync tests.
+class FakeExtensionsActivityMonitor
+ : public ExtensionsActivityMonitor,
+ public base::NonThreadSafe {
+ public:
+ FakeExtensionsActivityMonitor();
+ virtual ~FakeExtensionsActivityMonitor();
+
+ // ExtensionsActivityMonitor implementation.
+ virtual void GetAndClearRecords(Records* buffer) OVERRIDE;
+ virtual void PutRecords(const Records& records) OVERRIDE;
+
+ private:
+ Records records_;
+};
+
+} // namespace syncer
+
+#endif // SYNC_TEST_FAKE_EXTENSIONS_ACTIVITY_MONITOR_H_