| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/udp/udp_net_log_parameters.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/values.h" | |
| 12 #include "net/base/ip_endpoint.h" | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 std::unique_ptr<base::Value> NetLogUDPDataTranferCallback( | |
| 19 int byte_count, | |
| 20 const char* bytes, | |
| 21 const IPEndPoint* address, | |
| 22 NetLogCaptureMode capture_mode) { | |
| 23 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | |
| 24 dict->SetInteger("byte_count", byte_count); | |
| 25 if (capture_mode.include_socket_bytes()) | |
| 26 dict->SetString("hex_encoded_bytes", base::HexEncode(bytes, byte_count)); | |
| 27 if (address) | |
| 28 dict->SetString("address", address->ToString()); | |
| 29 return std::move(dict); | |
| 30 } | |
| 31 | |
| 32 std::unique_ptr<base::Value> NetLogUDPConnectCallback( | |
| 33 const IPEndPoint* address, | |
| 34 NetworkChangeNotifier::NetworkHandle network, | |
| 35 NetLogCaptureMode /* capture_mode */) { | |
| 36 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | |
| 37 dict->SetString("address", address->ToString()); | |
| 38 if (network != NetworkChangeNotifier::kInvalidNetworkHandle) | |
| 39 dict->SetInteger("bound_to_network", network); | |
| 40 return std::move(dict); | |
| 41 } | |
| 42 | |
| 43 } // namespace | |
| 44 | |
| 45 NetLogParametersCallback CreateNetLogUDPDataTranferCallback( | |
| 46 int byte_count, | |
| 47 const char* bytes, | |
| 48 const IPEndPoint* address) { | |
| 49 DCHECK(bytes); | |
| 50 return base::Bind(&NetLogUDPDataTranferCallback, byte_count, bytes, address); | |
| 51 } | |
| 52 | |
| 53 NetLogParametersCallback CreateNetLogUDPConnectCallback( | |
| 54 const IPEndPoint* address, | |
| 55 NetworkChangeNotifier::NetworkHandle network) { | |
| 56 DCHECK(address); | |
| 57 return base::Bind(&NetLogUDPConnectCallback, address, network); | |
| 58 } | |
| 59 | |
| 60 } // namespace net | |
| OLD | NEW |