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 scoped_ptr
<base::Value
> NetLogSocketErrorCallback(
20 NetLogCaptureMode
/* capture_mode */) {
21 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
22 dict
->SetInteger("net_error", net_error
);
23 dict
->SetInteger("os_error", os_error
);
27 scoped_ptr
<base::Value
> NetLogHostPortPairCallback(
28 const HostPortPair
* host_and_port
,
29 NetLogCaptureMode
/* capture_mode */) {
30 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
31 dict
->SetString("host_and_port", host_and_port
->ToString());
35 scoped_ptr
<base::Value
> NetLogIPEndPointCallback(
36 const IPEndPoint
* address
,
37 NetLogCaptureMode
/* capture_mode */) {
38 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
39 dict
->SetString("address", address
->ToString());
43 scoped_ptr
<base::Value
> NetLogSourceAddressCallback(
44 const struct sockaddr
* net_address
,
45 socklen_t address_len
,
46 NetLogCaptureMode
/* capture_mode */) {
47 scoped_ptr
<base::DictionaryValue
> dict(new base::DictionaryValue());
48 dict
->SetString("source_address",
49 NetAddressToStringWithPort(net_address
, address_len
));
55 NetLog::ParametersCallback
CreateNetLogSocketErrorCallback(int net_error
,
57 return base::Bind(&NetLogSocketErrorCallback
, net_error
, os_error
);
60 NetLog::ParametersCallback
CreateNetLogHostPortPairCallback(
61 const HostPortPair
* host_and_port
) {
62 return base::Bind(&NetLogHostPortPairCallback
, host_and_port
);
65 NetLog::ParametersCallback
CreateNetLogIPEndPointCallback(
66 const IPEndPoint
* address
) {
67 return base::Bind(&NetLogIPEndPointCallback
, address
);
70 NetLog::ParametersCallback
CreateNetLogSourceAddressCallback(
71 const struct sockaddr
* net_address
,
72 socklen_t address_len
) {
73 return base::Bind(&NetLogSourceAddressCallback
, net_address
, address_len
);