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/socket/socket_net_log_params.h"
8 #include "base/values.h"
9 #include "net/base/host_port_pair.h"
10 #include "net/base/ip_endpoint.h"
11 #include "net/base/net_util.h"
17 base::Value
* NetLogSocketErrorCallback(int net_error
,
19 NetLogCaptureMode
/* capture_mode */) {
20 base::DictionaryValue
* dict
= new base::DictionaryValue();
21 dict
->SetInteger("net_error", net_error
);
22 dict
->SetInteger("os_error", os_error
);
26 base::Value
* NetLogHostPortPairCallback(const HostPortPair
* host_and_port
,
27 NetLogCaptureMode
/* capture_mode */) {
28 base::DictionaryValue
* dict
= new base::DictionaryValue();
29 dict
->SetString("host_and_port", host_and_port
->ToString());
33 base::Value
* NetLogIPEndPointCallback(const IPEndPoint
* address
,
34 NetLogCaptureMode
/* capture_mode */) {
35 base::DictionaryValue
* dict
= new base::DictionaryValue();
36 dict
->SetString("address", address
->ToString());
40 base::Value
* NetLogSourceAddressCallback(const struct sockaddr
* net_address
,
41 socklen_t address_len
,
42 NetLogCaptureMode
/* capture_mode */) {
43 base::DictionaryValue
* dict
= new base::DictionaryValue();
44 dict
->SetString("source_address",
45 NetAddressToStringWithPort(net_address
, address_len
));
51 NetLog::ParametersCallback
CreateNetLogSocketErrorCallback(int net_error
,
53 return base::Bind(&NetLogSocketErrorCallback
, net_error
, os_error
);
56 NetLog::ParametersCallback
CreateNetLogHostPortPairCallback(
57 const HostPortPair
* host_and_port
) {
58 return base::Bind(&NetLogHostPortPairCallback
, host_and_port
);
61 NetLog::ParametersCallback
CreateNetLogIPEndPointCallback(
62 const IPEndPoint
* address
) {
63 return base::Bind(&NetLogIPEndPointCallback
, address
);
66 NetLog::ParametersCallback
CreateNetLogSourceAddressCallback(
67 const struct sockaddr
* net_address
,
68 socklen_t address_len
) {
69 return base::Bind(&NetLogSourceAddressCallback
, net_address
, address_len
);