| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/atomicops.h" | 11 #include "base/atomicops.h" |
| 12 #include "base/lock.h" | |
| 13 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 14 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/synchronization/lock.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 17 | 17 |
| 18 class LoadTimingObserver; | 18 class LoadTimingObserver; |
| 19 class NetLogLogger; | 19 class NetLogLogger; |
| 20 class PassiveLogCollector; | 20 class PassiveLogCollector; |
| 21 | 21 |
| 22 // ChromeNetLog is an implementation of NetLog that dispatches network log | 22 // ChromeNetLog is an implementation of NetLog that dispatches network log |
| 23 // messages to a list of observers. | 23 // messages to a list of observers. |
| 24 // | 24 // |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 void AddObserverWhileLockHeld(ThreadSafeObserver* observer); | 137 void AddObserverWhileLockHeld(ThreadSafeObserver* observer); |
| 138 | 138 |
| 139 // Called whenever an observer is added or removed, or changes its log level. | 139 // Called whenever an observer is added or removed, or changes its log level. |
| 140 // Must have acquired |lock_| prior to calling. | 140 // Must have acquired |lock_| prior to calling. |
| 141 void UpdateLogLevel_(); | 141 void UpdateLogLevel_(); |
| 142 | 142 |
| 143 // |lock_| protects access to |observers_| and, indirectly, to | 143 // |lock_| protects access to |observers_| and, indirectly, to |
| 144 // |passive_collector_|. Should not be acquired by observers. | 144 // |passive_collector_|. Should not be acquired by observers. |
| 145 Lock lock_; | 145 base::Lock lock_; |
| 146 | 146 |
| 147 // Last assigned source ID. Incremented to get the next one. | 147 // Last assigned source ID. Incremented to get the next one. |
| 148 base::subtle::Atomic32 last_id_; | 148 base::subtle::Atomic32 last_id_; |
| 149 | 149 |
| 150 base::subtle::Atomic32 log_level_; | 150 base::subtle::Atomic32 log_level_; |
| 151 | 151 |
| 152 // Not thread safe. Must only be used when |lock_| is acquired. | 152 // Not thread safe. Must only be used when |lock_| is acquired. |
| 153 scoped_ptr<PassiveLogCollector> passive_collector_; | 153 scoped_ptr<PassiveLogCollector> passive_collector_; |
| 154 | 154 |
| 155 scoped_ptr<LoadTimingObserver> load_timing_observer_; | 155 scoped_ptr<LoadTimingObserver> load_timing_observer_; |
| 156 scoped_ptr<NetLogLogger> net_log_logger_; | 156 scoped_ptr<NetLogLogger> net_log_logger_; |
| 157 | 157 |
| 158 // |lock_| must be acquired whenever reading or writing to this. | 158 // |lock_| must be acquired whenever reading or writing to this. |
| 159 ObserverList<ThreadSafeObserver, true> observers_; | 159 ObserverList<ThreadSafeObserver, true> observers_; |
| 160 | 160 |
| 161 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); | 161 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ | 164 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ |
| OLD | NEW |