diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:03:53 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:03:53 +0000 |
commit | 9e743cddfd631038fe6f1cdde050e18d61319ec6 (patch) | |
tree | 7ef974e43b23f570433fe819bcd07966165c517f /chrome/browser/net/chrome_net_log.h | |
parent | 2e7aff66fe443c29b2fc14a776dca5512b0b4729 (diff) | |
download | chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.zip chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.tar.gz chromium_src-9e743cddfd631038fe6f1cdde050e18d61319ec6.tar.bz2 |
Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog).
This makes it possible to associate a single NetLog with a URLRequestContext, and then attach observers to that log to watch the stream of events.
This changelist attempts to do the most direct translation, so there will be subsequent iterations to clean up.
The user-visible behavior should remain unchanged.
BUG=37421
Review URL: http://codereview.chromium.org/848006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_net_log.h')
-rw-r--r-- | chrome/browser/net/chrome_net_log.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/chrome/browser/net/chrome_net_log.h b/chrome/browser/net/chrome_net_log.h new file mode 100644 index 0000000..d27c8d0 --- /dev/null +++ b/chrome/browser/net/chrome_net_log.h @@ -0,0 +1,54 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_NET_CHROME_NET_LOG_H_ +#define CHROME_BROWSER_NET_CHROME_NET_LOG_H_ + +#include "base/observer_list.h" +#include "net/base/net_log.h" + +class PassiveLogCollector; + +// ChromeNetLog is an implementation of NetLog that dispatches network log +// messages to a list of observers. +// +// By default, ChromeNetLog will attach the observer PassiveLogCollector which +// will keep track of recent request information (which used when displaying +// the about:net-internals page). +// +// TODO(eroman): Move this default observer out of ChromeNetLog. +// +class ChromeNetLog : public net::NetLog { + public: + // Interface for observing the events logged by the network stack. + class Observer { + public: + virtual ~Observer() {} + virtual void OnAddEntry(const Entry& entry) = 0; + }; + + ChromeNetLog(); + ~ChromeNetLog(); + + // NetLog implementation: + virtual void AddEntry(const Entry& entry); + virtual int NextID(); + virtual bool HasListener() const; + + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + + PassiveLogCollector* passive_collector() { + return passive_collector_.get(); + } + + private: + int next_id_; + scoped_ptr<PassiveLogCollector> passive_collector_; + ObserverList<Observer, true> observers_; + + DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); +}; + +#endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |