summaryrefslogtreecommitdiffstats
path: root/net/base/net_log.h
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
committerIain Merrick <husky@google.com>2010-10-19 14:37:37 +0100
commit3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch)
tree7784b988ef1698cb6967ea1bdf07616237716c6c /net/base/net_log.h
parentefc8475837ec58186051f23bb03542620424f6ce (diff)
downloadexternal_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz
external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used. Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'net/base/net_log.h')
-rw-r--r--net/base/net_log.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/net/base/net_log.h b/net/base/net_log.h
index 266b93a..c97eb1a 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -4,6 +4,7 @@
#ifndef NET_BASE_NET_LOG_H_
#define NET_BASE_NET_LOG_H_
+#pragma once
#include <string>
#include <vector>
@@ -68,7 +69,10 @@ class NetLog {
Source() : type(SOURCE_NONE), id(kInvalidId) {}
Source(SourceType type, uint32 id) : type(type), id(id) {}
- bool is_valid() { return id != kInvalidId; }
+ bool is_valid() const { return id != kInvalidId; }
+
+ // The caller takes ownership of the returned Value*.
+ Value* ToValue() const;
SourceType type;
uint32 id;
@@ -91,6 +95,15 @@ class NetLog {
DISALLOW_COPY_AND_ASSIGN(EventParameters);
};
+ // Specifies the granularity of events that should be emitted to the log.
+ enum LogLevel {
+ // Log everything possible, even if it is slow and memory expensive.
+ LOG_ALL,
+
+ // Only log events which are cheap, and don't consume much memory.
+ LOG_BASIC,
+ };
+
NetLog() {}
virtual ~NetLog() {}
@@ -113,8 +126,9 @@ class NetLog {
// Returns a unique ID which can be used as a source ID.
virtual uint32 NextID() = 0;
- // Returns true if more complicated messages should be sent to the log.
- virtual bool HasListener() const = 0;
+ // Returns the logging level for this NetLog. This is used to avoid computing
+ // and saving expensive log entries.
+ virtual LogLevel GetLogLevel() const = 0;
// Returns a C-String symbolic name for |event_type|.
static const char* EventTypeToString(EventType event_type);
@@ -122,6 +136,21 @@ class NetLog {
// Returns a list of all the available EventTypes.
static std::vector<EventType> GetAllEventTypes();
+ // Returns a C-String symbolic name for |source_type|.
+ static const char* SourceTypeToString(SourceType source_type);
+
+ // Returns a C-String symbolic name for |event_phase|.
+ static const char* EventPhaseToString(EventPhase event_phase);
+
+ // Serializes the specified event to a DictionaryValue.
+ // If |use_strings| is true, uses strings rather than numeric ids.
+ static Value* EntryToDictionaryValue(net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ net::NetLog::EventParameters* params,
+ bool use_strings);
+
private:
DISALLOW_COPY_AND_ASSIGN(NetLog);
};
@@ -158,7 +187,10 @@ class BoundNetLog {
void EndEvent(NetLog::EventType event_type,
const scoped_refptr<NetLog::EventParameters>& params) const;
- bool HasListener() const;
+ NetLog::LogLevel GetLogLevel() const;
+
+ // Returns true if the log level is LOG_ALL.
+ bool IsLoggingAll() 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.
@@ -178,6 +210,7 @@ class NetLogStringParameter : public NetLog::EventParameters {
public:
// |name| must be a string literal.
NetLogStringParameter(const char* name, const std::string& value);
+ virtual ~NetLogStringParameter();
const std::string& value() const {
return value_;