1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_LOG_NET_LOG_UTIL_H_ 6 #define NET_LOG_NET_LOG_UTIL_H_ 7 8 #include <memory> 9 #include <set> 10 11 #include "net/base/net_export.h" 12 #include "net/log/net_log.h" 13 14 namespace net { 15 16 class URLRequestContext; 17 18 // Utility methods for creating NetLog dumps. 19 20 // Creates a dictionary containing a legend for net/ constants. 21 NET_EXPORT base::Value::Dict GetNetConstants(); 22 23 // Retrieves a dictionary containing information about the current state of 24 // |context|. 25 // 26 // May only be called on |context|'s thread. 27 NET_EXPORT base::Value::Dict GetNetInfo(URLRequestContext* context); 28 29 // Takes in a set of contexts and a NetLog::Observer, and passes in 30 // NetLog::Entries to the observer for certain NetLogSources with pending 31 // events. This allows requests that were ongoing when logging was started to 32 // have an initial event that has some information. This is particularly useful 33 // for hung requests. Note that these calls are not protected by the NetLog's 34 // lock, so this should generally be invoked before the observer starts watching 35 // the NetLog. 36 // 37 // All members of |contexts| must be using the same NetLog, and live on the 38 // current thread. 39 // 40 // Currently only creates events for URLRequests. 41 // 42 // The reason for not returning a list of NetLog::Entries is that entries don't 43 // own most of their data, so it's simplest just to pass them in to the observer 44 // directly while their data is on the stack. 45 NET_EXPORT void CreateNetLogEntriesForActiveObjects( 46 const std::set<URLRequestContext*>& contexts, 47 NetLog::ThreadSafeObserver* observer); 48 49 } // namespace net 50 51 #endif // NET_LOG_NET_LOG_UTIL_H_ 52