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.
5 #include "net/udp/udp_net_log_parameters.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/values.h"
10 #include "net/base/ip_endpoint.h"
16 scoped_ptr
<base::Value
> NetLogUDPDataTranferCallback(
19 const IPEndPoint
* address
,
20 NetLogCaptureMode capture_mode
) {
21 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
22 dict
->SetInteger("byte_count", byte_count
);
23 if (capture_mode
.include_socket_bytes())
24 dict
->SetString("hex_encoded_bytes", base::HexEncode(bytes
, byte_count
));
26 dict
->SetString("address", address
->ToString());
30 scoped_ptr
<base::Value
> NetLogUDPConnectCallback(
31 const IPEndPoint
* address
,
32 NetLogCaptureMode
/* capture_mode */) {
33 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
34 dict
->SetString("address", address
->ToString());
40 NetLog::ParametersCallback
CreateNetLogUDPDataTranferCallback(
43 const IPEndPoint
* address
) {
45 return base::Bind(&NetLogUDPDataTranferCallback
, byte_count
, bytes
, address
);
48 NetLog::ParametersCallback
CreateNetLogUDPConnectCallback(
49 const IPEndPoint
* address
) {
51 return base::Bind(&NetLogUDPConnectCallback
, address
);