OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ |
| 7 #include <deque> |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "talk/p2p/base/port.h" |
| 12 |
| 13 namespace buzz { |
| 14 class XmppClientSettings; |
| 15 } |
| 16 |
| 17 namespace notifier { |
| 18 |
| 19 class ConnectionSettings { |
| 20 public: |
| 21 ConnectionSettings() : protocol_(cricket::PROTO_TCP) {} |
| 22 |
| 23 cricket::ProtocolType protocol() { return protocol_; } |
| 24 const talk_base::SocketAddress& server() const { return server_; } |
| 25 const talk_base::ProxyInfo& proxy() const { return proxy_; } |
| 26 |
| 27 void set_protocol(cricket::ProtocolType protocol) { protocol_ = protocol; } |
| 28 talk_base::SocketAddress* mutable_server() { return &server_; } |
| 29 talk_base::ProxyInfo* mutable_proxy() { return &proxy_; } |
| 30 |
| 31 void FillXmppClientSettings(buzz::XmppClientSettings* xcs) const; |
| 32 |
| 33 private: |
| 34 cricket::ProtocolType protocol_; // PROTO_TCP, PROTO_SSLTCP, etc. |
| 35 talk_base::SocketAddress server_; // Server |
| 36 talk_base::ProxyInfo proxy_; // Proxy info |
| 37 // need copy constructor due to use in stl deque |
| 38 }; |
| 39 |
| 40 class ConnectionSettingsList { |
| 41 public: |
| 42 ConnectionSettingsList() {} |
| 43 |
| 44 void SetProxy(const talk_base::ProxyInfo& proxy) { |
| 45 *(template_.mutable_proxy()) = proxy; |
| 46 } |
| 47 |
| 48 const talk_base::ProxyInfo& proxy() const { |
| 49 return template_.proxy(); |
| 50 } |
| 51 |
| 52 int GetCount() { return list_.size(); } |
| 53 ConnectionSettings* GetSettings(size_t index) { return &list_[index]; } |
| 54 |
| 55 void ClearPermutations() { |
| 56 list_.clear(); |
| 57 iplist_seen_.clear(); |
| 58 } |
| 59 |
| 60 void AddPermutations(const std::string& hostname, |
| 61 const std::vector<uint32>& iplist, |
| 62 int16 port, |
| 63 bool special_port_magic, |
| 64 bool proxy_only); |
| 65 private: |
| 66 void PermuteForAddress(const talk_base::SocketAddress& server, |
| 67 bool special_port_magic, |
| 68 bool proxy_only, |
| 69 std::deque<ConnectionSettings>* list_temp); |
| 70 |
| 71 ConnectionSettings template_; |
| 72 std::deque<ConnectionSettings> list_; |
| 73 std::vector<uint32> iplist_seen_; |
| 74 DISALLOW_COPY_AND_ASSIGN(ConnectionSettingsList); |
| 75 }; |
| 76 } // namespace notifier |
| 77 |
| 78 #endif // CHROME_BROWSER_SYNC_NOTIFIER_COMMUNICATOR_CONNECTION_SETTINGS_H_ |
OLD | NEW |