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

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

Issue 10407014: Rename InvalidationVersionTracker to InvalidationStateTracker in preparation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/sync.gyp ('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 <cstdio> 5 #include <cstdio>
6 #include <string> 6 #include <string>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "jingle/notifier/base/notification_method.h" 18 #include "jingle/notifier/base/notification_method.h"
19 #include "jingle/notifier/base/notifier_options.h" 19 #include "jingle/notifier/base/notifier_options.h"
20 #include "net/base/host_port_pair.h" 20 #include "net/base/host_port_pair.h"
21 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
22 #include "sync/notifier/invalidation_version_tracker.h" 22 #include "sync/notifier/invalidation_state_tracker.h"
23 #include "sync/notifier/sync_notifier.h" 23 #include "sync/notifier/sync_notifier.h"
24 #include "sync/notifier/sync_notifier_factory.h" 24 #include "sync/notifier/sync_notifier_factory.h"
25 #include "sync/notifier/sync_notifier_observer.h" 25 #include "sync/notifier/sync_notifier_observer.h"
26 #include "sync/syncable/model_type.h" 26 #include "sync/syncable/model_type.h"
27 #include "sync/syncable/model_type_payload_map.h" 27 #include "sync/syncable/model_type_payload_map.h"
28 28
29 // This is a simple utility that initializes a sync notifier and 29 // This is a simple utility that initializes a sync notifier and
30 // listens to any received notifications. 30 // listens to any received notifications.
31 31
32 namespace { 32 namespace {
(...skipping 25 matching lines...) Expand all
58 virtual void StoreState(const std::string& state) OVERRIDE { 58 virtual void StoreState(const std::string& state) OVERRIDE {
59 std::string base64_state; 59 std::string base64_state;
60 CHECK(base::Base64Encode(state, &base64_state)); 60 CHECK(base::Base64Encode(state, &base64_state));
61 LOG(INFO) << "Got state to store: " << base64_state; 61 LOG(INFO) << "Got state to store: " << base64_state;
62 } 62 }
63 63
64 private: 64 private:
65 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter); 65 DISALLOW_COPY_AND_ASSIGN(NotificationPrinter);
66 }; 66 };
67 67
68 class NullInvalidationVersionTracker 68 class NullInvalidationStateTracker
69 : public base::SupportsWeakPtr<NullInvalidationVersionTracker>, 69 : public base::SupportsWeakPtr<NullInvalidationStateTracker>,
70 public sync_notifier::InvalidationVersionTracker { 70 public sync_notifier::InvalidationStateTracker {
71 public: 71 public:
72 NullInvalidationVersionTracker() {} 72 NullInvalidationStateTracker() {}
73 virtual ~NullInvalidationVersionTracker() {} 73 virtual ~NullInvalidationStateTracker() {}
74 74
75 virtual sync_notifier::InvalidationVersionMap 75 virtual sync_notifier::InvalidationVersionMap
76 GetAllMaxVersions() const OVERRIDE { 76 GetAllMaxVersions() const OVERRIDE {
77 return sync_notifier::InvalidationVersionMap(); 77 return sync_notifier::InvalidationVersionMap();
78 } 78 }
79 79
80 virtual void SetMaxVersion( 80 virtual void SetMaxVersion(
81 syncable::ModelType model_type, 81 syncable::ModelType model_type,
82 int64 max_invalidation_version) OVERRIDE { 82 int64 max_invalidation_version) OVERRIDE {
83 LOG(INFO) << "Setting max invalidation version for " 83 LOG(INFO) << "Setting max invalidation version for "
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch, 164 kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch,
165 kNotificationMethodSwitch); 165 kNotificationMethodSwitch);
166 return -1; 166 return -1;
167 } 167 }
168 168
169 const notifier::NotifierOptions& notifier_options = 169 const notifier::NotifierOptions& notifier_options =
170 ParseNotifierOptions( 170 ParseNotifierOptions(
171 command_line, 171 command_line,
172 new TestURLRequestContextGetter(io_thread.message_loop_proxy())); 172 new TestURLRequestContextGetter(io_thread.message_loop_proxy()));
173 const char kClientInfo[] = "sync_listen_notifications"; 173 const char kClientInfo[] = "sync_listen_notifications";
174 NullInvalidationVersionTracker null_invalidation_version_tracker; 174 NullInvalidationStateTracker null_invalidation_state_tracker;
175 sync_notifier::SyncNotifierFactory sync_notifier_factory( 175 sync_notifier::SyncNotifierFactory sync_notifier_factory(
176 notifier_options, kClientInfo, 176 notifier_options, kClientInfo,
177 null_invalidation_version_tracker.AsWeakPtr()); 177 null_invalidation_state_tracker.AsWeakPtr());
178 scoped_ptr<sync_notifier::SyncNotifier> sync_notifier( 178 scoped_ptr<sync_notifier::SyncNotifier> sync_notifier(
179 sync_notifier_factory.CreateSyncNotifier()); 179 sync_notifier_factory.CreateSyncNotifier());
180 NotificationPrinter notification_printer; 180 NotificationPrinter notification_printer;
181 sync_notifier->AddObserver(&notification_printer); 181 sync_notifier->AddObserver(&notification_printer);
182 182
183 const char kUniqueId[] = "fake_unique_id"; 183 const char kUniqueId[] = "fake_unique_id";
184 sync_notifier->SetUniqueId(kUniqueId); 184 sync_notifier->SetUniqueId(kUniqueId);
185 sync_notifier->SetState(""); 185 sync_notifier->SetState("");
186 sync_notifier->UpdateCredentials(email, token); 186 sync_notifier->UpdateCredentials(email, token);
187 // Listen for notifications for all known types. 187 // Listen for notifications for all known types.
188 sync_notifier->UpdateEnabledTypes(syncable::ModelTypeSet::All()); 188 sync_notifier->UpdateEnabledTypes(syncable::ModelTypeSet::All());
189 189
190 ui_loop.Run(); 190 ui_loop.Run();
191 191
192 sync_notifier->RemoveObserver(&notification_printer); 192 sync_notifier->RemoveObserver(&notification_printer);
193 io_thread.Stop(); 193 io_thread.Stop();
194 return 0; 194 return 0;
195 } 195 }
OLDNEW
« no previous file with comments | « sync/sync.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698