OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/socket/socket_net_log_params.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/values.h" | |
9 #include "net/base/host_port_pair.h" | |
10 #include "net/base/ip_endpoint.h" | |
11 #include "net/base/net_util.h" | |
12 | |
13 namespace net { | |
14 | |
15 namespace { | |
16 | |
17 base::Value* NetLogSocketErrorCallback(int net_error, | |
18 int os_error, | |
19 NetLog::LogLevel /* log_level */) { | |
20 base::DictionaryValue* dict = new base::DictionaryValue(); | |
21 dict->SetInteger("net_error", net_error); | |
22 dict->SetInteger("os_error", os_error); | |
23 return dict; | |
24 } | |
25 | |
26 base::Value* NetLogHostPortPairCallback(const HostPortPair* host_and_port, | |
27 NetLog::LogLevel /* log_level */) { | |
28 base::DictionaryValue* dict = new base::DictionaryValue(); | |
29 dict->SetString("host_and_port", host_and_port->ToString()); | |
30 return dict; | |
31 } | |
32 | |
33 base::Value* NetLogIPEndPointCallback(const IPEndPoint* address, | |
34 NetLog::LogLevel /* log_level */) { | |
35 base::DictionaryValue* dict = new base::DictionaryValue(); | |
36 dict->SetString("address", address->ToString()); | |
37 return dict; | |
38 } | |
39 | |
40 base::Value* NetLogSourceAddressCallback(const struct sockaddr* net_address, | |
41 socklen_t address_len, | |
42 NetLog::LogLevel /* log_level */) { | |
43 base::DictionaryValue* dict = new base::DictionaryValue(); | |
44 dict->SetString("source_address", | |
45 NetAddressToStringWithPort(net_address, address_len)); | |
46 return dict; | |
47 } | |
48 | |
49 } // namespace | |
50 | |
51 NetLog::ParametersCallback CreateNetLogSocketErrorCallback(int net_error, | |
52 int os_error) { | |
53 return base::Bind(&NetLogSocketErrorCallback, net_error, os_error); | |
54 } | |
55 | |
56 NetLog::ParametersCallback CreateNetLogHostPortPairCallback( | |
57 const HostPortPair* host_and_port) { | |
58 return base::Bind(&NetLogHostPortPairCallback, host_and_port); | |
59 } | |
60 | |
61 NetLog::ParametersCallback CreateNetLogIPEndPointCallback( | |
62 const IPEndPoint* address) { | |
63 return base::Bind(&NetLogIPEndPointCallback, address); | |
64 } | |
65 | |
66 NetLog::ParametersCallback CreateNetLogSourceAddressCallback( | |
67 const struct sockaddr* net_address, | |
68 socklen_t address_len) { | |
69 return base::Bind(&NetLogSourceAddressCallback, net_address, address_len); | |
70 } | |
71 | |
72 } // namespace net | |
OLD | NEW |