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

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

Issue 10539094: NetLogEventParameter to Callback refactoring 1, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove unneeded line Created 8 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
OLDNEW
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/bind.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h"
8 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
9 #include "net/base/sys_addrinfo.h" 11 #include "net/base/sys_addrinfo.h"
10 12
11 namespace net { 13 namespace net {
12 14
15 namespace {
16
17 base::Value* NetLogAddressListCallback(const AddressList* address_list,
18 NetLog::LogLevel log_level) {
19 DictionaryValue* dict = new DictionaryValue();
20 ListValue* list = new ListValue();
21
22 for (AddressList::const_iterator it = address_list->begin();
23 it != address_list->end(); ++it) {
24 list->Append(Value::CreateStringValue(it->ToString()));
25 }
26
27 dict->Set("address_list", list);
28 return dict;
29 }
30
31 } // namespace
32
13 AddressList::AddressList() {} 33 AddressList::AddressList() {}
14 34
15 AddressList::~AddressList() {} 35 AddressList::~AddressList() {}
16 36
17 AddressList::AddressList(const IPEndPoint& endpoint) { 37 AddressList::AddressList(const IPEndPoint& endpoint) {
18 push_back(endpoint); 38 push_back(endpoint);
19 } 39 }
20 40
21 // static 41 // static
22 AddressList AddressList::CreateFromIPAddress(const IPAddressNumber& address, 42 AddressList AddressList::CreateFromIPAddress(const IPAddressNumber& address,
(...skipping 29 matching lines...) Expand all
52 DLOG(WARNING) << "Unknown family found in addrinfo: " << ai->ai_family; 72 DLOG(WARNING) << "Unknown family found in addrinfo: " << ai->ai_family;
53 } 73 }
54 return list; 74 return list;
55 } 75 }
56 76
57 void AddressList::SetDefaultCanonicalName() { 77 void AddressList::SetDefaultCanonicalName() {
58 DCHECK(!empty()); 78 DCHECK(!empty());
59 set_canonical_name(front().ToStringWithoutPort()); 79 set_canonical_name(front().ToStringWithoutPort());
60 } 80 }
61 81
82 NetLog::ParametersCallback AddressList::CreateNetLogCallback() const {
83 return base::Bind(&NetLogAddressListCallback, this);
84 }
85
62 void SetPortOnAddressList(uint16 port, AddressList* list) { 86 void SetPortOnAddressList(uint16 port, AddressList* list) {
63 DCHECK(list); 87 DCHECK(list);
64 for (AddressList::iterator it = list->begin(); it != list->end(); ++it) { 88 for (AddressList::iterator it = list->begin(); it != list->end(); ++it)
65 *it = IPEndPoint(it->address(), port); 89 *it = IPEndPoint(it->address(), port);
66 }
67 } 90 }
68 91
69 } // namespace net 92 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698