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 NET_BASE_NET_LOG_H_ | 5 #ifndef NET_BASE_NET_LOG_H_ |
6 #define NET_BASE_NET_LOG_H_ | 6 #define NET_BASE_NET_LOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Constructs an observer that wants to see network events, with | 114 // Constructs an observer that wants to see network events, with |
115 // the specified minimum event granularity. A ThreadSafeObserver can only | 115 // the specified minimum event granularity. A ThreadSafeObserver can only |
116 // observe a single NetLog at a time. | 116 // observe a single NetLog at a time. |
117 // | 117 // |
118 // Observers will be called on the same thread an entry is added on, | 118 // Observers will be called on the same thread an entry is added on, |
119 // and are responsible for ensuring their own thread safety. | 119 // and are responsible for ensuring their own thread safety. |
120 // | 120 // |
121 // Observers must stop watching a NetLog before either the Observer or the | 121 // Observers must stop watching a NetLog before either the Observer or the |
122 // NetLog is destroyed. | 122 // NetLog is destroyed. |
123 ThreadSafeObserver(); | 123 ThreadSafeObserver(); |
124 virtual ~ThreadSafeObserver(); | |
125 | 124 |
126 // Returns the minimum log level for events this observer wants to | 125 // Returns the minimum log level for events this observer wants to |
127 // receive. Must not be called when not watching a NetLog. | 126 // receive. Must not be called when not watching a NetLog. |
128 LogLevel log_level() const; | 127 LogLevel log_level() const; |
129 | 128 |
130 // Returns the NetLog we are currently watching, if any. Returns NULL | 129 // Returns the NetLog we are currently watching, if any. Returns NULL |
131 // otherwise. | 130 // otherwise. |
132 NetLog* net_log() const; | 131 NetLog* net_log() const; |
133 | 132 |
134 // This method will be called on the thread that the event occurs on. It | 133 // This method will be called on the thread that the event occurs on. It |
(...skipping 11 matching lines...) Expand all Loading... |
146 // |params| - Optional (may be NULL) parameters for this event. | 145 // |params| - Optional (may be NULL) parameters for this event. |
147 // The specific subclass of EventParameters is defined | 146 // The specific subclass of EventParameters is defined |
148 // by the contract for events of this |type|. | 147 // by the contract for events of this |type|. |
149 // TODO(eroman): Take a scoped_refptr<EventParameters> instead. | 148 // TODO(eroman): Take a scoped_refptr<EventParameters> instead. |
150 virtual void OnAddEntry(EventType type, | 149 virtual void OnAddEntry(EventType type, |
151 const base::TimeTicks& time, | 150 const base::TimeTicks& time, |
152 const Source& source, | 151 const Source& source, |
153 EventPhase phase, | 152 EventPhase phase, |
154 EventParameters* params) = 0; | 153 EventParameters* params) = 0; |
155 | 154 |
| 155 protected: |
| 156 virtual ~ThreadSafeObserver(); |
| 157 |
156 private: | 158 private: |
157 friend class NetLog; | 159 friend class NetLog; |
158 | 160 |
159 // Both of these values are only modified by the NetLog. | 161 // Both of these values are only modified by the NetLog. |
160 LogLevel log_level_; | 162 LogLevel log_level_; |
161 NetLog* net_log_; | 163 NetLog* net_log_; |
162 | 164 |
163 DISALLOW_COPY_AND_ASSIGN(ThreadSafeObserver); | 165 DISALLOW_COPY_AND_ASSIGN(ThreadSafeObserver); |
164 }; | 166 }; |
165 | 167 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 406 |
405 private: | 407 private: |
406 BoundNetLog net_log_; | 408 BoundNetLog net_log_; |
407 const NetLog::EventType event_type_; | 409 const NetLog::EventType event_type_; |
408 scoped_refptr<NetLog::EventParameters> end_event_params_; | 410 scoped_refptr<NetLog::EventParameters> end_event_params_; |
409 }; | 411 }; |
410 | 412 |
411 } // namespace net | 413 } // namespace net |
412 | 414 |
413 #endif // NET_BASE_NET_LOG_H_ | 415 #endif // NET_BASE_NET_LOG_H_ |
OLD | NEW |