OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "net/base/address_list.h" | 5 #include "net/base/address_list.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" |
8 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
9 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 | 13 |
13 AddressList::AddressList() {} | 14 AddressList::AddressList() {} |
14 | 15 |
15 AddressList::~AddressList() {} | 16 AddressList::~AddressList() {} |
16 | 17 |
17 AddressList::AddressList(const IPEndPoint& endpoint) { | 18 AddressList::AddressList(const IPEndPoint& endpoint) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DLOG(WARNING) << "Unknown family found in addrinfo: " << ai->ai_family; | 53 DLOG(WARNING) << "Unknown family found in addrinfo: " << ai->ai_family; |
53 } | 54 } |
54 return list; | 55 return list; |
55 } | 56 } |
56 | 57 |
57 void AddressList::SetDefaultCanonicalName() { | 58 void AddressList::SetDefaultCanonicalName() { |
58 DCHECK(!empty()); | 59 DCHECK(!empty()); |
59 set_canonical_name(front().ToStringWithoutPort()); | 60 set_canonical_name(front().ToStringWithoutPort()); |
60 } | 61 } |
61 | 62 |
| 63 base::Value* AddressList::NetLogCallback(NetLog::LogLevel log_level) const { |
| 64 DictionaryValue* dict = new DictionaryValue(); |
| 65 ListValue* list = new ListValue(); |
| 66 |
| 67 for (AddressList::const_iterator it = begin(); it != end(); ++it) |
| 68 list->Append(Value::CreateStringValue(it->ToString())); |
| 69 |
| 70 dict->Set("address_list", list); |
| 71 return dict; |
| 72 } |
| 73 |
62 void SetPortOnAddressList(uint16 port, AddressList* list) { | 74 void SetPortOnAddressList(uint16 port, AddressList* list) { |
63 DCHECK(list); | 75 DCHECK(list); |
64 for (AddressList::iterator it = list->begin(); it != list->end(); ++it) { | 76 for (AddressList::iterator it = list->begin(); it != list->end(); ++it) |
65 *it = IPEndPoint(it->address(), port); | 77 *it = IPEndPoint(it->address(), port); |
66 } | |
67 } | 78 } |
68 | 79 |
69 } // namespace net | 80 } // namespace net |
OLD | NEW |