[Android] Add base_junit_tests to VALID_TESTS in bb_device_steps.
[chromium-blink-merge.git] / net / socket / socket_net_log_params.cc
blob3dd6595525d60cb7efc45d6264d83be78655a4b1
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"
7 #include "base/bind.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"
13 namespace net {
15 namespace {
17 base::Value* NetLogSocketErrorCallback(int net_error,
18 int os_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);
23 return dict;
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());
30 return dict;
33 base::Value* NetLogIPEndPointCallback(const IPEndPoint* address,
34 NetLogCaptureMode /* capture_mode */) {
35 base::DictionaryValue* dict = new base::DictionaryValue();
36 dict->SetString("address", address->ToString());
37 return dict;
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));
46 return dict;
49 } // namespace
51 NetLog::ParametersCallback CreateNetLogSocketErrorCallback(int net_error,
52 int os_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);
72 } // namespace net