summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
Diffstat (limited to 'net/base')
-rw-r--r--net/base/capturing_net_log.h2
-rw-r--r--net/base/forwarding_net_log.cc4
-rw-r--r--net/base/forwarding_net_log.h2
-rw-r--r--net/base/net_log.cc10
-rw-r--r--net/base/net_log.h19
5 files changed, 27 insertions, 10 deletions
diff --git a/net/base/capturing_net_log.h b/net/base/capturing_net_log.h
index 9a5addd..9669445 100644
--- a/net/base/capturing_net_log.h
+++ b/net/base/capturing_net_log.h
@@ -53,7 +53,7 @@ class CapturingNetLog : public NetLog {
EventPhase phase,
EventParameters* extra_parameters);
virtual uint32 NextID();
- virtual bool HasListener() const { return true; }
+ virtual LogLevel GetLogLevel() const { return LOG_ALL; }
// Returns the list of all entries in the log.
const EntryList& entries() const { return entries_; }
diff --git a/net/base/forwarding_net_log.cc b/net/base/forwarding_net_log.cc
index dfc8700..efe6eff 100644
--- a/net/base/forwarding_net_log.cc
+++ b/net/base/forwarding_net_log.cc
@@ -86,10 +86,10 @@ uint32 ForwardingNetLog::NextID() {
return 0;
}
-bool ForwardingNetLog::HasListener() const {
+NetLog::LogLevel ForwardingNetLog::GetLogLevel() const {
// Can't forward a synchronous API.
CHECK(false) << "Not supported";
- return false;
+ return LOG_ALL;
}
} // namespace net
diff --git a/net/base/forwarding_net_log.h b/net/base/forwarding_net_log.h
index 36ff9d2..257b4c7 100644
--- a/net/base/forwarding_net_log.h
+++ b/net/base/forwarding_net_log.h
@@ -39,7 +39,7 @@ class ForwardingNetLog : public NetLog {
EventPhase phase,
EventParameters* params);
virtual uint32 NextID();
- virtual bool HasListener() const;
+ virtual LogLevel GetLogLevel() const;
private:
class Core;
diff --git a/net/base/net_log.cc b/net/base/net_log.cc
index 734cef1..2cc149f 100644
--- a/net/base/net_log.cc
+++ b/net/base/net_log.cc
@@ -122,10 +122,14 @@ void BoundNetLog::AddEntryWithTime(
}
}
-bool BoundNetLog::HasListener() const {
+NetLog::LogLevel BoundNetLog::GetLogLevel() const {
if (net_log_)
- return net_log_->HasListener();
- return false;
+ return net_log_->GetLogLevel();
+ return NetLog::LOG_BASIC;
+}
+
+bool BoundNetLog::IsLoggingAll() const {
+ return GetLogLevel() == NetLog::LOG_ALL;
}
void BoundNetLog::AddEvent(
diff --git a/net/base/net_log.h b/net/base/net_log.h
index d6eca7c..c97eb1a 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -95,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() {}
@@ -117,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);
@@ -177,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.