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