Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: net/base/address_list.h

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get compiling on mac Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/dns_master_unittest.cc ('k') | net/base/address_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Adopt the given addrinfo list in place of the existing one if any. This 18 // Adopt the given addrinfo list in place of the existing one if any. This
19 // hands over responsibility for freeing the addrinfo list to the AddressList 19 // hands over responsibility for freeing the addrinfo list to the AddressList
20 // object. 20 // object.
21 void Adopt(struct addrinfo* head); 21 void Adopt(struct addrinfo* head);
22 22
23 // Copies the given addrinfo rather than adopting it.
24 void Copy(const struct addrinfo* head);
wtc 2009/06/12 18:40:04 Eric, In the most common case, we connect to only
eroman 2009/06/12 20:15:22 That seems really weird to me. - We would be doin
25
26 // Sets the port of all addresses in the list to |port| (that is the
27 // sin[6]_port field for the sockaddrs).
28 void SetPort(int port);
29
30 // Retrieves the port number of the first sockaddr in the list. (If SetPort()
31 // was previously used on this list, then all the addresses will have this
32 // same port number.)
33 int GetPort() const;
34
35 // Sets the address to match |src|, and have each sockaddr's port be |port|.
36 // If |src| already has the desired port this operation is cheap (just adds
37 // a reference to |src|'s data.) Otherwise we will make a copy.
38 void SetFrom(const AddressList& src, int port);
39
40 // Clears all data from this address list. This leaves the list in the same
41 // empty state as when first constructed.
42 void Reset();
43
23 // Get access to the head of the addrinfo list. 44 // Get access to the head of the addrinfo list.
24 const struct addrinfo* head() const { return data_->head; } 45 const struct addrinfo* head() const { return data_->head; }
25 46
26 private: 47 private:
27 struct Data : public base::RefCountedThreadSafe<Data> { 48 struct Data : public base::RefCountedThreadSafe<Data> {
28 explicit Data(struct addrinfo* ai) : head(ai) {} 49 Data(struct addrinfo* ai, bool is_system_created)
50 : head(ai), is_system_created(is_system_created) {}
29 ~Data(); 51 ~Data();
30 struct addrinfo* head; 52 struct addrinfo* head;
31 private: 53
32 Data(); 54 // Indicates which free function to use for |head|.
55 bool is_system_created;
33 }; 56 };
34 scoped_refptr<Data> data_; 57 scoped_refptr<Data> data_;
35 }; 58 };
36 59
37 } // namespace net 60 } // namespace net
38 61
39 #endif // NET_BASE_ADDRESS_LIST_H_ 62 #endif // NET_BASE_ADDRESS_LIST_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/dns_master_unittest.cc ('k') | net/base/address_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698