net_log_util.h 1.7 KB

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