xref: /aosp_15_r20/external/cronet/net/log/net_log_entry.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 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_ENTRY_H_
6 #define NET_LOG_NET_LOG_ENTRY_H_
7 
8 #include "base/time/time.h"
9 #include "base/values.h"
10 #include "net/base/net_export.h"
11 #include "net/log/net_log_event_type.h"
12 #include "net/log/net_log_source.h"
13 
14 namespace net {
15 
16 // Represents an event that was sent to a NetLog observer, including the
17 // materialized parameters.
18 struct NET_EXPORT NetLogEntry {
19  public:
20   NetLogEntry(NetLogEventType type,
21               NetLogSource source,
22               NetLogEventPhase phase,
23               base::TimeTicks time,
24               base::Value::Dict params);
25 
26   ~NetLogEntry();
27 
28   // Moveable.
29   NetLogEntry(NetLogEntry&& entry);
30   NetLogEntry& operator=(NetLogEntry&& entry);
31 
32   // Serializes the specified event to a Dict.
33   base::Value::Dict ToDict() const;
34 
35   // NetLogEntry is not copy constructible, however copying is useful for
36   // unittests.
37   NetLogEntry Clone() const;
38 
39   // Returns true if the entry has value for |params|.
40   bool HasParams() const;
41 
42   NetLogEventType type;
43   NetLogSource source;
44   NetLogEventPhase phase;
45   base::TimeTicks time;
46   base::Value::Dict params;
47 };
48 
49 }  // namespace net
50 
51 #endif  // NET_LOG_NET_LOG_ENTRY_H_
52