summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/test
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-21 04:16:33 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-21 04:16:33 +0000
commit16b85e8a64fd14f425d9b12c8b6802d5e41c1853 (patch)
tree3c5ddbcef5b4c05824a6c197ae558c12ac027f75 /sync/internal_api/test
parent6bf30d0a453f8647c63d261a2f603a2c3939566b (diff)
downloadchromium_src-16b85e8a64fd14f425d9b12c8b6802d5e41c1853.zip
chromium_src-16b85e8a64fd14f425d9b12c8b6802d5e41c1853.tar.gz
chromium_src-16b85e8a64fd14f425d9b12c8b6802d5e41c1853.tar.bz2
Sync: Add DeviceInfo's ChangeProcessor
This is the long-awaited change to enable DeviceInfo tracking. Long ago (r161496) we committed code to support the DeviceInfo type, but we had to leave this code disabled until the server was ready to support the new type. That support has now been added. This change includes a very special kind of ChangeProcessor named SyncedDeviceTracker. It is the only ChangeProcessor that is owned by the sync thread. The SyncBackendHost creates and initializes it during backend intialization and deletes it before the UserShare it references is destroyed. As part of its initialization, the SyncedDeviceTracker will update the DeviceInfo entry for the current device. The SyncedDeviceTracker could support sending notifications to any interested listeners when new or update DeviceInfo information arrives, but this functionality has not been implemented yet. Also included are: - Tests for the SyncedDeviceTracker - A MockTransactionObserver to support these tests - A cache_guid() accessor on the SyncManager, used to initialize the SyncedDeviceTracker - Remove support for default constructing a DeviceInfo object BUG=122825 Review URL: https://chromiumcodereview.appspot.com/11360259 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168972 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/test')
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc27
-rw-r--r--sync/internal_api/test/test_user_share.cc4
2 files changed, 29 insertions, 2 deletions
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index 66b3ac6..0556cc9 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -20,6 +20,7 @@
#include "sync/notifier/invalidator.h"
#include "sync/notifier/invalidator_state.h"
#include "sync/notifier/object_id_invalidation_map.h"
+#include "sync/syncable/directory.h"
#include "sync/test/fake_sync_encryption_handler.h"
namespace syncer {
@@ -91,7 +92,6 @@ void FakeSyncManager::Init(
const std::string& sync_server_and_path,
int sync_server_port,
bool use_ssl,
- const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
@@ -107,6 +107,14 @@ void FakeSyncManager::Init(
report_unrecoverable_error_function) {
sync_task_runner_ = base::ThreadTaskRunnerHandle::Get();
PurgePartiallySyncedTypes();
+
+ test_user_share_.SetUp();
+ UserShare* share = test_user_share_.user_share();
+ for (ModelTypeSet::Iterator it = initial_sync_ended_types_.First();
+ it.Good(); it.Inc()) {
+ TestUserShare::CreateRoot(it.Get(), share);
+ }
+
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnInitializationComplete(
WeakHandle<JsBackend>(),
@@ -186,6 +194,16 @@ void FakeSyncManager::ConfigureSyncer(
<< ModelTypeSetToString(success_types) << ". Cleaning: "
<< ModelTypeSetToString(disabled_types);
+ // Update our fake directory by clearing and fake-downloading as necessary.
+ UserShare* share = GetUserShare();
+ share->directory->PurgeEntriesWithTypeIn(disabled_types);
+ for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) {
+ // We must be careful to not create the same root node twice.
+ if (!initial_sync_ended_types_.Has(it.Get())) {
+ TestUserShare::CreateRoot(it.Get(), share);
+ }
+ }
+
// Simulate cleaning up disabled types.
// TODO(sync): consider only cleaning those types that were recently disabled,
// if this isn't the first cleanup, which more accurately reflects the
@@ -228,10 +246,15 @@ void FakeSyncManager::StopSyncingForShutdown(const base::Closure& callback) {
void FakeSyncManager::ShutdownOnSyncThread() {
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
+ test_user_share_.TearDown();
}
UserShare* FakeSyncManager::GetUserShare() {
- return NULL;
+ return test_user_share_.user_share();
+}
+
+const std::string FakeSyncManager::cache_guid() {
+ return test_user_share_.user_share()->directory->cache_guid();
}
bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) {
diff --git a/sync/internal_api/test/test_user_share.cc b/sync/internal_api/test/test_user_share.cc
index 1533d63..5c7856e 100644
--- a/sync/internal_api/test/test_user_share.cc
+++ b/sync/internal_api/test/test_user_share.cc
@@ -46,6 +46,10 @@ SyncEncryptionHandler* TestUserShare::encryption_handler() {
return dir_maker_->encryption_handler();
}
+syncable::TestTransactionObserver* TestUserShare::transaction_observer() {
+ return dir_maker_->transaction_observer();
+}
+
/* static */
bool TestUserShare::CreateRoot(ModelType model_type, UserShare* user_share) {
syncer::syncable::Directory* directory = user_share->directory.get();