OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 // A log file reader can read log files produced by Event Tracing for Windows | |
6 // (by way of the FileLogger class) that contain events generated from a select | |
7 // few supported providers; see file_logger_win.h for the list. | |
8 | |
9 #ifndef CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_ | |
10 #define CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_ | |
11 #pragma once | |
12 | |
13 #include <stddef.h> | |
14 #include <windows.h> | |
15 #include <wmistr.h> | |
16 #include <evntrace.h> | |
17 | |
18 #include "base/logging.h" | |
19 #include "base/string_piece.h" | |
20 | |
21 class FilePath; | |
22 | |
23 namespace logging_win { | |
24 | |
25 // An interface to classes interested in taking action based on events parsed | |
26 // out of a log file created by the FileLogger. | |
27 class LogFileDelegate { | |
28 public: | |
29 virtual ~LogFileDelegate(); | |
30 | |
31 // Invoked for event types not currently handled by the parser. | |
32 virtual void OnUnknownEvent(const EVENT_TRACE* event) = 0; | |
33 | |
34 // Invoked for events of known types that cannot be parsed due to unexpected | |
35 // data. | |
36 virtual void OnUnparsableEvent(const EVENT_TRACE* event) = 0; | |
37 | |
38 // Invoked for the header at the front of all log files. | |
39 virtual void OnFileHeader(const EVENT_TRACE* event, | |
40 const TRACE_LOGFILE_HEADER* header) = 0; | |
41 | |
42 // Invoked for simple log messages produced by LogEventProvider. | |
43 virtual void OnLogMessage(const EVENT_TRACE* event, | |
44 logging::LogSeverity severity, | |
45 const base::StringPiece& message) = 0; | |
46 | |
47 // Invoked for full log messages produced by LogEventProvider. | |
48 virtual void OnLogMessageFull(const EVENT_TRACE* event, | |
49 logging::LogSeverity severity, | |
50 DWORD stack_depth, | |
51 const intptr_t* backtrace, | |
52 int line, | |
53 const base::StringPiece& file, | |
54 const base::StringPiece& message) = 0; | |
55 | |
56 // Invoked for trace events produced by TraceEventETWProvider. | |
57 virtual void OnTraceEvent(const EVENT_TRACE* event, | |
58 const base::StringPiece& name, | |
59 char type, | |
60 intptr_t id, | |
robertshield
2012/03/09 16:58:04
intptr_t seems like an odd type for an ID.
grt (UTC plus 2)
2012/03/09 17:55:25
Indeed. a void* is used in the creation of a trac
| |
61 const base::StringPiece& extra, | |
62 DWORD stack_depth, | |
63 const intptr_t* backtrace) = 0; | |
64 | |
65 protected: | |
66 LogFileDelegate(); | |
67 }; | |
68 | |
69 // Reads |log_file|, invoking appropriate methods on |delegate| as events are | |
70 // parsed. Although it is safe to call this from multiple threads, only one | |
71 // file may be read at a time; other threads trying to read other log files will | |
72 // be blocked waiting. | |
73 void ReadLogFile(const FilePath& log_file, LogFileDelegate* delegate); | |
74 | |
75 } // namespace logging_win | |
76 | |
77 #endif // CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_ | |
OLD | NEW |