summaryrefslogtreecommitdiffstats
path: root/net/base/net_log.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 23:20:45 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 23:20:45 +0000
commitd13f51bc832e8e7965e92f5aa4b16b8c10c3f913 (patch)
treed5a1a413bf8716befbae7d056cd8c6194eed5a98 /net/base/net_log.cc
parentf2286c23e17c0012d53800a5ef28975b6e22393a (diff)
downloadchromium_src-d13f51bc832e8e7965e92f5aa4b16b8c10c3f913.zip
chromium_src-d13f51bc832e8e7965e92f5aa4b16b8c10c3f913.tar.gz
chromium_src-d13f51bc832e8e7965e92f5aa4b16b8c10c3f913.tar.bz2
Cleanup: Address some of the todos in net_log.h
- Get rid of the AddString() and AddStringLiteral() methods. - Make EventParameters able to serialize to JSON, instead of a string. BUG=37421 Review URL: http://codereview.chromium.org/1716007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_log.cc')
-rw-r--r--net/base/net_log.cc64
1 files changed, 32 insertions, 32 deletions
diff --git a/net/base/net_log.cc b/net/base/net_log.cc
index c9ef380..c46214f 100644
--- a/net/base/net_log.cc
+++ b/net/base/net_log.cc
@@ -5,6 +5,7 @@
#include "net/base/net_log.h"
#include "base/logging.h"
#include "base/string_util.h"
+#include "base/values.h"
namespace net {
@@ -63,9 +64,18 @@ void BoundNetLog::AddEventWithParameters(
}
void BoundNetLog::AddEventWithInteger(NetLog::EventType event_type,
- int integer) const {
+ const char* name,
+ int value) const {
scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
+ new NetLogIntegerParameter(name, value);
+ AddEventWithParameters(event_type, params);
+}
+
+void BoundNetLog::AddEventWithString(NetLog::EventType event_type,
+ const char* name,
+ const std::string& value) const {
+ scoped_refptr<NetLog::EventParameters> params =
+ new NetLogStringParameter(name, value);
AddEventWithParameters(event_type, params);
}
@@ -80,16 +90,18 @@ void BoundNetLog::BeginEventWithParameters(
}
void BoundNetLog::BeginEventWithString(NetLog::EventType event_type,
- const std::string& string) const {
+ const char* name,
+ const std::string& value) const {
scoped_refptr<NetLog::EventParameters> params =
- new NetLogStringParameter(string);
+ new NetLogStringParameter(name, value);
BeginEventWithParameters(event_type, params);
}
void BoundNetLog::BeginEventWithInteger(NetLog::EventType event_type,
- int integer) const {
+ const char* name,
+ int value) const {
scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
+ new NetLogIntegerParameter(name, value);
BeginEventWithParameters(event_type, params);
}
@@ -104,30 +116,13 @@ void BoundNetLog::EndEventWithParameters(
}
void BoundNetLog::EndEventWithInteger(NetLog::EventType event_type,
- int integer) const {
+ const char* name,
+ int value) const {
scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
+ new NetLogIntegerParameter(name, value);
EndEventWithParameters(event_type, params);
}
-void BoundNetLog::AddString(const std::string& string) const {
- // We pass TYPE_TODO_STRING since we have no event type to associate this
- // with. (AddString() is deprecated, and should be replaced with
- // AddEventWithParameters()).
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogStringParameter(string);
- AddEventWithParameters(NetLog::TYPE_TODO_STRING, params);
-}
-
-void BoundNetLog::AddStringLiteral(const char* literal) const {
- // We pass TYPE_TODO_STRING_LITERAL since we have no event type to associate
- // this with. (AddString() is deprecated, and should be replaced with
- // AddEventWithParameters()).
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogStringLiteralParameter(literal);
- AddEventWithParameters(NetLog::TYPE_TODO_STRING_LITERAL, params);
-}
-
// static
BoundNetLog BoundNetLog::Make(NetLog* net_log,
NetLog::SourceType source_type) {
@@ -138,16 +133,21 @@ BoundNetLog BoundNetLog::Make(NetLog* net_log,
return BoundNetLog(source, net_log);
}
-NetLogStringParameter::NetLogStringParameter(const std::string& value)
- : value_(value) {
+NetLogStringParameter::NetLogStringParameter(const char* name,
+ const std::string& value)
+ : name_(name), value_(value) {
}
-std::string NetLogIntegerParameter::ToString() const {
- return IntToString(value_);
+Value* NetLogIntegerParameter::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetInteger(ASCIIToWide(name_), value_);
+ return dict;
}
-std::string NetLogStringLiteralParameter::ToString() const {
- return std::string(value_);
+Value* NetLogStringParameter::ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString(ASCIIToWide(name_), value_);
+ return dict;
}
void CapturingNetLog::AddEntry(EventType type,