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