blob: 9ce41b3ec4a34c94aebe91b8cba424ad246a50c3 [file] [log] [blame]
mikecironef22f9812016-10-04 03:40:191// 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
5#ifndef NET_LOG_NET_LOG_SOURCE_H_
6#define NET_LOG_NET_LOG_SOURCE_H_
7
8#include <stdint.h>
9
Matt Mueller8dbfd7e2020-01-10 21:04:1610#include "base/time/time.h"
Matt Menkec9a0b382022-05-27 22:31:4711#include "base/values.h"
mikecironef22f9812016-10-04 03:40:1912#include "net/base/net_export.h"
mikecironef22f9812016-10-04 03:40:1913#include "net/log/net_log_source_type.h"
14
mikecironef22f9812016-10-04 03:40:1915namespace net {
16
17// Identifies the entity that generated this log. The |id| field should
18// uniquely identify the source, and is used by log observers to infer
19// message groupings. Can use NetLog::NextID() to create unique IDs.
20struct NET_EXPORT NetLogSource {
21 static const uint32_t kInvalidId;
22
23 NetLogSource();
24 NetLogSource(NetLogSourceType type, uint32_t id);
Matt Mueller8dbfd7e2020-01-10 21:04:1625 NetLogSource(NetLogSourceType type, uint32_t id, base::TimeTicks start_time);
ainozaki7eefe912021-10-12 03:40:2626
27 bool operator==(const NetLogSource& rhs) const;
28
mikecironef22f9812016-10-04 03:40:1929 bool IsValid() const;
30
Panos Astithas5ab30f12020-06-15 20:46:2631 // Adds the source to a dictionary containing event parameters,
mikecironef22f9812016-10-04 03:40:1932 // using the name "source_dependency".
Matt Menkec9a0b382022-05-27 22:31:4733 void AddToEventParameters(base::Value::Dict& event_params) const;
mikecironef22f9812016-10-04 03:40:1934
Eric Roman06bd9742019-07-13 15:19:1335 // Returns a dictionary with a single entry named "source_dependency" that
36 // describes |this|.
37 base::Value ToEventParameters() const;
mikecironef22f9812016-10-04 03:40:1938
mikecironef22f9812016-10-04 03:40:1939 NetLogSourceType type;
40 uint32_t id;
Matt Mueller8dbfd7e2020-01-10 21:04:1641 base::TimeTicks start_time;
mikecironef22f9812016-10-04 03:40:1942};
43
44} // namespace net
45
46#endif // NET_LOG_NET_LOG_SOURCE_H_