net_log_source.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2016 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_SOURCE_H_
  5. #define NET_LOG_NET_LOG_SOURCE_H_
  6. #include <stdint.h>
  7. #include "base/time/time.h"
  8. #include "base/values.h"
  9. #include "net/base/net_export.h"
  10. #include "net/log/net_log_source_type.h"
  11. namespace net {
  12. // Identifies the entity that generated this log. The |id| field should
  13. // uniquely identify the source, and is used by log observers to infer
  14. // message groupings. Can use NetLog::NextID() to create unique IDs.
  15. struct NET_EXPORT NetLogSource {
  16. static const uint32_t kInvalidId;
  17. NetLogSource();
  18. NetLogSource(NetLogSourceType type, uint32_t id);
  19. NetLogSource(NetLogSourceType type, uint32_t id, base::TimeTicks start_time);
  20. bool operator==(const NetLogSource& rhs) const;
  21. bool IsValid() const;
  22. // Adds the source to a dictionary containing event parameters,
  23. // using the name "source_dependency".
  24. void AddToEventParameters(base::Value::Dict& event_params) const;
  25. // Returns a dictionary with a single entry named "source_dependency" that
  26. // describes |this|.
  27. base::Value ToEventParameters() const;
  28. NetLogSourceType type;
  29. uint32_t id;
  30. base::TimeTicks start_time;
  31. };
  32. } // namespace net
  33. #endif // NET_LOG_NET_LOG_SOURCE_H_