| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "net/base/ip_endpoint.h" | 7 #include "net/base/ip_endpoint.h" |
| 8 #include "net/udp/udp_data_transfer_param.h" | 8 #include "net/udp/udp_data_transfer_param.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 UDPDataTransferNetLogParam::UDPDataTransferNetLogParam( | 12 UDPDataTransferNetLogParam::UDPDataTransferNetLogParam( |
| 13 int byte_count, | 13 int byte_count, |
| 14 const char* bytes, | 14 const char* bytes, |
| 15 bool log_bytes, | 15 bool log_bytes, |
| 16 const IPEndPoint* address) | 16 const IPEndPoint* address) |
| 17 : byte_count_(byte_count), | 17 : byte_count_(byte_count), |
| 18 hex_encoded_bytes_(log_bytes ? base::HexEncode(bytes, byte_count) : "") { | 18 hex_encoded_bytes_(log_bytes ? base::HexEncode(bytes, byte_count) : "") { |
| 19 if (address) | 19 if (address) |
| 20 address_.reset(new IPEndPoint(*address)); | 20 address_.reset(new IPEndPoint(*address)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 UDPDataTransferNetLogParam::~UDPDataTransferNetLogParam() { | |
| 24 } | |
| 25 | |
| 26 Value* UDPDataTransferNetLogParam::ToValue() const { | 23 Value* UDPDataTransferNetLogParam::ToValue() const { |
| 27 DictionaryValue* dict = new DictionaryValue(); | 24 DictionaryValue* dict = new DictionaryValue(); |
| 28 dict->SetInteger("byte_count", byte_count_); | 25 dict->SetInteger("byte_count", byte_count_); |
| 29 if (!hex_encoded_bytes_.empty()) | 26 if (!hex_encoded_bytes_.empty()) |
| 30 dict->SetString("hex_encoded_bytes", hex_encoded_bytes_); | 27 dict->SetString("hex_encoded_bytes", hex_encoded_bytes_); |
| 31 if (address_.get()) | 28 if (address_.get()) |
| 32 dict->SetString("address", address_->ToString()); | 29 dict->SetString("address", address_->ToString()); |
| 33 return dict; | 30 return dict; |
| 34 } | 31 } |
| 35 | 32 |
| 33 UDPDataTransferNetLogParam::~UDPDataTransferNetLogParam() {} |
| 34 |
| 36 } // namespace net | 35 } // namespace net |
| OLD | NEW |