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

Unified Diff: sync/internal_api/test/fake_sync_manager.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around brittle unit test Created 8 years, 4 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
« no previous file with comments | « sync/internal_api/sync_manager_impl_unittest.cc ('k') | sync/notifier/invalidation_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/test/fake_sync_manager.cc
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index 696746d33f6b637e31b5b4fb7be781d28ca833c3..e6b415a551c9919a38d57a5480f24f5e36877829 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/run_loop.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
@@ -21,22 +22,15 @@
namespace syncer {
-FakeSyncManager::FakeSyncManager() {}
+FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types,
+ ModelTypeSet progress_marker_types,
+ ModelTypeSet configure_fail_types) :
+ initial_sync_ended_types_(initial_sync_ended_types),
+ progress_marker_types_(progress_marker_types),
+ configure_fail_types_(configure_fail_types) {}
FakeSyncManager::~FakeSyncManager() {}
-void FakeSyncManager::set_initial_sync_ended_types(ModelTypeSet types) {
- initial_sync_ended_types_ = types;
-}
-
-void FakeSyncManager::set_progress_marker_types(ModelTypeSet types) {
- progress_marker_types_ = types;
-}
-
-void FakeSyncManager::set_configure_fail_types(ModelTypeSet types) {
- configure_fail_types_ = types;
-}
-
ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() {
ModelTypeSet cleaned_types = cleaned_types_;
cleaned_types_.Clear();
@@ -84,6 +78,24 @@ void FakeSyncManager::DisableNotifications(
}
}
+namespace {
+
+void DoNothing() {}
+
+} // namespace
+
+void FakeSyncManager::WaitForSyncThread() {
+ // Post a task to |sync_task_runner_| and block until it runs.
+ base::RunLoop run_loop;
+ if (!sync_task_runner_->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&DoNothing),
+ run_loop.QuitClosure())) {
+ NOTREACHED();
+ }
+ run_loop.Run();
+}
+
void FakeSyncManager::Init(
const FilePath& database_location,
const WeakHandle<JsEventHandler>& event_handler,
@@ -148,10 +160,20 @@ void FakeSyncManager::UpdateEnabledTypes(const ModelTypeSet& types) {
enabled_types_ = types;
}
+void FakeSyncManager::RegisterInvalidationHandler(
+ SyncNotifierObserver* handler) {
+ registrar_.RegisterHandler(handler);
+}
+
void FakeSyncManager::UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler,
const ObjectIdSet& ids) {
- notifier_helper_.UpdateRegisteredIds(handler, ids);
+ registrar_.UpdateRegisteredIds(handler, ids);
+}
+
+void FakeSyncManager::UnregisterInvalidationHandler(
+ SyncNotifierObserver* handler) {
+ registrar_.UnregisterHandler(handler);
}
void FakeSyncManager::StartSyncingNormally(
@@ -264,18 +286,18 @@ void FakeSyncManager::InvalidateOnSyncThread(
const ObjectIdPayloadMap& id_payloads,
IncomingNotificationSource source) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- notifier_helper_.DispatchInvalidationsToHandlers(id_payloads, source);
+ registrar_.DispatchInvalidationsToHandlers(id_payloads, source);
}
void FakeSyncManager::EnableNotificationsOnSyncThread() {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- notifier_helper_.EmitOnNotificationsEnabled();
+ registrar_.EmitOnNotificationsEnabled();
}
void FakeSyncManager::DisableNotificationsOnSyncThread(
NotificationsDisabledReason reason) {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
- notifier_helper_.EmitOnNotificationsDisabled(reason);
+ registrar_.EmitOnNotificationsDisabled(reason);
}
} // namespace syncer
« no previous file with comments | « sync/internal_api/sync_manager_impl_unittest.cc ('k') | sync/notifier/invalidation_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698