Chromium Code Reviews| Index: sync/tools/sync_client.cc |
| diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc |
| index 7623db1e87e93599a0007fca11dd341ce551e81a..d21e543d3fa0cdc0204ece5ebf621e91dcb24222 100644 |
| --- a/sync/tools/sync_client.cc |
| +++ b/sync/tools/sync_client.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/message_loop.h" |
| +#include "base/rand_util.h" |
| #include "base/task_runner.h" |
| #include "base/threading/thread.h" |
| #include "jingle/notifier/base/notification_method.h" |
| @@ -40,8 +41,7 @@ |
| #include "sync/js/js_event_details.h" |
| #include "sync/js/js_event_handler.h" |
| #include "sync/notifier/invalidation_state_tracker.h" |
| -#include "sync/notifier/invalidator.h" |
| -#include "sync/notifier/invalidator_factory.h" |
| +#include "sync/notifier/non_blocking_invalidator.h" |
| #include "sync/test/fake_encryptor.h" |
| #include "sync/tools/null_invalidation_state_tracker.h" |
| @@ -215,15 +215,14 @@ notifier::NotifierOptions ParseNotifierOptions( |
| LOG_IF(INFO, notifier_options.allow_insecure_connection) |
| << "Allowing insecure XMPP connections."; |
| - if (command_line.HasSwitch(kNotificationMethodSwitch)) { |
| - notifier_options.notification_method = |
| - notifier::StringToNotificationMethod( |
| - command_line.GetSwitchValueASCII(kNotificationMethodSwitch)); |
| - } |
| - |
| return notifier_options; |
| } |
| +void StubNetworkTimeUpdateCallback(const base::Time&, |
| + const base::TimeDelta&, |
| + const base::TimeDelta&) { |
| +} |
| + |
| int SyncClientMain(int argc, char* argv[]) { |
| #if defined(OS_MACOSX) |
| base::mac::ScopedNSAutoreleasePool pool; |
| @@ -253,7 +252,6 @@ int SyncClientMain(int argc, char* argv[]) { |
| if (credentials.email.empty() || credentials.sync_token.empty()) { |
| std::printf("Usage: %s --%s=foo@bar.com --%s=token\n" |
| "[--%s=host:port] [--%s] [--%s]\n" |
| - "[--%s=(server|p2p)]\n\n" |
| "Run chrome and set a breakpoint on\n" |
| "syncer::SyncManagerImpl::UpdateCredentials() " |
| "after logging into\n" |
| @@ -261,8 +259,7 @@ int SyncClientMain(int argc, char* argv[]) { |
| argv[0], |
| kEmailSwitch, kTokenSwitch, kXmppHostPortSwitch, |
| kXmppTrySslTcpFirstSwitch, |
| - kXmppAllowInsecureConnectionSwitch, |
| - kNotificationMethodSwitch); |
| + kXmppAllowInsecureConnectionSwitch); |
| return -1; |
| } |
| @@ -275,18 +272,49 @@ int SyncClientMain(int argc, char* argv[]) { |
| new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()); |
| const notifier::NotifierOptions& notifier_options = |
| ParseNotifierOptions(command_line, context_getter); |
| - const char kClientInfo[] = "sync_listen_notifications"; |
| + const char kClientInfo[] = "standalone_sync_client"; |
| + std::string invalidator_id = base::RandBytesAsString(8); |
| NullInvalidationStateTracker null_invalidation_state_tracker; |
| - InvalidatorFactory invalidator_factory( |
| - notifier_options, kClientInfo, |
| - null_invalidation_state_tracker.AsWeakPtr()); |
| + Invalidator* invalidator = new NonBlockingInvalidator( |
|
akalin
2013/05/24 22:58:46
what owns the invalidator?
rlarocque
2013/05/29 00:37:55
In this patch, no one owns it. I'll change this t
akalin
2013/06/04 19:23:54
Yeah, there's no graceful shutdown. But it's good
|
| + notifier_options, |
| + invalidator_id, |
| + null_invalidation_state_tracker.GetAllInvalidationStates(), |
| + null_invalidation_state_tracker.GetBootstrapData(), |
| + WeakHandle<InvalidationStateTracker>( |
| + null_invalidation_state_tracker.AsWeakPtr()), |
| + kClientInfo); |
| // Set up database directory for the syncer. |
| base::ScopedTempDir database_dir; |
| CHECK(database_dir.CreateUniqueTempDir()); |
| - // Set up model type parameters. |
| - const ModelTypeSet model_types = ModelTypeSet::All(); |
| + // Developers often add types to ModelTypeSet::All() before the server |
| + // supports them. We need to be explicit about which types we want here. |
| + ModelTypeSet model_types; |
| + model_types.Put(BOOKMARKS); |
| + model_types.Put(PREFERENCES); |
| + model_types.Put(PASSWORDS); |
| + model_types.Put(AUTOFILL); |
| + model_types.Put(THEMES); |
| + model_types.Put(TYPED_URLS); |
| + model_types.Put(EXTENSIONS); |
| + model_types.Put(NIGORI); |
| + model_types.Put(SEARCH_ENGINES); |
| + model_types.Put(SESSIONS); |
| + model_types.Put(APPS); |
| + model_types.Put(AUTOFILL_PROFILE); |
| + model_types.Put(APP_SETTINGS); |
| + model_types.Put(EXTENSION_SETTINGS); |
| + model_types.Put(APP_NOTIFICATIONS); |
| + model_types.Put(HISTORY_DELETE_DIRECTIVES); |
| + model_types.Put(SYNCED_NOTIFICATIONS); |
| + model_types.Put(DEVICE_INFO); |
| + model_types.Put(EXPERIMENTS); |
| + model_types.Put(PRIORITY_PREFERENCES); |
| + model_types.Put(DICTIONARY); |
| + model_types.Put(FAVICON_IMAGES); |
| + model_types.Put(FAVICON_TRACKING); |
| + |
| ModelSafeRoutingInfo routing_info; |
| for (ModelTypeSet::Iterator it = model_types.First(); |
| it.Good(); it.Inc()) { |
| @@ -313,7 +341,7 @@ int SyncClientMain(int argc, char* argv[]) { |
| scoped_ptr<HttpPostProviderFactory> post_factory( |
| new HttpBridgeFactory(context_getter, |
| kUserAgent, |
| - NetworkTimeUpdateCallback())); |
| + base::Bind(&StubNetworkTimeUpdateCallback))); |
| // Used only when committing bookmarks, so it's okay to leave this |
| // as NULL. |
| ExtensionsActivityMonitor* extensions_activity_monitor = NULL; |
| @@ -338,9 +366,7 @@ int SyncClientMain(int argc, char* argv[]) { |
| extensions_activity_monitor, |
| &change_delegate, |
| credentials, |
| - scoped_ptr<Invalidator>( |
| - invalidator_factory.CreateInvalidator()), |
| - invalidator_factory.GetInvalidatorClientId(), |
| + invalidator_id, |
| kRestoredKeyForBootstrapping, |
| kRestoredKeystoreKeyForBootstrapping, |
| scoped_ptr<InternalComponentsFactory>( |
| @@ -350,7 +376,10 @@ int SyncClientMain(int argc, char* argv[]) { |
| &LogUnrecoverableErrorContext); |
| // TODO(akalin): Avoid passing in model parameters multiple times by |
| // organizing handling of model types. |
| - sync_manager->UpdateEnabledTypes(model_types); |
| + invalidator->UpdateCredentials(credentials.email, credentials.sync_token); |
| + invalidator->RegisterHandler(sync_manager.get()); |
| + invalidator->UpdateRegisteredIds( |
| + sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); |
| sync_manager->StartSyncingNormally(routing_info); |
| sync_loop.Run(); |