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

Side by Side 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: revised unit test 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "remoting/signaling/jid_util.h" 5 #include "remoting/signaling/jid_util.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 8
9 namespace remoting { 9 namespace remoting {
10 10
11 std::string NormalizeJid(const std::string& jid) { 11 std::string NormalizeJid(const std::string& jid) {
12 size_t slash_pos = jid.find('/'); 12 std::string bare_jid;
13 std::string resource_suffix;
14 SplitJidResource(jid, &bare_jid, &resource_suffix);
15 return base::StringToLowerASCII(bare_jid) + resource_suffix;
16 }
13 17
14 // In case there the jid doesn't have resource id covert the whole value to 18 bool SplitJidResource(const std::string& full_jid,
15 // lower-case. 19 std::string* bare_jid,
16 if (slash_pos == std::string::npos) 20 std::string* resource_suffix) {
17 return base::StringToLowerASCII(jid); 21 size_t slash_index = full_jid.find('/');
18 22 if (slash_index == std::string::npos) {
19 return base::StringToLowerASCII(jid.substr(0, slash_pos)) + 23 if (bare_jid != nullptr) {
Sergey Ulanov 2015/05/15 18:22:37 nit: don't need "!=nullptr" part
John Williams 2015/05/15 21:59:43 Done.
20 jid.substr(slash_pos); 24 *bare_jid = full_jid;
25 }
26 if (resource_suffix != nullptr) {
27 resource_suffix->clear();
28 }
29 return false;
30 } else {
Sergey Ulanov 2015/05/15 18:22:37 don't need else because the if above always return
John Williams 2015/05/15 21:59:43 Done.
31 if (bare_jid != nullptr) {
32 *bare_jid = std::string(full_jid, 0, slash_index);
33 }
34 if (resource_suffix != nullptr) {
35 *resource_suffix = std::string(full_jid, slash_index);
36 }
37 return true;
38 }
21 } 39 }
22 40
23 } // namespace remoting 41 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698