OLD | NEW |
---|---|
(Empty) | |
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 | |
5 #ifndef NET_LOG_ENTRY_H_ | |
6 #define NET_LOG_ENTRY_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/time/time.h" | |
12 #include "net/base/net_export.h" | |
13 #include "net/log/net_log_capture_mode.h" | |
14 #include "net/log/net_log_event_type.h" | |
15 #include "net/log/net_log_parameters_callback_typedef.h" | |
16 #include "net/log/net_log_source.h" | |
17 | |
18 namespace base { | |
19 class Value; | |
20 } | |
21 | |
22 namespace net { | |
23 | |
24 struct NET_EXPORT NetLogEntryData { | |
25 NetLogEntryData(NetLogEventType type, | |
26 NetLogSource source, | |
27 NetLogEventPhase phase, | |
28 base::TimeTicks time, | |
29 const NetLogParametersCallback* parameters_callback); | |
30 ~NetLogEntryData(); | |
31 | |
32 const NetLogEventType type; | |
33 const NetLogSource source; | |
34 const NetLogEventPhase phase; | |
35 const base::TimeTicks time; | |
36 const NetLogParametersCallback* const parameters_callback; | |
37 }; | |
38 | |
39 // A NetLogEntry pre-binds NetLogEntryData to a capture mode, so observers will | |
40 // observe | |
eroman
2016/10/03 21:40:50
join this line
mikecirone
2016/10/03 23:38:25
Done.
| |
41 // the output of ToValue() and ParametersToValue() at their log capture mode | |
42 // rather than the current maximum. | |
43 class NET_EXPORT NetLogEntry { | |
44 public: | |
45 NetLogEntry(const NetLogEntryData* data, NetLogCaptureMode capture_mode); | |
46 ~NetLogEntry(); | |
47 | |
48 NetLogEventType type() const { return data_->type; } | |
49 NetLogSource source() const { return data_->source; } | |
50 NetLogEventPhase phase() const { return data_->phase; } | |
51 | |
52 // Serializes the specified event to a Value. The Value also includes the | |
53 // current time. Takes in a time to allow back-dating entries. | |
54 std::unique_ptr<base::Value> ToValue() const; | |
55 | |
56 // Returns the parameters as a Value. Returns NULL if there are no | |
eroman
2016/10/03 21:40:50
optional: change to "nullptr" while editing this.
mikecirone
2016/10/03 23:38:25
Done.
| |
57 // parameters. | |
58 std::unique_ptr<base::Value> ParametersToValue() const; | |
59 | |
60 private: | |
61 const NetLogEntryData* const data_; | |
62 | |
63 // Log capture mode when the event occurred. | |
64 const NetLogCaptureMode capture_mode_; | |
65 | |
66 // It is not safe to copy this class, since |parameters_callback_| may | |
67 // include pointers that become stale immediately after the event is added, | |
68 // even if the code were modified to keep its own copy of the callback. | |
69 DISALLOW_COPY_AND_ASSIGN(NetLogEntry); | |
70 }; | |
71 | |
72 } // namespace net | |
73 | |
74 #endif // NET_LOG_ENTRY_H_ | |
OLD | NEW |