OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // | 21 // |
22 // All methods are thread safe, with the exception that no NetLog or | 22 // All methods are thread safe, with the exception that no NetLog or |
23 // NetLog::ThreadSafeObserver functions may be called by an observer's | 23 // NetLog::ThreadSafeObserver functions may be called by an observer's |
24 // OnAddEntry() method. Doing so will result in a deadlock. | 24 // OnAddEntry() method. Doing so will result in a deadlock. |
25 class ChromeNetLog : public net::NetLog { | 25 class ChromeNetLog : public net::NetLog { |
26 public: | 26 public: |
27 ChromeNetLog(); | 27 ChromeNetLog(); |
28 virtual ~ChromeNetLog(); | 28 virtual ~ChromeNetLog(); |
29 | 29 |
30 // NetLog implementation: | 30 // NetLog implementation: |
31 virtual void AddEntry(EventType type, | |
32 const base::TimeTicks& time, | |
33 const Source& source, | |
34 EventPhase phase, | |
35 EventParameters* params) OVERRIDE; | |
36 virtual uint32 NextID() OVERRIDE; | 31 virtual uint32 NextID() OVERRIDE; |
37 virtual LogLevel GetLogLevel() const OVERRIDE; | 32 virtual LogLevel GetLogLevel() const OVERRIDE; |
38 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer, | 33 virtual void AddThreadSafeObserver(ThreadSafeObserver* observer, |
39 LogLevel log_level) OVERRIDE; | 34 LogLevel log_level) OVERRIDE; |
40 virtual void SetObserverLogLevel(ThreadSafeObserver* observer, | 35 virtual void SetObserverLogLevel(ThreadSafeObserver* observer, |
41 LogLevel log_level) OVERRIDE; | 36 LogLevel log_level) OVERRIDE; |
42 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE; | 37 virtual void RemoveThreadSafeObserver(ThreadSafeObserver* observer) OVERRIDE; |
43 | 38 |
44 LoadTimingObserver* load_timing_observer() { | 39 LoadTimingObserver* load_timing_observer() { |
45 return load_timing_observer_.get(); | 40 return load_timing_observer_.get(); |
46 } | 41 } |
47 | 42 |
48 private: | 43 private: |
| 44 // NetLog implementation: |
| 45 virtual void AddEntry(EventType type, |
| 46 const Source& source, |
| 47 EventPhase phase, |
| 48 const scoped_refptr<EventParameters>& params) OVERRIDE; |
| 49 |
49 // Called whenever an observer is added or removed, or has its log level | 50 // Called whenever an observer is added or removed, or has its log level |
50 // changed. Must have acquired |lock_| prior to calling. | 51 // changed. Must have acquired |lock_| prior to calling. |
51 void UpdateLogLevel(); | 52 void UpdateLogLevel(); |
52 | 53 |
53 // |lock_| protects access to |observers_|. | 54 // |lock_| protects access to |observers_|. |
54 base::Lock lock_; | 55 base::Lock lock_; |
55 | 56 |
56 // Last assigned source ID. Incremented to get the next one. | 57 // Last assigned source ID. Incremented to get the next one. |
57 base::subtle::Atomic32 last_id_; | 58 base::subtle::Atomic32 last_id_; |
58 | 59 |
59 // The lowest allowed log level, regardless of any ChromeNetLogObservers. | 60 // The lowest allowed log level, regardless of any ChromeNetLogObservers. |
60 // Normally defaults to LOG_BASIC, but can be changed with command line flags. | 61 // Normally defaults to LOG_BASIC, but can be changed with command line flags. |
61 LogLevel base_log_level_; | 62 LogLevel base_log_level_; |
62 | 63 |
63 // The current log level. | 64 // The current log level. |
64 base::subtle::Atomic32 effective_log_level_; | 65 base::subtle::Atomic32 effective_log_level_; |
65 | 66 |
66 scoped_ptr<LoadTimingObserver> load_timing_observer_; | 67 scoped_ptr<LoadTimingObserver> load_timing_observer_; |
67 scoped_ptr<NetLogLogger> net_log_logger_; | 68 scoped_ptr<NetLogLogger> net_log_logger_; |
68 | 69 |
69 // |lock_| must be acquired whenever reading or writing to this. | 70 // |lock_| must be acquired whenever reading or writing to this. |
70 ObserverList<ThreadSafeObserver, true> observers_; | 71 ObserverList<ThreadSafeObserver, true> observers_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); | 73 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); |
73 }; | 74 }; |
74 | 75 |
75 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ | 76 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |
OLD | NEW |