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

Unified Diff: net/base/capturing_net_log.cc

Issue 1746012: More cleanup of net_log.h (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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/base/capturing_net_log.h ('k') | net/base/host_resolver_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/capturing_net_log.cc
===================================================================
--- net/base/capturing_net_log.cc (revision 45736)
+++ net/base/capturing_net_log.cc (working copy)
@@ -2,154 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/base/net_log.h"
-#include "base/logging.h"
-#include "base/string_util.h"
+#include "net/base/capturing_net_log.h"
namespace net {
-// static
-const char* NetLog::EventTypeToString(EventType event) {
- switch (event) {
-#define EVENT_TYPE(label) case TYPE_ ## label: return #label;
-#include "net/base/net_log_event_type_list.h"
-#undef EVENT_TYPE
- }
- return NULL;
+CapturingNetLog::CapturingNetLog(size_t max_num_entries)
+ : next_id_(0), max_num_entries_(max_num_entries) {
}
-// static
-std::vector<NetLog::EventType> NetLog::GetAllEventTypes() {
- std::vector<NetLog::EventType> types;
-#define EVENT_TYPE(label) types.push_back(TYPE_ ## label);
-#include "net/base/net_log_event_type_list.h"
-#undef EVENT_TYPE
- return types;
-}
-
-void BoundNetLog::AddEntry(NetLog::EventType type,
- NetLog::EventPhase phase,
- NetLog::EventParameters* extra_parameters) const {
- if (net_log_) {
- net_log_->AddEntry(type, base::TimeTicks::Now(), source_, phase,
- extra_parameters);
- }
-}
-
-void BoundNetLog::AddEntryWithTime(
- NetLog::EventType type,
- const base::TimeTicks& time,
- NetLog::EventPhase phase,
- NetLog::EventParameters* extra_parameters) const {
- if (net_log_) {
- net_log_->AddEntry(type, time, source_, phase, extra_parameters);
- }
-}
-
-bool BoundNetLog::HasListener() const {
- if (net_log_)
- return net_log_->HasListener();
- return false;
-}
-
-void BoundNetLog::AddEvent(NetLog::EventType event_type) const {
- AddEventWithParameters(event_type, NULL);
-}
-
-void BoundNetLog::AddEventWithParameters(
- NetLog::EventType event_type,
- NetLog::EventParameters* params) const {
- AddEntry(event_type, NetLog::PHASE_NONE, params);
-}
-
-void BoundNetLog::AddEventWithInteger(NetLog::EventType event_type,
- int integer) const {
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
- AddEventWithParameters(event_type, params);
-}
-
-void BoundNetLog::BeginEvent(NetLog::EventType event_type) const {
- BeginEventWithParameters(event_type, NULL);
-}
-
-void BoundNetLog::BeginEventWithParameters(
- NetLog::EventType event_type,
- NetLog::EventParameters* params) const {
- AddEntry(event_type, NetLog::PHASE_BEGIN, params);
-}
-
-void BoundNetLog::BeginEventWithString(NetLog::EventType event_type,
- const std::string& string) const {
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogStringParameter(string);
- BeginEventWithParameters(event_type, params);
-}
-
-void BoundNetLog::BeginEventWithInteger(NetLog::EventType event_type,
- int integer) const {
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
- BeginEventWithParameters(event_type, params);
-}
-
-void BoundNetLog::EndEvent(NetLog::EventType event_type) const {
- EndEventWithParameters(event_type, NULL);
-}
-
-void BoundNetLog::EndEventWithParameters(
- NetLog::EventType event_type,
- NetLog::EventParameters* params) const {
- AddEntry(event_type, NetLog::PHASE_END, params);
-}
-
-void BoundNetLog::EndEventWithInteger(NetLog::EventType event_type,
- int integer) const {
- scoped_refptr<NetLog::EventParameters> params =
- new NetLogIntegerParameter(integer);
- 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) {
- if (!net_log)
- return BoundNetLog();
-
- NetLog::Source source(source_type, net_log->NextID());
- return BoundNetLog(source, net_log);
-}
-
-NetLogStringParameter::NetLogStringParameter(const std::string& value)
- : value_(value) {
-}
-
-std::string NetLogIntegerParameter::ToString() const {
- return IntToString(value_);
-}
-
-std::string NetLogStringLiteralParameter::ToString() const {
- return std::string(value_);
-}
-
void CapturingNetLog::AddEntry(EventType type,
const base::TimeTicks& time,
const Source& source,
« no previous file with comments | « net/base/capturing_net_log.h ('k') | net/base/host_resolver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698