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" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 VLOG(2) << "Queueing stanza"; | 77 VLOG(2) << "Queueing stanza"; |
78 QueueStanza(stanza); | 78 QueueStanza(stanza); |
79 return true; | 79 return true; |
80 } | 80 } |
81 VLOG(2) << "Stanza skipped"; | 81 VLOG(2) << "Stanza skipped"; |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 bool IsValidCacheInvalidationIqPacket(const buzz::XmlElement* stanza) { | 86 bool IsValidCacheInvalidationIqPacket(const buzz::XmlElement* stanza) { |
87 // We make sure to compare jids (which are normalized) instead of | 87 return MatchRequestIq(stanza, buzz::STR_SET, kQnData); |
sanjeevr
2011/01/30 22:55:07
Nit: Might want to add some comments mentioning th
akalin
2011/01/31 09:54:17
Done.
| |
88 // just strings -- server may use non-normalized jids in | |
89 // attributes. | |
90 // | |
91 // TODO(akalin): Add unit tests for this. | |
92 buzz::Jid to(stanza->Attr(buzz::QN_TO)); | |
93 return | |
94 (MatchRequestIq(stanza, buzz::STR_SET, kQnData) && | |
95 (to == GetClient()->jid())); | |
96 } | 88 } |
97 | 89 |
98 bool GetCacheInvalidationIqPacketData(const buzz::XmlElement* stanza, | 90 bool GetCacheInvalidationIqPacketData(const buzz::XmlElement* stanza, |
99 std::string* data) { | 91 std::string* data) { |
100 DCHECK(IsValidCacheInvalidationIqPacket(stanza)); | 92 DCHECK(IsValidCacheInvalidationIqPacket(stanza)); |
101 const buzz::XmlElement* cache_invalidation_iq_packet = | 93 const buzz::XmlElement* cache_invalidation_iq_packet = |
102 stanza->FirstNamed(kQnData); | 94 stanza->FirstNamed(kQnData); |
103 if (!cache_invalidation_iq_packet) { | 95 if (!cache_invalidation_iq_packet) { |
104 LOG(ERROR) << "Could not find cache invalidation IQ packet element"; | 96 LOG(ERROR) << "Could not find cache invalidation IQ packet element"; |
105 return false; | 97 return false; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 std::string decoded_message; | 240 std::string decoded_message; |
249 if (!base::Base64Decode(packet, &decoded_message)) { | 241 if (!base::Base64Decode(packet, &decoded_message)) { |
250 LOG(ERROR) << "Could not base64-decode received message: " | 242 LOG(ERROR) << "Could not base64-decode received message: " |
251 << packet; | 243 << packet; |
252 return; | 244 return; |
253 } | 245 } |
254 network_endpoint->HandleInboundMessage(decoded_message); | 246 network_endpoint->HandleInboundMessage(decoded_message); |
255 } | 247 } |
256 | 248 |
257 } // namespace sync_notifier | 249 } // namespace sync_notifier |
OLD | NEW |