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