diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-25 01:47:46 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-25 01:47:46 +0000 |
commit | 1691f004283eca700aa101b784bdec5a8c3b24cb (patch) | |
tree | 51686e63df183d4ea60fb38be4400db97fedbf18 /sync/tools | |
parent | 9f9309fbb4f1ff34330a9ba3879011cad09f05e5 (diff) | |
download | chromium_src-1691f004283eca700aa101b784bdec5a8c3b24cb.zip chromium_src-1691f004283eca700aa101b784bdec5a8c3b24cb.tar.gz chromium_src-1691f004283eca700aa101b784bdec5a8c3b24cb.tar.bz2 |
Revert 208315 "Make use of InvalidationService"
> Make use of InvalidationService
>
> The InvalidationService was introduced r199520. That commit added the
> InvalidationService interface and several implementations of it, but
> made no use of the new code. This commit builds on that work.
>
> Up until now, TICL invalidations were handled on the sync thread. The
> related objects were instantiated and owned by the SyncBackendHost and
> SyncManager. All requests to update the set of object registrations had
> to be passed to the sync thread. Components that wanted to receive
> invalidations but were not part of sync had to route their communication
> with the invalidations server through ProfileSyncService to get to the
> sync thread. Things were a bit different on Android, but the system
> still tried to pretend that invalidations were owned by the sync thread.
>
> The new InvalidationService implementation is a ProfileKeyedService that
> is mostly independent from sync. It still relies on sync to manage sign
> in and fetch the appropriate auth tokens. However, it's now much easier
> for components outside of sync to communication with the invalidations
> server.
>
> The new system allows us to remove a lot of invalidations-related code
> from the ProfileSyncService, SyncBackendHost and SyncManager. Sync is
> now just one of many clients of the InvalidationService. The
> SyncBackendHost is responsible for forwarding messages back and forth
> between the InvalidationService and the sync thread.
>
> TBR=sky,erg
> BUG=124137
>
> Review URL: https://chromiumcodereview.appspot.com/15580002
TBR=rlarocque@chromium.org
Review URL: https://codereview.chromium.org/17610004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/tools')
-rw-r--r-- | sync/tools/sync_client.cc | 77 | ||||
-rw-r--r-- | sync/tools/sync_listen_notifications.cc | 26 | ||||
-rw-r--r-- | sync/tools/testserver/xmppserver.py | 8 |
3 files changed, 37 insertions, 74 deletions
diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc index 21a46fd..6ce8bde 100644 --- a/sync/tools/sync_client.cc +++ b/sync/tools/sync_client.cc @@ -17,7 +17,6 @@ #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" @@ -41,7 +40,8 @@ #include "sync/js/js_event_details.h" #include "sync/js/js_event_handler.h" #include "sync/notifier/invalidation_state_tracker.h" -#include "sync/notifier/non_blocking_invalidator.h" +#include "sync/notifier/invalidator.h" +#include "sync/notifier/invalidator_factory.h" #include "sync/test/fake_encryptor.h" #include "sync/tools/null_invalidation_state_tracker.h" @@ -215,12 +215,13 @@ notifier::NotifierOptions ParseNotifierOptions( LOG_IF(INFO, notifier_options.allow_insecure_connection) << "Allowing insecure XMPP connections."; - return notifier_options; -} + if (command_line.HasSwitch(kNotificationMethodSwitch)) { + notifier_options.notification_method = + notifier::StringToNotificationMethod( + command_line.GetSwitchValueASCII(kNotificationMethodSwitch)); + } -void StubNetworkTimeUpdateCallback(const base::Time&, - const base::TimeDelta&, - const base::TimeDelta&) { + return notifier_options; } int SyncClientMain(int argc, char* argv[]) { @@ -249,6 +250,7 @@ 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" @@ -256,7 +258,8 @@ int SyncClientMain(int argc, char* argv[]) { argv[0], kEmailSwitch, kTokenSwitch, kXmppHostPortSwitch, kXmppTrySslTcpFirstSwitch, - kXmppAllowInsecureConnectionSwitch); + kXmppAllowInsecureConnectionSwitch, + kNotificationMethodSwitch); return -1; } @@ -269,49 +272,18 @@ 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[] = "standalone_sync_client"; - std::string invalidator_id = base::RandBytesAsString(8); + const char kClientInfo[] = "sync_listen_notifications"; NullInvalidationStateTracker null_invalidation_state_tracker; - scoped_ptr<Invalidator> invalidator(new NonBlockingInvalidator( - notifier_options, - invalidator_id, - null_invalidation_state_tracker.GetAllInvalidationStates(), - null_invalidation_state_tracker.GetBootstrapData(), - WeakHandle<InvalidationStateTracker>( - null_invalidation_state_tracker.AsWeakPtr()), - kClientInfo)); + InvalidatorFactory invalidator_factory( + notifier_options, kClientInfo, + null_invalidation_state_tracker.AsWeakPtr()); // Set up database directory for the syncer. base::ScopedTempDir database_dir; CHECK(database_dir.CreateUniqueTempDir()); - // 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); - + // Set up model type parameters. + const ModelTypeSet model_types = ModelTypeSet::All(); ModelSafeRoutingInfo routing_info; for (ModelTypeSet::Iterator it = model_types.First(); it.Good(); it.Inc()) { @@ -335,10 +307,8 @@ int SyncClientMain(int argc, char* argv[]) { const char kUserAgent[] = "sync_client"; // TODO(akalin): Replace this with just the context getter once // HttpPostProviderFactory is removed. - scoped_ptr<HttpPostProviderFactory> post_factory( - new HttpBridgeFactory(context_getter, - kUserAgent, - base::Bind(&StubNetworkTimeUpdateCallback))); + scoped_ptr<HttpPostProviderFactory> post_factory(new HttpBridgeFactory( + context_getter.get(), kUserAgent, NetworkTimeUpdateCallback())); // Used only when committing bookmarks, so it's okay to leave this // as NULL. ExtensionsActivityMonitor* extensions_activity_monitor = NULL; @@ -363,7 +333,9 @@ int SyncClientMain(int argc, char* argv[]) { extensions_activity_monitor, &change_delegate, credentials, - invalidator_id, + scoped_ptr<Invalidator>( + invalidator_factory.CreateInvalidator()), + invalidator_factory.GetInvalidatorClientId(), kRestoredKeyForBootstrapping, kRestoredKeystoreKeyForBootstrapping, scoped_ptr<InternalComponentsFactory>( @@ -373,10 +345,7 @@ int SyncClientMain(int argc, char* argv[]) { &LogUnrecoverableErrorContext, false); // TODO(akalin): Avoid passing in model parameters multiple times by // organizing handling of model types. - invalidator->UpdateCredentials(credentials.email, credentials.sync_token); - invalidator->RegisterHandler(sync_manager.get()); - invalidator->UpdateRegisteredIds( - sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); + sync_manager->UpdateEnabledTypes(model_types); sync_manager->StartSyncingNormally(routing_info); sync_loop.Run(); diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc index 615d6bd..dc54886 100644 --- a/sync/tools/sync_listen_notifications.cc +++ b/sync/tools/sync_listen_notifications.cc @@ -13,7 +13,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "base/rand_util.h" #include "base/threading/thread.h" #include "jingle/notifier/base/notification_method.h" #include "jingle/notifier/base/notifier_options.h" @@ -28,7 +27,7 @@ #include "sync/notifier/invalidation_state_tracker.h" #include "sync/notifier/invalidation_util.h" #include "sync/notifier/invalidator.h" -#include "sync/notifier/non_blocking_invalidator.h" +#include "sync/notifier/invalidator_factory.h" #include "sync/tools/null_invalidation_state_tracker.h" #if defined(OS_MACOSX) @@ -135,6 +134,12 @@ 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; } @@ -164,13 +169,15 @@ int SyncListenNotificationsMain(int argc, char* argv[]) { if (email.empty() || 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" "sync to get the token to pass into this utility.\n", argv[0], kEmailSwitch, kTokenSwitch, kHostPortSwitch, - kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch); + kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch, + kNotificationMethodSwitch); return -1; } @@ -184,16 +191,11 @@ int SyncListenNotificationsMain(int argc, char* argv[]) { new MyTestURLRequestContextGetter(io_thread.message_loop_proxy())); const char kClientInfo[] = "sync_listen_notifications"; NullInvalidationStateTracker null_invalidation_state_tracker; + InvalidatorFactory invalidator_factory( + notifier_options, kClientInfo, + null_invalidation_state_tracker.AsWeakPtr()); scoped_ptr<Invalidator> invalidator( - new NonBlockingInvalidator( - notifier_options, - base::RandBytesAsString(8), - null_invalidation_state_tracker.GetAllInvalidationStates(), - null_invalidation_state_tracker.GetBootstrapData(), - WeakHandle<InvalidationStateTracker>( - null_invalidation_state_tracker.AsWeakPtr()), - kClientInfo)); - + invalidator_factory.CreateInvalidator()); NotificationPrinter notification_printer; invalidator->UpdateCredentials(email, token); diff --git a/sync/tools/testserver/xmppserver.py b/sync/tools/testserver/xmppserver.py index 3f7c7d05..0b32933 100644 --- a/sync/tools/testserver/xmppserver.py +++ b/sync/tools/testserver/xmppserver.py @@ -575,14 +575,6 @@ class XmppServer(asyncore.dispatcher): def SetAuthenticated(self, auth_valid): self._authenticated = auth_valid - # We check authentication only when establishing new connections. We close - # all existing connections here to make sure previously connected clients - # pick up on the change. It's a hack, but it works well enough for our - # purposes. - if not self._authenticated: - for connection in self._handshake_done_connections: - connection.close() - def GetAuthenticated(self): return self._authenticated |