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 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 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 // | 27 // |
28 // To avoid needing to pass in the "source id" to the logging functions, NetLog | 28 // To avoid needing to pass in the "source id" to the logging functions, NetLog |
29 // is usually accessed through a BoundNetLog, which will always pass in a | 29 // is usually accessed through a BoundNetLog, which will always pass in a |
30 // specific source ID. | 30 // specific source ID. |
31 // | 31 // |
32 // ******** The NetLog (and associated logging) is a work in progress ******** | 32 // ******** The NetLog (and associated logging) is a work in progress ******** |
33 // | 33 // |
34 // TODO(eroman): Remove the 'const' qualitifer from the BoundNetLog methods. | 34 // TODO(eroman): Remove the 'const' qualitifer from the BoundNetLog methods. |
35 // TODO(eroman): Start a new Source each time net::URLRequest redirects | 35 // TODO(eroman): Start a new Source each time net::URLRequest redirects |
36 // (simpler to reason about each as a separate entity). | 36 // (simpler to reason about each as a separate entity). |
37 // TODO(mmenke): Replace EndEvent calls with EndEventWithNetErrorCode, where | |
38 // appropriate. | |
39 | 37 |
40 class NetLog { | 38 class NetLog { |
41 public: | 39 public: |
42 enum EventType { | 40 enum EventType { |
43 #define EVENT_TYPE(label) TYPE_ ## label, | 41 #define EVENT_TYPE(label) TYPE_ ## label, |
44 #include "net/base/net_log_event_type_list.h" | 42 #include "net/base/net_log_event_type_list.h" |
45 #undef EVENT_TYPE | 43 #undef EVENT_TYPE |
46 }; | 44 }; |
47 | 45 |
48 // The 'phase' of an event trace (whether it marks the beginning or end | 46 // The 'phase' of an event trace (whether it marks the beginning or end |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Convenience methods that call through to the NetLog, passing in the | 186 // Convenience methods that call through to the NetLog, passing in the |
189 // currently bound source, current time, and a fixed "capture phase" | 187 // currently bound source, current time, and a fixed "capture phase" |
190 // (begin, end, or none). | 188 // (begin, end, or none). |
191 void AddEvent(NetLog::EventType event_type, | 189 void AddEvent(NetLog::EventType event_type, |
192 const scoped_refptr<NetLog::EventParameters>& params) const; | 190 const scoped_refptr<NetLog::EventParameters>& params) const; |
193 void BeginEvent(NetLog::EventType event_type, | 191 void BeginEvent(NetLog::EventType event_type, |
194 const scoped_refptr<NetLog::EventParameters>& params) const; | 192 const scoped_refptr<NetLog::EventParameters>& params) const; |
195 void EndEvent(NetLog::EventType event_type, | 193 void EndEvent(NetLog::EventType event_type, |
196 const scoped_refptr<NetLog::EventParameters>& params) const; | 194 const scoped_refptr<NetLog::EventParameters>& params) const; |
197 | 195 |
198 // Just like EndEvent, except |net_error| is a net error code. If it's | |
199 // negative, a parameter called "net_error" with a value of |net_error| is | |
200 // associated with the event. Otherwise, the end event has no parameters. | |
201 // |net_error| must not be ERR_IO_PENDING, as it's not a true error. | |
202 void EndEventWithNetErrorCode(NetLog::EventType event_type, | |
203 int net_error) const; | |
204 | |
205 NetLog::LogLevel GetLogLevel() const; | 196 NetLog::LogLevel GetLogLevel() const; |
206 | 197 |
207 // Returns true if the log level is LOG_ALL. | 198 // Returns true if the log level is LOG_ALL. |
208 bool IsLoggingBytes() const; | 199 bool IsLoggingBytes() const; |
209 | 200 |
210 // Returns true if the log level is LOG_ALL or LOG_ALL_BUT_BYTES. | 201 // Returns true if the log level is LOG_ALL or LOG_ALL_BUT_BYTES. |
211 bool IsLoggingAllEvents() const; | 202 bool IsLoggingAllEvents() const; |
212 | 203 |
213 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care | 204 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care |
214 // of creating a unique source ID, and handles the case of NULL net_log. | 205 // of creating a unique source ID, and handles the case of NULL net_log. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 290 |
300 private: | 291 private: |
301 BoundNetLog net_log_; | 292 BoundNetLog net_log_; |
302 const NetLog::EventType event_type_; | 293 const NetLog::EventType event_type_; |
303 scoped_refptr<NetLog::EventParameters> end_event_params_; | 294 scoped_refptr<NetLog::EventParameters> end_event_params_; |
304 }; | 295 }; |
305 | 296 |
306 } // namespace net | 297 } // namespace net |
307 | 298 |
308 #endif // NET_BASE_NET_LOG_H_ | 299 #endif // NET_BASE_NET_LOG_H_ |
OLD | NEW |