Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: chrome/test/base/log_file_reader_win.h

Issue 9584017: New test infrastructure for producing verbose logs in failing tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops, forgot to add test Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/log_file_reader_win.h
diff --git a/chrome/test/base/log_file_reader_win.h b/chrome/test/base/log_file_reader_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..f24e3c276f9696433309b431eef0f20e555c0e59
--- /dev/null
+++ b/chrome/test/base/log_file_reader_win.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A log file reader can read log files produced by Event Tracing for Windows
+// (by way of the FileLogger class) that contain events generated from a select
+// few supported providers; see file_logger_win.h for the list.
+
+#ifndef CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_
+#define CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_
+#pragma once
+
+#include <stddef.h>
+#include <windows.h>
+#include <wmistr.h>
+#include <evntrace.h>
+
+#include "base/logging.h"
+#include "base/string_piece.h"
+
+class FilePath;
+
+namespace logging_win {
+
+// An interface to classes interested in taking action based on events parsed
+// out of a log file created by the FileLogger.
+class LogFileDelegate {
+ public:
+ virtual ~LogFileDelegate();
+
+ // Invoked for event types not currently handled by the parser.
+ virtual void OnUnknownEvent(const EVENT_TRACE* event) = 0;
+
+ // Invoked for events of known types that cannot be parsed due to unexpected
+ // data.
+ virtual void OnUnparsableEvent(const EVENT_TRACE* event) = 0;
+
+ // Invoked for the header at the front of all log files.
+ virtual void OnFileHeader(const EVENT_TRACE* event,
+ const TRACE_LOGFILE_HEADER* header) = 0;
+
+ // Invoked for simple log messages produced by LogEventProvider.
+ virtual void OnLogMessage(const EVENT_TRACE* event,
+ logging::LogSeverity severity,
+ const base::StringPiece& message) = 0;
+
+ // Invoked for full log messages produced by LogEventProvider.
+ virtual void OnLogMessageFull(const EVENT_TRACE* event,
+ logging::LogSeverity severity,
+ DWORD stack_depth,
+ const intptr_t* backtrace,
+ int line,
+ const base::StringPiece& file,
+ const base::StringPiece& message) = 0;
+
+ // Invoked for trace events produced by TraceEventETWProvider.
+ virtual void OnTraceEvent(const EVENT_TRACE* event,
+ const base::StringPiece& name,
+ char type,
+ 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
+ const base::StringPiece& extra,
+ DWORD stack_depth,
+ const intptr_t* backtrace) = 0;
+
+ protected:
+ LogFileDelegate();
+};
+
+// Reads |log_file|, invoking appropriate methods on |delegate| as events are
+// parsed. Although it is safe to call this from multiple threads, only one
+// file may be read at a time; other threads trying to read other log files will
+// be blocked waiting.
+void ReadLogFile(const FilePath& log_file, LogFileDelegate* delegate);
+
+} // namespace logging_win
+
+#endif // CHROME_TEST_BASE_LOG_FILE_READER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698