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

Side by Side Diff: chrome/common/net/notifier/communicator/connection_settings.cc

Issue 2255007: New libjingle integrated to chrome. (Closed)
Patch Set: - Created 10 years, 6 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/common/net/notifier/communicator/connection_settings.h" 11 #include "chrome/common/net/notifier/communicator/connection_settings.h"
12 #include "talk/base/helpers.h" 12 #include "talk/base/helpers.h"
13 #include "talk/xmpp/xmppclientsettings.h" 13 #include "talk/xmpp/xmppclientsettings.h"
14 14
15 namespace notifier { 15 namespace notifier {
16 16
17 class RandomGenerator { 17 class RandomGenerator {
18 public: 18 public:
19 int operator()(int ceiling) { 19 int operator()(int ceiling) {
20 return static_cast<int>(cricket::CreateRandomId() % ceiling); 20 return static_cast<int>(talk_base::CreateRandomId() % ceiling);
21 } 21 }
22 }; 22 };
23 23
24 void ConnectionSettings::FillXmppClientSettings( 24 void ConnectionSettings::FillXmppClientSettings(
25 buzz::XmppClientSettings* xcs) const { 25 buzz::XmppClientSettings* xcs) const {
26 DCHECK(xcs); 26 DCHECK(xcs);
27 xcs->set_protocol(protocol_); 27 xcs->set_protocol(protocol_);
28 xcs->set_server(server_); 28 xcs->set_server(server_);
29 xcs->set_proxy(proxy_.type); 29 xcs->set_proxy(proxy_.type);
30 if (proxy_.type != talk_base::PROXY_NONE) { 30 if (proxy_.type != talk_base::PROXY_NONE) {
(...skipping 20 matching lines...) Expand all
51 RandomGenerator rg; 51 RandomGenerator rg;
52 std::random_shuffle(iplist_random.begin(), iplist_random.end(), rg); 52 std::random_shuffle(iplist_random.begin(), iplist_random.end(), rg);
53 53
54 // Put generated addresses in a new deque, then append on the list_, since 54 // Put generated addresses in a new deque, then append on the list_, since
55 // there are order dependencies and AddPermutations() may be called more 55 // there are order dependencies and AddPermutations() may be called more
56 // than once. 56 // than once.
57 std::deque<ConnectionSettings> list_temp; 57 std::deque<ConnectionSettings> list_temp;
58 58
59 // Permute addresses for this server. In some cases we haven't resolved the 59 // Permute addresses for this server. In some cases we haven't resolved the
60 // to ip addresses. 60 // to ip addresses.
61 talk_base::SocketAddress server(hostname, port, false); 61 talk_base::SocketAddress server(hostname, port);
62 if (iplist_random.empty()) { 62 if (iplist_random.empty()) {
63 // We couldn't pre-resolve the hostname, so let's hope it will resolve 63 // We couldn't pre-resolve the hostname, so let's hope it will resolve
64 // further down the pipeline (by a proxy, for example). 64 // further down the pipeline (by a proxy, for example).
65 PermuteForAddress(server, special_port_magic, proxy_only, &list_temp); 65 PermuteForAddress(server, special_port_magic, proxy_only, &list_temp);
66 } else { 66 } else {
67 // Generate a set of possibilities for each server address. 67 // Generate a set of possibilities for each server address.
68 // Don't do permute duplicates. 68 // Don't do permute duplicates.
69 for (size_t index = 0; index < iplist_random.size(); ++index) { 69 for (size_t index = 0; index < iplist_random.size(); ++index) {
70 if (std::find(iplist_seen_.begin(), iplist_seen_.end(), 70 if (std::find(iplist_seen_.begin(), iplist_seen_.end(),
71 iplist_random[index]) != iplist_seen_.end()) { 71 iplist_random[index]) != iplist_seen_.end()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 if (special_port_magic) { 120 if (special_port_magic) {
121 settings.set_protocol(cricket::PROTO_SSLTCP); 121 settings.set_protocol(cricket::PROTO_SSLTCP);
122 settings.mutable_server()->SetPort(443); 122 settings.mutable_server()->SetPort(443);
123 list_temp->push_back(settings); 123 list_temp->push_back(settings);
124 } 124 }
125 } 125 }
126 } 126 }
127 } 127 }
128 } // namespace notifier 128 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/common/net/notifier/base/task_pump.cc ('k') | chrome/common/net/notifier/communicator/login.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698