OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" | 5 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
13 #include "base/string_util.h" | 13 #include "base/string_number_conversions.h" |
| 14 //#include "base/string_util.h" |
14 #include "chrome/browser/sync/sync_constants.h" | 15 #include "chrome/browser/sync/sync_constants.h" |
15 #include "google/cacheinvalidation/invalidation-client.h" | 16 #include "google/cacheinvalidation/invalidation-client.h" |
16 #include "jingle/notifier/listener/xml_element_util.h" | 17 #include "jingle/notifier/listener/xml_element_util.h" |
17 #include "talk/xmpp/constants.h" | 18 #include "talk/xmpp/constants.h" |
18 #include "talk/xmpp/jid.h" | 19 #include "talk/xmpp/jid.h" |
19 #include "talk/xmpp/xmppclient.h" | 20 #include "talk/xmpp/xmppclient.h" |
20 #include "talk/xmpp/xmpptask.h" | 21 #include "talk/xmpp/xmpptask.h" |
21 | 22 |
22 namespace sync_notifier { | 23 namespace sync_notifier { |
23 | 24 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 private: | 164 private: |
164 static buzz::XmlElement* MakeCacheInvalidationIqPacket( | 165 static buzz::XmlElement* MakeCacheInvalidationIqPacket( |
165 const buzz::Jid& to_jid, | 166 const buzz::Jid& to_jid, |
166 const std::string& task_id, | 167 const std::string& task_id, |
167 const std::string& msg, | 168 const std::string& msg, |
168 int seq, const std::string& sid) { | 169 int seq, const std::string& sid) { |
169 buzz::XmlElement* iq = MakeIq(buzz::STR_SET, to_jid, task_id); | 170 buzz::XmlElement* iq = MakeIq(buzz::STR_SET, to_jid, task_id); |
170 buzz::XmlElement* cache_invalidation_iq_packet = | 171 buzz::XmlElement* cache_invalidation_iq_packet = |
171 new buzz::XmlElement(kQnData, true); | 172 new buzz::XmlElement(kQnData, true); |
172 iq->AddElement(cache_invalidation_iq_packet); | 173 iq->AddElement(cache_invalidation_iq_packet); |
173 cache_invalidation_iq_packet->SetAttr(kQnSeq, IntToString(seq)); | 174 cache_invalidation_iq_packet->SetAttr(kQnSeq, base::IntToString(seq)); |
174 cache_invalidation_iq_packet->SetAttr(kQnSid, sid); | 175 cache_invalidation_iq_packet->SetAttr(kQnSid, sid); |
175 cache_invalidation_iq_packet->SetAttr(kQnServiceUrl, | 176 cache_invalidation_iq_packet->SetAttr(kQnServiceUrl, |
176 browser_sync::kSyncServiceUrl); | 177 browser_sync::kSyncServiceUrl); |
177 cache_invalidation_iq_packet->SetBodyText(msg); | 178 cache_invalidation_iq_packet->SetBodyText(msg); |
178 return iq; | 179 return iq; |
179 } | 180 } |
180 | 181 |
181 const buzz::Jid to_jid_; | 182 const buzz::Jid to_jid_; |
182 std::string msg_; | 183 std::string msg_; |
183 int seq_; | 184 int seq_; |
184 std::string sid_; | 185 std::string sid_; |
185 | 186 |
186 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationSendMessageTask); | 187 DISALLOW_COPY_AND_ASSIGN(CacheInvalidationSendMessageTask); |
187 }; | 188 }; |
188 | 189 |
189 std::string MakeSid() { | 190 std::string MakeSid() { |
190 uint64 sid = base::RandUint64(); | 191 uint64 sid = base::RandUint64(); |
191 return std::string("chrome-sync-") + Uint64ToString(sid); | 192 return std::string("chrome-sync-") + base::Uint64ToString(sid); |
192 } | 193 } |
193 | 194 |
194 } // namespace | 195 } // namespace |
195 | 196 |
196 CacheInvalidationPacketHandler::CacheInvalidationPacketHandler( | 197 CacheInvalidationPacketHandler::CacheInvalidationPacketHandler( |
197 buzz::XmppClient* xmpp_client, | 198 buzz::XmppClient* xmpp_client, |
198 invalidation::InvalidationClient* invalidation_client) | 199 invalidation::InvalidationClient* invalidation_client) |
199 : xmpp_client_(xmpp_client), | 200 : xmpp_client_(xmpp_client), |
200 invalidation_client_(invalidation_client), | 201 invalidation_client_(invalidation_client), |
201 seq_(0), | 202 seq_(0), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 xmpp_client_->SignalStateChange.disconnect(this); | 281 xmpp_client_->SignalStateChange.disconnect(this); |
281 xmpp_client_ = NULL; | 282 xmpp_client_ = NULL; |
282 break; | 283 break; |
283 default: | 284 default: |
284 LOG(INFO) << "xmpp_client_ state changed to " << state; | 285 LOG(INFO) << "xmpp_client_ state changed to " << state; |
285 break; | 286 break; |
286 } | 287 } |
287 } | 288 } |
288 | 289 |
289 } // namespace sync_notifier | 290 } // namespace sync_notifier |
OLD | NEW |