Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / udp / udp_net_log_parameters.cc
blobc258823f17755a59bc7ded082055be803d529707
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"
7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/values.h"
10 #include "net/base/ip_endpoint.h"
12 namespace net {
14 namespace {
16 base::Value* NetLogUDPDataTranferCallback(int byte_count,
17 const char* bytes,
18 const IPEndPoint* address,
19 NetLog::LogLevel log_level) {
20 base::DictionaryValue* dict = new base::DictionaryValue();
21 dict->SetInteger("byte_count", byte_count);
22 if (NetLog::IsLoggingBytes(log_level))
23 dict->SetString("hex_encoded_bytes", base::HexEncode(bytes, byte_count));
24 if (address)
25 dict->SetString("address", address->ToString());
26 return dict;
29 base::Value* NetLogUDPConnectCallback(const IPEndPoint* address,
30 NetLog::LogLevel /* log_level */) {
31 base::DictionaryValue* dict = new base::DictionaryValue();
32 dict->SetString("address", address->ToString());
33 return dict;
36 } // namespace
38 NetLog::ParametersCallback CreateNetLogUDPDataTranferCallback(
39 int byte_count,
40 const char* bytes,
41 const IPEndPoint* address) {
42 DCHECK(bytes);
43 return base::Bind(&NetLogUDPDataTranferCallback, byte_count, bytes, address);
46 NetLog::ParametersCallback CreateNetLogUDPConnectCallback(
47 const IPEndPoint* address) {
48 DCHECK(address);
49 return base::Bind(&NetLogUDPConnectCallback, address);
52 } // namespace net