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/udp/udp_net_log_parameters.h" | 5 #include "net/udp/udp_net_log_parameters.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 base::Value* NetLogUDPDataTranferCallback(int byte_count, | 16 scoped_ptr<base::Value> NetLogUDPDataTranferCallback( |
17 const char* bytes, | 17 int byte_count, |
18 const IPEndPoint* address, | 18 const char* bytes, |
19 NetLogCaptureMode capture_mode) { | 19 const IPEndPoint* address, |
20 base::DictionaryValue* dict = new base::DictionaryValue(); | 20 NetLogCaptureMode capture_mode) { |
| 21 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
21 dict->SetInteger("byte_count", byte_count); | 22 dict->SetInteger("byte_count", byte_count); |
22 if (capture_mode.include_socket_bytes()) | 23 if (capture_mode.include_socket_bytes()) |
23 dict->SetString("hex_encoded_bytes", base::HexEncode(bytes, byte_count)); | 24 dict->SetString("hex_encoded_bytes", base::HexEncode(bytes, byte_count)); |
24 if (address) | 25 if (address) |
25 dict->SetString("address", address->ToString()); | 26 dict->SetString("address", address->ToString()); |
26 return dict; | 27 return dict.Pass(); |
27 } | 28 } |
28 | 29 |
29 base::Value* NetLogUDPConnectCallback(const IPEndPoint* address, | 30 scoped_ptr<base::Value> NetLogUDPConnectCallback( |
30 NetLogCaptureMode /* capture_mode */) { | 31 const IPEndPoint* address, |
31 base::DictionaryValue* dict = new base::DictionaryValue(); | 32 NetLogCaptureMode /* capture_mode */) { |
| 33 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
32 dict->SetString("address", address->ToString()); | 34 dict->SetString("address", address->ToString()); |
33 return dict; | 35 return dict.Pass(); |
34 } | 36 } |
35 | 37 |
36 } // namespace | 38 } // namespace |
37 | 39 |
38 NetLog::ParametersCallback CreateNetLogUDPDataTranferCallback( | 40 NetLog::ParametersCallback CreateNetLogUDPDataTranferCallback( |
39 int byte_count, | 41 int byte_count, |
40 const char* bytes, | 42 const char* bytes, |
41 const IPEndPoint* address) { | 43 const IPEndPoint* address) { |
42 DCHECK(bytes); | 44 DCHECK(bytes); |
43 return base::Bind(&NetLogUDPDataTranferCallback, byte_count, bytes, address); | 45 return base::Bind(&NetLogUDPDataTranferCallback, byte_count, bytes, address); |
44 } | 46 } |
45 | 47 |
46 NetLog::ParametersCallback CreateNetLogUDPConnectCallback( | 48 NetLog::ParametersCallback CreateNetLogUDPConnectCallback( |
47 const IPEndPoint* address) { | 49 const IPEndPoint* address) { |
48 DCHECK(address); | 50 DCHECK(address); |
49 return base::Bind(&NetLogUDPConnectCallback, address); | 51 return base::Bind(&NetLogUDPConnectCallback, address); |
50 } | 52 } |
51 | 53 |
52 } // namespace net | 54 } // namespace net |
OLD | NEW |