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 base::Value* NetLogSocketErrorCallback(int net_error, | 17 scoped_ptr<base::Value> NetLogSocketErrorCallback( |
18 int os_error, | 18 int net_error, |
19 NetLogCaptureMode /* capture_mode */) { | 19 int os_error, |
20 base::DictionaryValue* dict = new base::DictionaryValue(); | 20 NetLogCaptureMode /* capture_mode */) { |
| 21 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
21 dict->SetInteger("net_error", net_error); | 22 dict->SetInteger("net_error", net_error); |
22 dict->SetInteger("os_error", os_error); | 23 dict->SetInteger("os_error", os_error); |
23 return dict; | 24 return dict.Pass(); |
24 } | 25 } |
25 | 26 |
26 base::Value* NetLogHostPortPairCallback(const HostPortPair* host_and_port, | 27 scoped_ptr<base::Value> NetLogHostPortPairCallback( |
27 NetLogCaptureMode /* capture_mode */) { | 28 const HostPortPair* host_and_port, |
28 base::DictionaryValue* dict = new base::DictionaryValue(); | 29 NetLogCaptureMode /* capture_mode */) { |
| 30 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
29 dict->SetString("host_and_port", host_and_port->ToString()); | 31 dict->SetString("host_and_port", host_and_port->ToString()); |
30 return dict; | 32 return dict.Pass(); |
31 } | 33 } |
32 | 34 |
33 base::Value* NetLogIPEndPointCallback(const IPEndPoint* address, | 35 scoped_ptr<base::Value> NetLogIPEndPointCallback( |
34 NetLogCaptureMode /* capture_mode */) { | 36 const IPEndPoint* address, |
35 base::DictionaryValue* dict = new base::DictionaryValue(); | 37 NetLogCaptureMode /* capture_mode */) { |
| 38 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
36 dict->SetString("address", address->ToString()); | 39 dict->SetString("address", address->ToString()); |
37 return dict; | 40 return dict.Pass(); |
38 } | 41 } |
39 | 42 |
40 base::Value* NetLogSourceAddressCallback(const struct sockaddr* net_address, | 43 scoped_ptr<base::Value> NetLogSourceAddressCallback( |
41 socklen_t address_len, | 44 const struct sockaddr* net_address, |
42 NetLogCaptureMode /* capture_mode */) { | 45 socklen_t address_len, |
43 base::DictionaryValue* dict = new base::DictionaryValue(); | 46 NetLogCaptureMode /* capture_mode */) { |
| 47 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
44 dict->SetString("source_address", | 48 dict->SetString("source_address", |
45 NetAddressToStringWithPort(net_address, address_len)); | 49 NetAddressToStringWithPort(net_address, address_len)); |
46 return dict; | 50 return dict.Pass(); |
47 } | 51 } |
48 | 52 |
49 } // namespace | 53 } // namespace |
50 | 54 |
51 NetLog::ParametersCallback CreateNetLogSocketErrorCallback(int net_error, | 55 NetLog::ParametersCallback CreateNetLogSocketErrorCallback(int net_error, |
52 int os_error) { | 56 int os_error) { |
53 return base::Bind(&NetLogSocketErrorCallback, net_error, os_error); | 57 return base::Bind(NetLogSocketErrorCallback, net_error, os_error); |
54 } | 58 } |
55 | 59 |
56 NetLog::ParametersCallback CreateNetLogHostPortPairCallback( | 60 NetLog::ParametersCallback CreateNetLogHostPortPairCallback( |
57 const HostPortPair* host_and_port) { | 61 const HostPortPair* host_and_port) { |
58 return base::Bind(&NetLogHostPortPairCallback, host_and_port); | 62 return base::Bind(NetLogHostPortPairCallback, host_and_port); |
59 } | 63 } |
60 | 64 |
61 NetLog::ParametersCallback CreateNetLogIPEndPointCallback( | 65 NetLog::ParametersCallback CreateNetLogIPEndPointCallback( |
62 const IPEndPoint* address) { | 66 const IPEndPoint* address) { |
63 return base::Bind(&NetLogIPEndPointCallback, address); | 67 return base::Bind(NetLogIPEndPointCallback, address); |
64 } | 68 } |
65 | 69 |
66 NetLog::ParametersCallback CreateNetLogSourceAddressCallback( | 70 NetLog::ParametersCallback CreateNetLogSourceAddressCallback( |
67 const struct sockaddr* net_address, | 71 const struct sockaddr* net_address, |
68 socklen_t address_len) { | 72 socklen_t address_len) { |
69 return base::Bind(&NetLogSourceAddressCallback, net_address, address_len); | 73 return base::Bind(NetLogSourceAddressCallback, net_address, address_len); |
70 } | 74 } |
71 | 75 |
72 } // namespace net | 76 } // namespace net |
OLD | NEW |