| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef NET_BASE_ADDRESS_LIST_H_ | 5 #ifndef NET_BASE_ADDRESS_LIST_H_ |
| 6 #define NET_BASE_ADDRESS_LIST_H_ | 6 #define NET_BASE_ADDRESS_LIST_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 11 | 9 |
| 12 struct addrinfo; | 10 struct addrinfo; |
| 13 | 11 |
| 14 namespace net { | 12 namespace net { |
| 15 | 13 |
| 16 // An AddressList object contains a linked list of addrinfo structures. This | 14 // An AddressList object contains a linked list of addrinfo structures. This |
| 17 // class is designed to be copied around by value. | 15 // class is designed to be copied around by value. |
| 18 class AddressList { | 16 class AddressList { |
| 19 public: | 17 public: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 41 // Retrieves the port number of the first sockaddr in the list. (If SetPort() | 39 // Retrieves the port number of the first sockaddr in the list. (If SetPort() |
| 42 // was previously used on this list, then all the addresses will have this | 40 // was previously used on this list, then all the addresses will have this |
| 43 // same port number.) | 41 // same port number.) |
| 44 int GetPort() const; | 42 int GetPort() const; |
| 45 | 43 |
| 46 // Sets the address to match |src|, and have each sockaddr's port be |port|. | 44 // Sets the address to match |src|, and have each sockaddr's port be |port|. |
| 47 // If |src| already has the desired port this operation is cheap (just adds | 45 // If |src| already has the desired port this operation is cheap (just adds |
| 48 // a reference to |src|'s data.) Otherwise we will make a copy. | 46 // a reference to |src|'s data.) Otherwise we will make a copy. |
| 49 void SetFrom(const AddressList& src, int port); | 47 void SetFrom(const AddressList& src, int port); |
| 50 | 48 |
| 51 // Gets the canonical name for the address. | |
| 52 // If the canonical name exists, |*canonical_name| is filled in with the | |
| 53 // value and true is returned. If it does not exist, |*canonical_name| is | |
| 54 // not altered and false is returned. | |
| 55 // |canonical_name| must be a non-null value. | |
| 56 bool GetCanonicalName(std::string* canonical_name) const; | |
| 57 | |
| 58 // Clears all data from this address list. This leaves the list in the same | 49 // Clears all data from this address list. This leaves the list in the same |
| 59 // empty state as when first constructed. | 50 // empty state as when first constructed. |
| 60 void Reset(); | 51 void Reset(); |
| 61 | 52 |
| 62 // Used by unit-tests to manually set the TCP socket address. | 53 // Used by unit-tests to manually set the TCP socket address. |
| 63 static AddressList CreateIPv6Address(unsigned char data[16]); | 54 static AddressList CreateIPv6Address(unsigned char data[16]); |
| 64 | 55 |
| 65 // Get access to the head of the addrinfo list. | 56 // Get access to the head of the addrinfo list. |
| 66 const struct addrinfo* head() const { return data_->head; } | 57 const struct addrinfo* head() const { return data_->head; } |
| 67 | 58 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 81 }; | 72 }; |
| 82 | 73 |
| 83 explicit AddressList(Data* data) : data_(data) {} | 74 explicit AddressList(Data* data) : data_(data) {} |
| 84 | 75 |
| 85 scoped_refptr<Data> data_; | 76 scoped_refptr<Data> data_; |
| 86 }; | 77 }; |
| 87 | 78 |
| 88 } // namespace net | 79 } // namespace net |
| 89 | 80 |
| 90 #endif // NET_BASE_ADDRESS_LIST_H_ | 81 #endif // NET_BASE_ADDRESS_LIST_H_ |
| OLD | NEW |