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

Unified Diff: remoting/signaling/jid_util.cc

Issue 1123153002: Added class to subscribe to GCD notifications over XMPP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-xmpp-connect2a
Patch Set: sync to head Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/signaling/jid_util.h ('k') | remoting/signaling/jid_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/signaling/jid_util.cc
diff --git a/remoting/signaling/jid_util.cc b/remoting/signaling/jid_util.cc
index 8e8e12bb8788da5d03eb93f8046d190907c03caf..ca0c9094cf40627c76cb72a080988d882a0f5064 100644
--- a/remoting/signaling/jid_util.cc
+++ b/remoting/signaling/jid_util.cc
@@ -9,15 +9,35 @@
namespace remoting {
std::string NormalizeJid(const std::string& jid) {
- size_t slash_pos = jid.find('/');
+ std::string bare_jid;
+ std::string resource;
+ if (SplitJidResource(jid, &bare_jid, &resource)) {
+ return base::StringToLowerASCII(bare_jid) + "/" + resource;
+ }
+ return base::StringToLowerASCII(bare_jid);
+}
- // In case there the jid doesn't have resource id covert the whole value to
- // lower-case.
- if (slash_pos == std::string::npos)
- return base::StringToLowerASCII(jid);
+bool SplitJidResource(const std::string& full_jid,
+ std::string* bare_jid,
+ std::string* resource) {
+ size_t slash_index = full_jid.find('/');
+ if (slash_index == std::string::npos) {
+ if (bare_jid) {
+ *bare_jid = full_jid;
+ }
+ if (resource) {
+ resource->clear();
+ }
+ return false;
+ }
- return base::StringToLowerASCII(jid.substr(0, slash_pos)) +
- jid.substr(slash_pos);
+ if (bare_jid) {
+ *bare_jid = full_jid.substr(0, slash_index);
+ }
+ if (resource) {
+ *resource = full_jid.substr(slash_index + 1);
+ }
+ return true;
}
} // namespace remoting
« no previous file with comments | « remoting/signaling/jid_util.h ('k') | remoting/signaling/jid_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698