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