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

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

Issue 11415049: Implement features needed for local ack handling in InvalidationStateTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
« sync/tools/sync_client.cc ('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/base64.h" 10 #include "base/base64.h"
11 #include "base/bind.h"
12 #include "base/callback.h"
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/location.h"
13 #include "base/logging.h" 16 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop.h" 20 #include "base/message_loop.h"
18 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
19 #include "jingle/notifier/base/notification_method.h" 22 #include "jingle/notifier/base/notification_method.h"
20 #include "jingle/notifier/base/notifier_options.h" 23 #include "jingle/notifier/base/notifier_options.h"
21 #include "net/base/host_port_pair.h" 24 #include "net/base/host_port_pair.h"
22 #include "net/base/host_resolver.h" 25 #include "net/base/host_resolver.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 : public base::SupportsWeakPtr<NullInvalidationStateTracker>, 85 : public base::SupportsWeakPtr<NullInvalidationStateTracker>,
83 public InvalidationStateTracker { 86 public InvalidationStateTracker {
84 public: 87 public:
85 NullInvalidationStateTracker() {} 88 NullInvalidationStateTracker() {}
86 virtual ~NullInvalidationStateTracker() {} 89 virtual ~NullInvalidationStateTracker() {}
87 90
88 virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE { 91 virtual InvalidationStateMap GetAllInvalidationStates() const OVERRIDE {
89 return InvalidationStateMap(); 92 return InvalidationStateMap();
90 } 93 }
91 94
92 virtual void SetMaxVersion( 95 virtual void SetMaxVersionAndPayload(
93 const invalidation::ObjectId& id, 96 const invalidation::ObjectId& id,
94 int64 max_invalidation_version) OVERRIDE { 97 int64 max_invalidation_version,
98 const std::string& payload) OVERRIDE {
95 LOG(INFO) << "Setting max invalidation version for " 99 LOG(INFO) << "Setting max invalidation version for "
96 << ObjectIdToString(id) << " to " << max_invalidation_version; 100 << ObjectIdToString(id) << " to " << max_invalidation_version
101 << " with payload " << payload;
97 } 102 }
98 103
99 virtual void Forget(const ObjectIdSet& ids) OVERRIDE { 104 virtual void Forget(const ObjectIdSet& ids) OVERRIDE {
100 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { 105 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
101 LOG(INFO) << "Forgetting saved state for " << ObjectIdToString(*it); 106 LOG(INFO) << "Forgetting saved state for " << ObjectIdToString(*it);
102 } 107 }
103 } 108 }
104 109
105 virtual std::string GetBootstrapData() const OVERRIDE { 110 virtual std::string GetBootstrapData() const OVERRIDE {
106 return std::string(); 111 return std::string();
107 } 112 }
108 113
109 virtual void SetBootstrapData(const std::string& data) OVERRIDE { 114 virtual void SetBootstrapData(const std::string& data) OVERRIDE {
110 std::string base64_data; 115 std::string base64_data;
111 CHECK(base::Base64Encode(data, &base64_data)); 116 CHECK(base::Base64Encode(data, &base64_data));
112 LOG(INFO) << "Setting bootstrap data to: " << base64_data; 117 LOG(INFO) << "Setting bootstrap data to: " << base64_data;
akalin 2012/11/28 00:11:42 boo, duplicated code. can you pull this out into
dcheng 2012/11/30 01:42:54 Done. There's some TODOs with your name attached f
akalin 2012/11/30 02:54:31 There's one more -- the MyTestURLRequestContext, e
113 } 118 }
119
120 virtual void GenerateAckHandles(
121 const ObjectIdSet& ids,
122 const scoped_refptr<base::TaskRunner>& task_runner,
123 base::Callback<void(const AckHandleMap&)> callback) OVERRIDE {
124 AckHandleMap ack_handles;
125 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
126 ack_handles.insert(std::make_pair(*it, AckHandle::InvalidAckHandle()));
127 }
128 task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles));
akalin 2012/11/28 00:11:42 process return values (CHECK?)
dcheng 2012/11/30 01:42:54 Done.
129 }
130
131 virtual void Acknowledge(const invalidation::ObjectId& id,
132 const AckHandle& ack_handle) OVERRIDE {
133 LOG(INFO) << "Received ack for " << ObjectIdToString(id);
134 }
114 }; 135 };
115 136
116 // Needed to use a real host resolver. 137 // Needed to use a real host resolver.
117 class MyTestURLRequestContext : public net::TestURLRequestContext { 138 class MyTestURLRequestContext : public net::TestURLRequestContext {
118 public: 139 public:
119 MyTestURLRequestContext() : TestURLRequestContext(true) { 140 MyTestURLRequestContext() : TestURLRequestContext(true) {
120 context_storage_.set_host_resolver( 141 context_storage_.set_host_resolver(
121 net::HostResolver::CreateDefaultResolver(NULL)); 142 net::HostResolver::CreateDefaultResolver(NULL));
122 context_storage_.set_transport_security_state( 143 context_storage_.set_transport_security_state(
123 new net::TransportSecurityState()); 144 new net::TransportSecurityState());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 io_thread.Stop(); 275 io_thread.Stop();
255 return 0; 276 return 0;
256 } 277 }
257 278
258 } // namespace 279 } // namespace
259 } // namespace syncer 280 } // namespace syncer
260 281
261 int main(int argc, char* argv[]) { 282 int main(int argc, char* argv[]) {
262 return syncer::SyncListenNotificationsMain(argc, argv); 283 return syncer::SyncListenNotificationsMain(argc, argv);
263 } 284 }
OLDNEW
« sync/tools/sync_client.cc ('K') | « sync/tools/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698