OLD | NEW |
1 // Copyright (c) 2006-2008 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 "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 | 9 |
10 struct addrinfo; | 10 struct addrinfo; |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 // An AddressList object contains a linked list of addrinfo structures. This | 14 // An AddressList object contains a linked list of addrinfo structures. This |
15 // class is designed to be copied around by value. | 15 // class is designed to be copied around by value. |
16 class AddressList { | 16 class AddressList { |
17 public: | 17 public: |
18 // Constructs an empty address list. | 18 // Constructs an empty address list. |
19 AddressList() {} | 19 AddressList() {} |
20 | 20 |
21 // Adopt the given addrinfo list in place of the existing one if any. This | 21 // Adopt the given addrinfo list in place of the existing one if any. This |
22 // hands over responsibility for freeing the addrinfo list to the AddressList | 22 // hands over responsibility for freeing the addrinfo list to the AddressList |
23 // object. | 23 // object. |
24 void Adopt(struct addrinfo* head); | 24 void Adopt(struct addrinfo* head); |
25 | 25 |
26 // Copies the given addrinfo rather than adopting it. | 26 // Copies the given addrinfo rather than adopting it. If |recursive| is true, |
27 void Copy(const struct addrinfo* head); | 27 // all linked struct addrinfos will be copied as well. Otherwise only the head |
| 28 // will be copied, and the rest of linked entries will be ignored. |
| 29 void Copy(const struct addrinfo* head, bool recursive); |
| 30 |
| 31 // Appends a copy of |head| and all its linked addrinfos to the stored |
| 32 // addrinfo. |
| 33 void Append(const struct addrinfo* head); |
28 | 34 |
29 // Sets the port of all addresses in the list to |port| (that is the | 35 // Sets the port of all addresses in the list to |port| (that is the |
30 // sin[6]_port field for the sockaddrs). | 36 // sin[6]_port field for the sockaddrs). |
31 void SetPort(int port); | 37 void SetPort(int port); |
32 | 38 |
33 // 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() |
34 // 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 |
35 // same port number.) | 41 // same port number.) |
36 int GetPort() const; | 42 int GetPort() const; |
37 | 43 |
(...skipping 28 matching lines...) Expand all Loading... |
66 }; | 72 }; |
67 | 73 |
68 explicit AddressList(Data* data) : data_(data) {} | 74 explicit AddressList(Data* data) : data_(data) {} |
69 | 75 |
70 scoped_refptr<Data> data_; | 76 scoped_refptr<Data> data_; |
71 }; | 77 }; |
72 | 78 |
73 } // namespace net | 79 } // namespace net |
74 | 80 |
75 #endif // NET_BASE_ADDRESS_LIST_H_ | 81 #endif // NET_BASE_ADDRESS_LIST_H_ |
OLD | NEW |