diff options
author | pavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-04 02:48:51 +0000 |
---|---|---|
committer | pavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-04 02:48:51 +0000 |
commit | 04a830a0906ac5d23f3fe715ad8c356e7a11652e (patch) | |
tree | 7dd99b6797477af64120d36749e51d1d3bfbba2a /sync/tools | |
parent | 18db33766a265168f8850ff99dcdde3c393174db (diff) | |
download | chromium_src-04a830a0906ac5d23f3fe715ad8c356e7a11652e.zip chromium_src-04a830a0906ac5d23f3fe715ad8c356e7a11652e.tar.gz chromium_src-04a830a0906ac5d23f3fe715ad8c356e7a11652e.tar.bz2 |
Control invalidations network channel from TiclInvalidationService
This change introduces boilerplate GCMNetworkChannel implementation and switches
sync/notifier classes to refer network channel through base class
SyncNetworkChannel.
TiclInvalidationService can initialize invalidator with either PushClient or
GCM channel. On one hand goal was to not expose network channel implementation to
TiclInvalidationService, on the other hand to avoid passing channel specific
parameters across sync/notifier classes during initialization.
The solution is to introduce NetworkChannelCreator callback that takes no
parameters and returns scoped_ptr to SyncNetworkChannel. There are helper
functions in SyncNetworkChannel to create implementations for Puch/GCM clients
and helper functions in NonBlockingInvalidator to createNetworkChannelCreator.
The alternative was to create NetworkChannel factory interface and write
implementations of it for each channel type. This would provide more expressive
names, but requires interface and two implementations for simple purpose.
Review URL: https://codereview.chromium.org/116533006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242991 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/tools')
-rw-r--r-- | sync/tools/sync_client.cc | 8 | ||||
-rw-r--r-- | sync/tools/sync_listen_notifications.cc | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc index c0a1ef1..b0c9b55 100644 --- a/sync/tools/sync_client.cc +++ b/sync/tools/sync_client.cc @@ -269,17 +269,21 @@ int SyncClientMain(int argc, char* argv[]) { new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()); const notifier::NotifierOptions& notifier_options = ParseNotifierOptions(command_line, context_getter); + syncer::NetworkChannelCreator network_channel_creator = + syncer::NonBlockingInvalidator::MakePushClientChannelCreator( + notifier_options); const char kClientInfo[] = "standalone_sync_client"; std::string invalidator_id = base::RandBytesAsString(8); NullInvalidationStateTracker null_invalidation_state_tracker; scoped_ptr<Invalidator> invalidator(new NonBlockingInvalidator( - notifier_options, + network_channel_creator, invalidator_id, null_invalidation_state_tracker.GetSavedInvalidations(), null_invalidation_state_tracker.GetBootstrapData(), WeakHandle<InvalidationStateTracker>( null_invalidation_state_tracker.AsWeakPtr()), - kClientInfo)); + kClientInfo, + notifier_options.request_context_getter)); // Set up database directory for the syncer. base::ScopedTempDir database_dir; diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc index 5d212f3..12d089b 100644 --- a/sync/tools/sync_listen_notifications.cc +++ b/sync/tools/sync_listen_notifications.cc @@ -177,17 +177,21 @@ int SyncListenNotificationsMain(int argc, char* argv[]) { ParseNotifierOptions( command_line, new MyTestURLRequestContextGetter(io_thread.message_loop_proxy())); + syncer::NetworkChannelCreator network_channel_creator = + syncer::NonBlockingInvalidator::MakePushClientChannelCreator( + notifier_options); const char kClientInfo[] = "sync_listen_notifications"; NullInvalidationStateTracker null_invalidation_state_tracker; scoped_ptr<Invalidator> invalidator( new NonBlockingInvalidator( - notifier_options, + network_channel_creator, base::RandBytesAsString(8), null_invalidation_state_tracker.GetSavedInvalidations(), null_invalidation_state_tracker.GetBootstrapData(), WeakHandle<InvalidationStateTracker>( null_invalidation_state_tracker.AsWeakPtr()), - kClientInfo)); + kClientInfo, + notifier_options.request_context_getter)); NotificationPrinter notification_printer; |