OLD | NEW |
1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 | 13 |
14 struct addrinfo; | 14 struct addrinfo; |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 // An AddressList object contains a linked list of addrinfo structures. This | 18 // An AddressList object contains a linked list of addrinfo structures. This |
19 // class is designed to be copied around by value. | 19 // class is designed to be copied around by value. |
20 class AddressList { | 20 class AddressList { |
21 public: | 21 public: |
22 // Constructs an empty address list. | 22 // Constructs an empty address list. |
23 AddressList() {} | 23 AddressList() {} |
24 | 24 |
25 // Constructs an address list for a single IP literal. If | 25 // Constructs an address list for a single IP literal. If |
26 // |canonicalize_name| is true, fill the ai_canonname field with the | 26 // |canonicalize_name| is true, fill the ai_canonname field with the |
27 // canonicalized IP address. | 27 // canonicalized IP address. |
28 AddressList(const IPAddressNumber& address, int port, bool canonicalize_name); | 28 AddressList(const IPAddressNumber& address, int port, bool canonicalize_name); |
29 | 29 |
30 // Adopt the given addrinfo list in place of the existing one if any. This | 30 // Adopt the given addrinfo list (assumed to have been created by |
31 // hands over responsibility for freeing the addrinfo list to the AddressList | 31 // the system, e.g. returned by getaddrinfo()) in place of the |
32 // object. | 32 // existing one if any. This hands over responsibility for freeing |
| 33 // the addrinfo list to the AddressList object. |
33 void Adopt(struct addrinfo* head); | 34 void Adopt(struct addrinfo* head); |
34 | 35 |
35 // Copies the given addrinfo rather than adopting it. If |recursive| is true, | 36 // Copies the given addrinfo rather than adopting it. If |recursive| is true, |
36 // all linked struct addrinfos will be copied as well. Otherwise only the head | 37 // all linked struct addrinfos will be copied as well. Otherwise only the head |
37 // will be copied, and the rest of linked entries will be ignored. | 38 // will be copied, and the rest of linked entries will be ignored. |
38 void Copy(const struct addrinfo* head, bool recursive); | 39 void Copy(const struct addrinfo* head, bool recursive); |
39 | 40 |
40 // Appends a copy of |head| and all its linked addrinfos to the stored | 41 // Appends a copy of |head| and all its linked addrinfos to the stored |
41 // addrinfo. | 42 // addrinfo. |
42 void Append(const struct addrinfo* head); | 43 void Append(const struct addrinfo* head); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 }; | 85 }; |
85 | 86 |
86 explicit AddressList(Data* data) : data_(data) {} | 87 explicit AddressList(Data* data) : data_(data) {} |
87 | 88 |
88 scoped_refptr<Data> data_; | 89 scoped_refptr<Data> data_; |
89 }; | 90 }; |
90 | 91 |
91 } // namespace net | 92 } // namespace net |
92 | 93 |
93 #endif // NET_BASE_ADDRESS_LIST_H_ | 94 #endif // NET_BASE_ADDRESS_LIST_H_ |
OLD | NEW |