summaryrefslogtreecommitdiffstats
path: root/net/base/net_log.h
diff options
context:
space:
mode:
authordpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-27 01:18:28 +0000
committerdpranke@chromium.org <dpranke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-27 01:18:28 +0000
commitae6e99198cc1d63e74459ba60172676bcea2af22 (patch)
tree13fa083e1a8b2b60e6038b495b62e9e32fdde3eb /net/base/net_log.h
parentcf4b8e3ace0b430a3bb73d45a3af0a146b0d846e (diff)
downloadchromium_src-ae6e99198cc1d63e74459ba60172676bcea2af22.zip
chromium_src-ae6e99198cc1d63e74459ba60172676bcea2af22.tar.gz
chromium_src-ae6e99198cc1d63e74459ba60172676bcea2af22.tar.bz2
Remove ChromeNetLog depenency from content/browser/debugger
Revert r94208 (re-land r94196), add missing NET_API decl. TBR=willchan@chromium.org BUG=84078 TEST=everything compiles Review URL: http://codereview.chromium.org/7477035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_log.h')
-rw-r--r--net/base/net_log.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/net/base/net_log.h b/net/base/net_log.h
index 39fa915..97efb27 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -104,6 +104,50 @@ class NET_API NetLog {
LOG_BASIC,
};
+ // An observer, that must ensure its own thread safety, for events
+ // being added to a NetLog.
+ class NET_API ThreadSafeObserver {
+ public:
+ // Constructs an observer that wants to see network events, with
+ // the specified minimum event granularity. A ThreadSafeObserver can only
+ // observe a single NetLog at a time.
+ //
+ // Typical observers should specify LOG_BASIC.
+ //
+ // Observers that need to see the full granularity of events can
+ // specify LOG_ALL. However doing so will have performance consequences.
+ //
+ // Observers will be called on the same thread an entry is added on,
+ // and are responsible for ensuring their own thread safety.
+ explicit ThreadSafeObserver(LogLevel log_level);
+ virtual ~ThreadSafeObserver();
+
+ // Returns the minimum log level for events this observer wants to
+ // receive.
+ LogLevel log_level() const;
+
+ // This method will be called on the thread that the event occurs on. It
+ // is the responsibility of the observer to handle it in a thread safe
+ // manner.
+ //
+ // It is illegal for an Observer to call any NetLog or
+ // NetLog::Observer functions in response to a call to OnAddEntry.
+ virtual void OnAddEntry(EventType type,
+ const base::TimeTicks& time,
+ const Source& source,
+ EventPhase phase,
+ EventParameters* params) = 0;
+
+ protected:
+ // Subclasses should only ever modify this if they somehow
+ // collaborate with concrete implementations of NetLog to enable
+ // modification.
+ LogLevel log_level_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeObserver);
+ };
+
NetLog() {}
virtual ~NetLog() {}
@@ -130,6 +174,14 @@ class NET_API NetLog {
// and saving expensive log entries.
virtual LogLevel GetLogLevel() const = 0;
+ // Adds an observer. Each observer may be added only once and must
+ // be removed via |RemoveObserver()| before this object goes out of
+ // scope.
+ virtual void AddThreadSafeObserver(ThreadSafeObserver* observer) = 0;
+
+ // Removes an observer.
+ virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) = 0;
+
// Converts a time to the string format that the NetLog uses to represent
// times. Strings are used since integers may overflow.
static std::string TickCountToString(const base::TimeTicks& time);