Index: net/socket/socket_net_log_params.cc |
=================================================================== |
--- net/socket/socket_net_log_params.cc (revision 141995) |
+++ net/socket/socket_net_log_params.cc (working copy) |
@@ -2,24 +2,70 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "net/socket/socket_error_params.h" |
+#include "net/socket/socket_net_log_params.h" |
+#include "base/bind.h" |
#include "base/values.h" |
+#include "net/base/host_port_pair.h" |
+#include "net/base/ip_endpoint.h" |
namespace net { |
-SocketErrorParams::SocketErrorParams(int net_error, int os_error) |
- : net_error_(net_error), |
- os_error_(os_error) { |
+namespace { |
+ |
+Value* NetLogSocketErrorCallback(int net_error, |
+ int os_error, |
+ NetLog::LogLevel /* log_level */) { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ dict->SetInteger("net_error", net_error); |
+ dict->SetInteger("os_error", os_error); |
+ return dict; |
} |
-Value* SocketErrorParams::ToValue() const { |
+Value* NetLogHostPortPairCallback(const HostPortPair* host_and_port, |
+ NetLog::LogLevel /* log_level */) { |
DictionaryValue* dict = new DictionaryValue(); |
- dict->SetInteger("net_error", net_error_); |
- dict->SetInteger("os_error", os_error_); |
+ dict->SetString("host_and_port", host_and_port->ToString()); |
return dict; |
} |
-SocketErrorParams::~SocketErrorParams() {} |
+Value* NetLogIPEndPointCallback(const IPEndPoint* address, |
+ NetLog::LogLevel /* log_level */) { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ dict->SetString("address", address->ToString()); |
+ return dict; |
+} |
+Value* NetLogSourceAddressCallback(const struct sockaddr* net_address, |
+ socklen_t address_len, |
+ NetLog::LogLevel /* log_level */) { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ dict->SetString("source_address", |
+ NetAddressToStringWithPort(net_address, address_len)); |
+ return dict; |
+} |
+ |
+} // namespace |
+ |
+NetLog::ParametersCallback CreateNetLogSocketErrorCallback(int net_error, |
+ int os_error) { |
+ return base::Bind(&NetLogSocketErrorCallback, net_error, os_error); |
+} |
+ |
+NetLog::ParametersCallback CreateNetLogHostPortPairCallback( |
+ const HostPortPair* host_and_port) { |
+ return base::Bind(&NetLogHostPortPairCallback, host_and_port); |
+} |
+ |
+NetLog::ParametersCallback CreateNetLogIPEndPointCallback( |
+ const IPEndPoint* address) { |
+ return base::Bind(&NetLogIPEndPointCallback, address); |
+} |
+ |
+NetLog::ParametersCallback CreateNetLogSourceAddressCallback( |
+ const struct sockaddr* net_address, |
+ socklen_t address_len) { |
+ return base::Bind(&NetLogSourceAddressCallback, net_address, address_len); |
+} |
+ |
} // namespace net |