// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_BASE_ADDRESS_LIST_H_ #define NET_BASE_ADDRESS_LIST_H_ #include #include #include "base/basictypes.h" #include "base/compiler_specific.h" #include "net/base/ip_endpoint.h" #include "net/base/net_export.h" #include "net/base/net_log.h" #include "net/base/net_util.h" struct addrinfo; namespace net { class NET_EXPORT AddressList : NON_EXPORTED_BASE(private std::vector) { public: AddressList(); ~AddressList(); // Creates an address list for a single IP literal. explicit AddressList(const IPEndPoint& endpoint); static AddressList CreateFromIPAddress(const IPAddressNumber& address, uint16 port); static AddressList CreateFromIPAddressList( const IPAddressList& addresses, const std::string& canonical_name); // Copies the data from |head| and the chained list into an AddressList. static AddressList CreateFromAddrinfo(const struct addrinfo* head); // Returns a copy of |list| with port on each element set to |port|. static AddressList CopyWithPort(const AddressList& list, uint16 port); // TODO(szym): Remove all three. http://crbug.com/126134 const std::string& canonical_name() const { return canonical_name_; } void set_canonical_name(const std::string& canonical_name) { canonical_name_ = canonical_name; } // Sets canonical name to the literal of the first IP address on the list. void SetDefaultCanonicalName(); // Creates a callback for use with the NetLog that returns a Value // representation of the address list. The callback must be destroyed before // |this| is. NetLog::ParametersCallback CreateNetLogCallback() const; // Exposed methods from std::vector. using std::vector::size; using std::vector::empty; using std::vector::clear; using std::vector::reserve; using std::vector::capacity; using std::vector::operator[]; using std::vector::front; using std::vector::back; using std::vector::push_back; using std::vector::insert; using std::vector::erase; using std::vector::iterator; using std::vector::const_iterator; using std::vector::begin; using std::vector::end; using std::vector::rbegin; using std::vector::rend; private: // TODO(szym): Remove. http://crbug.com/126134 std::string canonical_name_; }; } // namespace net #endif // NET_BASE_ADDRESS_LIST_H_