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