summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_net_log.h
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 12:43:23 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 12:43:23 +0000
commitd5cbd92ad951a1c2c24cafebab8bbf3d084b1378 (patch)
tree2c48c137de27922fe1da18620568c4d442ddbe2c /chrome/browser/net/chrome_net_log.h
parent679a319c1fbb027fff52dee50a381ea054092b00 (diff)
downloadchromium_src-d5cbd92ad951a1c2c24cafebab8bbf3d084b1378.zip
chromium_src-d5cbd92ad951a1c2c24cafebab8bbf3d084b1378.tar.gz
chromium_src-d5cbd92ad951a1c2c24cafebab8bbf3d084b1378.tar.bz2
Remove the ChromeNetLog observer classes, using NetLog::ThreadSafeObserver
instead, slightly modifying the NetLog interface to do so. R=eroman@chromium.org BUG=114611 Review URL: http://codereview.chromium.org/9415013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_net_log.h')
-rw-r--r--chrome/browser/net/chrome_net_log.h84
1 files changed, 10 insertions, 74 deletions
diff --git a/chrome/browser/net/chrome_net_log.h b/chrome/browser/net/chrome_net_log.h
index 78ee636..5335b33 100644
--- a/chrome/browser/net/chrome_net_log.h
+++ b/chrome/browser/net/chrome_net_log.h
@@ -19,75 +19,11 @@ class NetLogLogger;
// ChromeNetLog is an implementation of NetLog that dispatches network log
// messages to a list of observers.
//
-// All methods are thread safe, with the exception that no ChromeNetLog or
-// ChromeNetLog::ThreadSafeObserverImpl functions may be called by an observer's
+// All methods are thread safe, with the exception that no NetLog or
+// NetLog::ThreadSafeObserver functions may be called by an observer's
// OnAddEntry() method. Doing so will result in a deadlock.
class ChromeNetLog : public net::NetLog {
public:
- // Base class for observing the events logged by the network
- // stack. This has some nice-to-have functionality for use by code
- // within chrome/, but any net::NetLog::ThreadSafeObserver may be
- // registered to observe the NetLog.
- //
- // This class uses composition rather than inheritance so that
- // certain invariants can be maintained when subclasses of it are
- // added as observers (through the AddAsObserver and
- // RemoveAsObserver methods on this class).
- class ThreadSafeObserverImpl {
- public:
- // Observers that need to see the full granularity of events can
- // specify LOG_ALL.
- explicit ThreadSafeObserverImpl(LogLevel log_level);
- virtual ~ThreadSafeObserverImpl();
-
- virtual void OnAddEntry(EventType type,
- const base::TimeTicks& time,
- const Source& source,
- EventPhase phase,
- EventParameters* params) = 0;
-
- // These must be used instead of
- // ChromeNetLog::Add/RemoveThreadSafeObserver to manage the
- // association in this class with a given ChromeNetLog instance.
- void AddAsObserver(ChromeNetLog* net_log);
- void RemoveAsObserver();
-
- void SetLogLevel(LogLevel log_level);
-
- protected:
- void AssertNetLogLockAcquired() const;
-
- private:
- class PassThroughObserver : public ThreadSafeObserver {
- public:
- PassThroughObserver(ThreadSafeObserverImpl* owner, LogLevel log_level);
- virtual ~PassThroughObserver() {}
- virtual void OnAddEntry(EventType type,
- const base::TimeTicks& time,
- const Source& source,
- EventPhase phase,
- EventParameters* params) OVERRIDE;
-
- // Can only be called when actively observing a ChromeNetLog.
- void SetLogLevel(LogLevel log_level);
-
- private:
- ThreadSafeObserverImpl* owner_;
- };
-
- friend class PassThroughObserver;
-
- // ChromeNetLog currently being observed. Set by
- // AddAsObserver/RemoveAsObserver.
- ChromeNetLog* net_log_;
-
- // The observer we register in AddAsObserver, that passes stuff
- // through to us.
- PassThroughObserver internal_observer_;
-
- DISALLOW_COPY_AND_ASSIGN(ThreadSafeObserverImpl);
- };
-
ChromeNetLog();
virtual ~ChromeNetLog();
@@ -99,22 +35,22 @@ class ChromeNetLog : public net::NetLog {
EventParameters* params) OVERRIDE;
virtual uint32 NextID() OVERRIDE;
virtual LogLevel GetLogLevel() const OVERRIDE;
+ virtual void AddThreadSafeObserver(ThreadSafeObserver* observer,
+ LogLevel log_level) OVERRIDE;
+ virtual void SetObserverLogLevel(ThreadSafeObserver* observer,
+ LogLevel log_level) OVERRIDE;
+ virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
LoadTimingObserver* load_timing_observer() {
return load_timing_observer_.get();
}
private:
- // NetLog implementation
- virtual void AddThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
- virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE;
-
- // Called whenever an observer is added or removed, or changes its log level.
- // Must have acquired |lock_| prior to calling.
+ // Called whenever an observer is added or removed, or has its log level
+ // changed. Must have acquired |lock_| prior to calling.
void UpdateLogLevel();
- // |lock_| protects access to |observers_| and, indirectly, to. Should not
- // be acquired by observers.
+ // |lock_| protects access to |observers_|.
base::Lock lock_;
// Last assigned source ID. Incremented to get the next one.