OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |
| 7 |
| 8 #include "base/observer_list.h" |
| 9 #include "net/base/net_log.h" |
| 10 |
| 11 class PassiveLogCollector; |
| 12 |
| 13 // ChromeNetLog is an implementation of NetLog that dispatches network log |
| 14 // messages to a list of observers. |
| 15 // |
| 16 // By default, ChromeNetLog will attach the observer PassiveLogCollector which |
| 17 // will keep track of recent request information (which used when displaying |
| 18 // the about:net-internals page). |
| 19 // |
| 20 // TODO(eroman): Move this default observer out of ChromeNetLog. |
| 21 // |
| 22 class ChromeNetLog : public net::NetLog { |
| 23 public: |
| 24 // Interface for observing the events logged by the network stack. |
| 25 class Observer { |
| 26 public: |
| 27 virtual ~Observer() {} |
| 28 virtual void OnAddEntry(const Entry& entry) = 0; |
| 29 }; |
| 30 |
| 31 ChromeNetLog(); |
| 32 ~ChromeNetLog(); |
| 33 |
| 34 // NetLog implementation: |
| 35 virtual void AddEntry(const Entry& entry); |
| 36 virtual int NextID(); |
| 37 virtual bool HasListener() const; |
| 38 |
| 39 void AddObserver(Observer* observer); |
| 40 void RemoveObserver(Observer* observer); |
| 41 |
| 42 PassiveLogCollector* passive_collector() { |
| 43 return passive_collector_.get(); |
| 44 } |
| 45 |
| 46 private: |
| 47 int next_id_; |
| 48 scoped_ptr<PassiveLogCollector> passive_collector_; |
| 49 ObserverList<Observer, true> observers_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); |
| 52 }; |
| 53 |
| 54 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |
OLD | NEW |