OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_UTIL_H_ | 5 #ifndef NET_BASE_NET_LOG_UTIL_H_ |
6 #define NET_BASE_NET_LOG_UTIL_H_ | 6 #define NET_BASE_NET_LOG_UTIL_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 12 #include "net/base/net_log.h" |
10 | 13 |
11 namespace base { | 14 namespace base { |
12 class DictionaryValue; | 15 class DictionaryValue; |
13 class Value; | 16 class Value; |
14 } | 17 } |
15 | 18 |
16 namespace net { | 19 namespace net { |
17 | 20 |
18 class URLRequestContext; | 21 class URLRequestContext; |
19 | 22 |
20 // A set of flags that can be OR'd together to request specific information | 23 // A set of flags that can be OR'd together to request specific information |
21 // about the current state of the URLRequestContext. See GetNetInfo, below. | 24 // about the current state of the URLRequestContext. See GetNetInfo, below. |
22 enum NetInfoSource { | 25 enum NetInfoSource { |
23 #define NET_INFO_SOURCE(label, string, value) NET_INFO_ ## label = value, | 26 #define NET_INFO_SOURCE(label, string, value) NET_INFO_ ## label = value, |
24 #include "net/base/net_info_source_list.h" | 27 #include "net/base/net_info_source_list.h" |
25 #undef NET_INFO_SOURCE | 28 #undef NET_INFO_SOURCE |
26 NET_INFO_ALL_SOURCES = -1, | 29 NET_INFO_ALL_SOURCES = -1, |
27 }; | 30 }; |
28 | 31 |
29 // Utility methods for creating NetLog dumps. | 32 // Utility methods for creating NetLog dumps. |
30 | 33 |
31 // Create a dictionary containing legend for net/ constants. | 34 // Create a dictionary containing a legend for net/ constants. |
32 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetConstants(); | 35 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetConstants(); |
33 | 36 |
34 // Retrieves a dictionary containing information about the current state of | 37 // Retrieves a dictionary containing information about the current state of |
35 // |context|. |info_sources| is a set of NetInfoSources OR'd together, | 38 // |context|. |info_sources| is a set of NetInfoSources OR'd together, |
36 // indicating just what information is being requested. Each NetInfoSource adds | 39 // indicating just what information is being requested. Each NetInfoSource adds |
37 // one top-level entry to the returned dictionary. | 40 // one top-level entry to the returned dictionary. |
| 41 // |
| 42 // May only be called on |context|'s thread. |
38 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetInfo( | 43 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetInfo( |
39 URLRequestContext* context, int info_sources); | 44 URLRequestContext* context, int info_sources); |
40 | 45 |
| 46 // Takes in a set of contexts and a NetLog::Observer, and passes in |
| 47 // NetLog::Entries to the observer for certain NetLog::Sources with pending |
| 48 // events. This allows requests that were ongoing when logging was started to |
| 49 // have an initial event that has some information. This is particularly useful |
| 50 // for hung requests. Note that these calls are not protected by the NetLog's |
| 51 // lock, so this should generally be invoked before the observer starts watching |
| 52 // the NetLog. |
| 53 // |
| 54 // All members of |contexts| must be using the same NetLog, and live on the |
| 55 // current thread. |
| 56 // |
| 57 // Currently only creates events for URLRequests. |
| 58 // |
| 59 // The reason for not returning a list of NetLog::Entries is that entries don't |
| 60 // own most of their data, so it's simplest just to pass them in to the observer |
| 61 // directly while their data is on the stack. |
| 62 NET_EXPORT void CreateNetLogEntriesForActiveObjects( |
| 63 const std::set<URLRequestContext*>& contexts, |
| 64 NetLog::ThreadSafeObserver* observer); |
| 65 |
41 } // namespace net | 66 } // namespace net |
42 | 67 |
43 #endif // NET_BASE_NET_LOG_UTIL_H_ | 68 #endif // NET_BASE_NET_LOG_UTIL_H_ |
OLD | NEW |