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

Unified Diff: net/base/net_log.h

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/host_resolver_impl.cc ('k') | net/base/net_log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_log.h
===================================================================
--- net/base/net_log.h (revision 45828)
+++ net/base/net_log.h (working copy)
@@ -12,7 +12,6 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
-#include "net/base/net_log.h"
class Value;
@@ -34,8 +33,6 @@
// TODO(eroman): Remove the 'const' qualitifer from the BoundNetLog methods.
// TODO(eroman): Remove NetLogUtil. Pretty printing should only be done from
// javascript, and should be very context-aware.
-// TODO(eroman): Move Capturing*NetLog to its own file. (And eventually remove
-// all the consumers of it).
// TODO(eroman): Make the DNS jobs emit directly into the NetLog.
// TODO(eroman): Start a new Source each time URLRequest redirects
// (simpler to reason about each as a separate entity).
@@ -149,37 +146,29 @@
: source_(source), net_log_(net_log) {
}
+ // Convenience methods that call through to the NetLog, passing in the
+ // currently bound source.
void AddEntry(NetLog::EventType type,
NetLog::EventPhase phase,
- NetLog::EventParameters* extra_parameters) const;
+ const scoped_refptr<NetLog::EventParameters>& params) const;
- void AddEntryWithTime(NetLog::EventType type,
- const base::TimeTicks& time,
- NetLog::EventPhase phase,
- NetLog::EventParameters* extra_parameters) const;
+ void AddEntryWithTime(
+ NetLog::EventType type,
+ const base::TimeTicks& time,
+ NetLog::EventPhase phase,
+ const scoped_refptr<NetLog::EventParameters>& params) const;
// Convenience methods that call through to the NetLog, passing in the
- // currently bound source.
- void AddEvent(NetLog::EventType event_type) const;
- void AddEventWithParameters(NetLog::EventType event_type,
- NetLog::EventParameters* params) const;
+ // currently bound source, current time, and a fixed "capture phase"
+ // (begin, end, or none).
+ void AddEvent(NetLog::EventType event_type,
+ const scoped_refptr<NetLog::EventParameters>& params) const;
+ void BeginEvent(NetLog::EventType event_type,
+ const scoped_refptr<NetLog::EventParameters>& params) const;
+ void EndEvent(NetLog::EventType event_type,
+ const scoped_refptr<NetLog::EventParameters>& params) const;
+
bool HasListener() const;
- void BeginEvent(NetLog::EventType event_type) const;
- void BeginEventWithParameters(NetLog::EventType event_type,
- NetLog::EventParameters* params) const;
- void BeginEventWithString(NetLog::EventType event_type,
- const char* name, const std::string& value) const;
- void BeginEventWithInteger(NetLog::EventType event_type,
- const char* name, int value) const;
- void AddEventWithInteger(NetLog::EventType event_type,
- const char* name, int value) const;
- void AddEventWithString(NetLog::EventType event_type,
- const char* name, const std::string& value) const;
- void EndEvent(NetLog::EventType event_type) const;
- void EndEventWithParameters(NetLog::EventType event_type,
- NetLog::EventParameters* params) const;
- void EndEventWithInteger(NetLog::EventType event_type,
- const char* name, int value) const;
// Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care
// of creating a unique source ID, and handles the case of NULL net_log.
@@ -230,96 +219,6 @@
const int value_;
};
-// CapturingNetLog is an implementation of NetLog that saves messages to a
-// bounded buffer.
-class CapturingNetLog : public NetLog {
- public:
- struct Entry {
- Entry(EventType type,
- const base::TimeTicks& time,
- Source source,
- EventPhase phase,
- EventParameters* extra_parameters)
- : type(type), time(time), source(source), phase(phase),
- extra_parameters(extra_parameters) {
- }
-
- EventType type;
- base::TimeTicks time;
- Source source;
- EventPhase phase;
- scoped_refptr<EventParameters> extra_parameters;
- };
-
- // Ordered set of entries that were logged.
- typedef std::vector<Entry> EntryList;
-
- enum { kUnbounded = -1 };
-
- // Creates a CapturingNetLog that logs a maximum of |max_num_entries|
- // messages.
- explicit CapturingNetLog(size_t max_num_entries)
- : next_id_(0), max_num_entries_(max_num_entries) {}
-
- // NetLog implementation:
- virtual void AddEntry(EventType type,
- const base::TimeTicks& time,
- const Source& source,
- EventPhase phase,
- EventParameters* extra_parameters);
- virtual uint32 NextID();
- virtual bool HasListener() const { return true; }
-
- // Returns the list of all entries in the log.
- const EntryList& entries() const { return entries_; }
-
- void Clear();
-
- private:
- uint32 next_id_;
- size_t max_num_entries_;
- EntryList entries_;
-
- DISALLOW_COPY_AND_ASSIGN(CapturingNetLog);
-};
-
-// Helper class that exposes a similar API as BoundNetLog, but uses a
-// CapturingNetLog rather than the more generic NetLog.
-//
-// CapturingBoundNetLog can easily be converted to a BoundNetLog using the
-// bound() method.
-class CapturingBoundNetLog {
- public:
- CapturingBoundNetLog(const NetLog::Source& source, CapturingNetLog* net_log)
- : source_(source), capturing_net_log_(net_log) {
- }
-
- explicit CapturingBoundNetLog(size_t max_num_entries)
- : capturing_net_log_(new CapturingNetLog(max_num_entries)) {}
-
- // The returned BoundNetLog is only valid while |this| is alive.
- BoundNetLog bound() const {
- return BoundNetLog(source_, capturing_net_log_.get());
- }
-
- // Returns the list of all entries in the log.
- const CapturingNetLog::EntryList& entries() const {
- return capturing_net_log_->entries();
- }
-
- void Clear();
-
- // Sends all of captured messages to |net_log|, using the same source ID
- // as |net_log|.
- void AppendTo(const BoundNetLog& net_log) const;
-
- private:
- NetLog::Source source_;
- scoped_ptr<CapturingNetLog> capturing_net_log_;
-
- DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog);
-};
-
} // namespace net
#endif // NET_BASE_NET_LOG_H_
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/base/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698