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