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

Side by Side Diff: sync/tools/sync_listen_notifications.cc

Issue 116533006: Control invalidations network channel from TiclInvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years 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 unified diff | Download patch
« sync/sync_tests.gypi ('K') | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstddef> 5 #include <cstddef>
6 #include <cstdio> 6 #include <cstdio>
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 // Set up objects that monitor the network. 172 // Set up objects that monitor the network.
173 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( 173 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier(
174 net::NetworkChangeNotifier::Create()); 174 net::NetworkChangeNotifier::Create());
175 175
176 const notifier::NotifierOptions& notifier_options = 176 const notifier::NotifierOptions& notifier_options =
177 ParseNotifierOptions( 177 ParseNotifierOptions(
178 command_line, 178 command_line,
179 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy())); 179 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()));
180 syncer::NetworkChannelCreator network_channel_creator =
181 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(
182 notifier_options);
180 const char kClientInfo[] = "sync_listen_notifications"; 183 const char kClientInfo[] = "sync_listen_notifications";
181 NullInvalidationStateTracker null_invalidation_state_tracker; 184 NullInvalidationStateTracker null_invalidation_state_tracker;
182 scoped_ptr<Invalidator> invalidator( 185 scoped_ptr<Invalidator> invalidator(
183 new NonBlockingInvalidator( 186 new NonBlockingInvalidator(
184 notifier_options, 187 network_channel_creator,
185 base::RandBytesAsString(8), 188 base::RandBytesAsString(8),
186 null_invalidation_state_tracker.GetSavedInvalidations(), 189 null_invalidation_state_tracker.GetSavedInvalidations(),
187 null_invalidation_state_tracker.GetBootstrapData(), 190 null_invalidation_state_tracker.GetBootstrapData(),
188 WeakHandle<InvalidationStateTracker>( 191 WeakHandle<InvalidationStateTracker>(
189 null_invalidation_state_tracker.AsWeakPtr()), 192 null_invalidation_state_tracker.AsWeakPtr()),
190 kClientInfo)); 193 kClientInfo,
194 notifier_options.request_context_getter));
191 195
192 NotificationPrinter notification_printer; 196 NotificationPrinter notification_printer;
193 197
194 invalidator->UpdateCredentials(email, token); 198 invalidator->UpdateCredentials(email, token);
195 199
196 // Listen for notifications for all known types. 200 // Listen for notifications for all known types.
197 invalidator->RegisterHandler(&notification_printer); 201 invalidator->RegisterHandler(&notification_printer);
198 invalidator->UpdateRegisteredIds( 202 invalidator->UpdateRegisteredIds(
199 &notification_printer, ModelTypeSetToObjectIdSet(ModelTypeSet::All())); 203 &notification_printer, ModelTypeSetToObjectIdSet(ModelTypeSet::All()));
200 204
201 ui_loop.Run(); 205 ui_loop.Run();
202 206
203 invalidator->UnregisterHandler(&notification_printer); 207 invalidator->UnregisterHandler(&notification_printer);
204 io_thread.Stop(); 208 io_thread.Stop();
205 return 0; 209 return 0;
206 } 210 }
207 211
208 } // namespace 212 } // namespace
209 } // namespace syncer 213 } // namespace syncer
210 214
211 int main(int argc, char* argv[]) { 215 int main(int argc, char* argv[]) {
212 return syncer::SyncListenNotificationsMain(argc, argv); 216 return syncer::SyncListenNotificationsMain(argc, argv);
213 } 217 }
OLDNEW
« sync/sync_tests.gypi ('K') | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698