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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/udp/udp_net_log_parameters.cc
===================================================================
--- net/udp/udp_net_log_parameters.cc (revision 141669)
+++ net/udp/udp_net_log_parameters.cc (working copy)
@@ -2,34 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "net/udp/udp_net_log_parameters.h"
+
+#include "base/bind.h"
#include "base/string_number_conversions.h"
#include "base/values.h"
#include "net/base/ip_endpoint.h"
-#include "net/udp/udp_data_transfer_param.h"
namespace net {
-UDPDataTransferNetLogParam::UDPDataTransferNetLogParam(
- int byte_count,
- const char* bytes,
- bool log_bytes,
- const IPEndPoint* address)
- : byte_count_(byte_count),
- hex_encoded_bytes_(log_bytes ? base::HexEncode(bytes, byte_count) : "") {
+namespace {
+
+Value* NetLogUDPDataTranferCallback(int byte_count,
+ const char* bytes,
+ const IPEndPoint* address,
+ NetLog::LogLevel log_level) {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetInteger("byte_count", byte_count);
+ if (NetLog::IsLoggingBytes(log_level))
+ dict->SetString("hex_encoded_bytes", base::HexEncode(bytes, byte_count));
if (address)
- address_.reset(new IPEndPoint(*address));
+ dict->SetString("address", address->ToString());
+ return dict;
}
-Value* UDPDataTransferNetLogParam::ToValue() const {
+Value* NetLogUDPConnectCallback(const IPEndPoint* address,
+ NetLog::LogLevel /* log_level */) {
DictionaryValue* dict = new DictionaryValue();
- dict->SetInteger("byte_count", byte_count_);
- if (!hex_encoded_bytes_.empty())
- dict->SetString("hex_encoded_bytes", hex_encoded_bytes_);
- if (address_.get())
- dict->SetString("address", address_->ToString());
+ dict->SetString("address", address->ToString());
return dict;
}
-UDPDataTransferNetLogParam::~UDPDataTransferNetLogParam() {}
+} // namespace
+NetLog::ParametersCallback CreateNetLogUDPDataTranferCallback(
+ int byte_count,
+ const char* bytes,
+ const IPEndPoint* address) {
+ DCHECK(bytes);
+ return base::Bind(&NetLogUDPDataTranferCallback, byte_count, bytes, address);
+}
+
+NetLog::ParametersCallback CreateNetLogUDPConnectCallback(
+ const IPEndPoint* address) {
+ DCHECK(address);
+ return base::Bind(&NetLogUDPConnectCallback, address);
+}
+
} // namespace net
« 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