Index: base/trace_event/scoped_file_trace.h |
diff --git a/base/trace_event/scoped_file_trace.h b/base/trace_event/scoped_file_trace.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61fa256ad37e81b4ec7687d8725ed18fe71a1b17 |
--- /dev/null |
+++ b/base/trace_event/scoped_file_trace.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 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. |
+ |
+#ifndef BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ |
+#define BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/macros.h" |
+ |
+namespace base { |
+ |
+class FilePath; |
+ |
+// A class to trace file I/O. Just stick one in a scope you're tracing like so: |
+// |
+// FilePath path("/var/run/prog"); |
+// File prog(path, File::FILE_OPEN | File::FILE_WRITE); |
+// { |
+// ScopedFileTrace trace(path, "Write", 1); |
+// prog.Write(0, "1", 1); |
+// } |
+// |
+// Tracing will be started/stopped automatically based on the scope it lives in. |
+// |
+class ScopedFileTrace { |
+ public: |
+ ScopedFileTrace(const FilePath& path, const char* event, size_t bytes); |
+ ~ScopedFileTrace(); |
+ |
+ // The group that shows up in chrome://tracing. |
+ static const char kGroup[]; |
Dan Beam
2015/04/23 22:32:19
don't really care where this lives; it's arguable
|
+ |
+ private: |
+ // The file path being traced. |
+ std::string path_; |
Dan Beam
2015/04/24 03:45:18
Note to self: const
|
+ |
+ // The event to trace (e.g. "Read", "Write"). |
+ const char* event_; |
+ |
+ // Number of bytes involved in this event. Not reported if 0. |
+ size_t bytes_; |
Dan Beam
2015/04/24 03:45:18
Also const if it's too hard to update with real by
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedFileTrace); |
+}; |
+ |
+} // namespace base |
+ |
+#endif // BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ |