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

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

Issue 10875064: Rename SyncNotifier->Invalidator and SyncNotifierObserver->InvalidationHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to ToT for landing Created 8 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « 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/base64.h" 10 #include "base/base64.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "jingle/notifier/base/notification_method.h" 19 #include "jingle/notifier/base/notification_method.h"
20 #include "jingle/notifier/base/notifier_options.h" 20 #include "jingle/notifier/base/notifier_options.h"
21 #include "net/base/host_port_pair.h" 21 #include "net/base/host_port_pair.h"
22 #include "net/base/host_resolver.h" 22 #include "net/base/host_resolver.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 #include "net/base/transport_security_state.h" 24 #include "net/base/transport_security_state.h"
25 #include "net/url_request/url_request_test_util.h" 25 #include "net/url_request/url_request_test_util.h"
26 #include "sync/internal_api/public/base/model_type.h" 26 #include "sync/internal_api/public/base/model_type.h"
27 #include "sync/internal_api/public/base/model_type_state_map.h" 27 #include "sync/internal_api/public/base/model_type_state_map.h"
28 #include "sync/notifier/invalidation_state_tracker.h" 28 #include "sync/notifier/invalidation_state_tracker.h"
29 #include "sync/notifier/invalidation_handler.h"
29 #include "sync/notifier/invalidation_util.h" 30 #include "sync/notifier/invalidation_util.h"
30 #include "sync/notifier/sync_notifier.h" 31 #include "sync/notifier/invalidator_factory.h"
31 #include "sync/notifier/sync_notifier_factory.h" 32 #include "sync/notifier/invalidator.h"
32 #include "sync/notifier/sync_notifier_observer.h"
33 33
34 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
35 #include "base/mac/scoped_nsautorelease_pool.h" 35 #include "base/mac/scoped_nsautorelease_pool.h"
36 #endif 36 #endif
37 37
38 // This is a simple utility that initializes a sync notifier and 38 // This is a simple utility that initializes a sync notifier and
39 // listens to any received notifications. 39 // listens to any received notifications.
40 40
41 namespace syncer { 41 namespace syncer {
42 namespace { 42 namespace {
43 43
44 const char kEmailSwitch[] = "email"; 44 const char kEmailSwitch[] = "email";
45 const char kTokenSwitch[] = "token"; 45 const char kTokenSwitch[] = "token";
46 const char kHostPortSwitch[] = "host-port"; 46 const char kHostPortSwitch[] = "host-port";
47 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first"; 47 const char kTrySslTcpFirstSwitch[] = "try-ssltcp-first";
48 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection"; 48 const char kAllowInsecureConnectionSwitch[] = "allow-insecure-connection";
49 const char kNotificationMethodSwitch[] = "notification-method"; 49 const char kNotificationMethodSwitch[] = "notification-method";
50 50
51 // Class to print received notifications events. 51 // Class to print received notifications events.
52 class NotificationPrinter : public SyncNotifierObserver { 52 class NotificationPrinter : public InvalidationHandler {
53 public: 53 public:
54 NotificationPrinter() {} 54 NotificationPrinter() {}
55 virtual ~NotificationPrinter() {} 55 virtual ~NotificationPrinter() {}
56 56
57 virtual void OnNotificationsEnabled() OVERRIDE { 57 virtual void OnNotificationsEnabled() OVERRIDE {
58 LOG(INFO) << "Notifications enabled"; 58 LOG(INFO) << "Notifications enabled";
59 } 59 }
60 60
61 virtual void OnNotificationsDisabled( 61 virtual void OnNotificationsDisabled(
62 NotificationsDisabledReason reason) OVERRIDE { 62 NotificationsDisabledReason reason) OVERRIDE {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // Set up objects that monitor the network. 226 // Set up objects that monitor the network.
227 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( 227 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier(
228 net::NetworkChangeNotifier::Create()); 228 net::NetworkChangeNotifier::Create());
229 229
230 const notifier::NotifierOptions& notifier_options = 230 const notifier::NotifierOptions& notifier_options =
231 ParseNotifierOptions( 231 ParseNotifierOptions(
232 command_line, 232 command_line,
233 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy())); 233 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()));
234 const char kClientInfo[] = "sync_listen_notifications"; 234 const char kClientInfo[] = "sync_listen_notifications";
235 NullInvalidationStateTracker null_invalidation_state_tracker; 235 NullInvalidationStateTracker null_invalidation_state_tracker;
236 SyncNotifierFactory sync_notifier_factory( 236 InvalidatorFactory invalidator_factory(
237 notifier_options, kClientInfo, 237 notifier_options, kClientInfo,
238 null_invalidation_state_tracker.AsWeakPtr()); 238 null_invalidation_state_tracker.AsWeakPtr());
239 scoped_ptr<SyncNotifier> sync_notifier( 239 scoped_ptr<Invalidator> invalidator(
240 sync_notifier_factory.CreateSyncNotifier()); 240 invalidator_factory.CreateInvalidator());
241 NotificationPrinter notification_printer; 241 NotificationPrinter notification_printer;
242 242
243 const char kUniqueId[] = "fake_unique_id"; 243 const char kUniqueId[] = "fake_unique_id";
244 sync_notifier->SetUniqueId(kUniqueId); 244 invalidator->SetUniqueId(kUniqueId);
245 sync_notifier->UpdateCredentials(email, token); 245 invalidator->UpdateCredentials(email, token);
246 246
247 // Listen for notifications for all known types. 247 // Listen for notifications for all known types.
248 sync_notifier->RegisterHandler(&notification_printer); 248 invalidator->RegisterHandler(&notification_printer);
249 sync_notifier->UpdateRegisteredIds( 249 invalidator->UpdateRegisteredIds(
250 &notification_printer, ModelTypeSetToObjectIdSet(ModelTypeSet::All())); 250 &notification_printer, ModelTypeSetToObjectIdSet(ModelTypeSet::All()));
251 251
252 ui_loop.Run(); 252 ui_loop.Run();
253 253
254 sync_notifier->UnregisterHandler(&notification_printer); 254 invalidator->UnregisterHandler(&notification_printer);
255 io_thread.Stop(); 255 io_thread.Stop();
256 return 0; 256 return 0;
257 } 257 }
258 258
259 } // namespace 259 } // namespace
260 } // namespace syncer 260 } // namespace syncer
261 261
262 int main(int argc, char* argv[]) { 262 int main(int argc, char* argv[]) {
263 return syncer::SyncListenNotificationsMain(argc, argv); 263 return syncer::SyncListenNotificationsMain(argc, argv);
264 } 264 }
OLDNEW
« no previous file with comments | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698