Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: net/udp/udp_net_log_parameters.cc

Issue 10546133: NetLogEventParameter to Callback refactoring 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync? Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/udp/udp_net_log_parameters.h ('k') | net/udp/udp_socket_libevent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
6
7 #include "base/bind.h"
5 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
6 #include "base/values.h" 9 #include "base/values.h"
7 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
8 #include "net/udp/udp_data_transfer_param.h"
9 11
10 namespace net { 12 namespace net {
11 13
12 UDPDataTransferNetLogParam::UDPDataTransferNetLogParam( 14 namespace {
13 int byte_count, 15
14 const char* bytes, 16 Value* NetLogUDPDataTranferCallback(int byte_count,
15 bool log_bytes, 17 const char* bytes,
16 const IPEndPoint* address) 18 const IPEndPoint* address,
17 : byte_count_(byte_count), 19 NetLog::LogLevel log_level) {
18 hex_encoded_bytes_(log_bytes ? base::HexEncode(bytes, byte_count) : "") { 20 DictionaryValue* dict = new 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));
19 if (address) 24 if (address)
20 address_.reset(new IPEndPoint(*address)); 25 dict->SetString("address", address->ToString());
21 }
22
23 Value* UDPDataTransferNetLogParam::ToValue() const {
24 DictionaryValue* dict = new DictionaryValue();
25 dict->SetInteger("byte_count", byte_count_);
26 if (!hex_encoded_bytes_.empty())
27 dict->SetString("hex_encoded_bytes", hex_encoded_bytes_);
28 if (address_.get())
29 dict->SetString("address", address_->ToString());
30 return dict; 26 return dict;
31 } 27 }
32 28
33 UDPDataTransferNetLogParam::~UDPDataTransferNetLogParam() {} 29 Value* NetLogUDPConnectCallback(const IPEndPoint* address,
30 NetLog::LogLevel /* log_level */) {
31 DictionaryValue* dict = new DictionaryValue();
32 dict->SetString("address", address->ToString());
33 return dict;
34 }
35
36 } // namespace
37
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);
44 }
45
46 NetLog::ParametersCallback CreateNetLogUDPConnectCallback(
47 const IPEndPoint* address) {
48 DCHECK(address);
49 return base::Bind(&NetLogUDPConnectCallback, address);
50 }
34 51
35 } // namespace net 52 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_net_log_parameters.h ('k') | net/udp/udp_socket_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698