Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ | |
| 6 #define BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/macros.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 class FilePath; | |
| 16 | |
| 17 // A class to trace file I/O. Just stick one in a scope you're tracing like so: | |
| 18 // | |
| 19 // FilePath path("/var/run/prog"); | |
| 20 // File prog(path, File::FILE_OPEN | File::FILE_WRITE); | |
| 21 // { | |
| 22 // ScopedFileTrace trace(path, "Write", 1); | |
| 23 // prog.Write(0, "1", 1); | |
| 24 // } | |
| 25 // | |
| 26 // Tracing will be started/stopped automatically based on the scope it lives in. | |
| 27 // | |
| 28 class ScopedFileTrace { | |
| 29 public: | |
| 30 ScopedFileTrace(const FilePath& path, const char* event, size_t bytes); | |
| 31 ~ScopedFileTrace(); | |
| 32 | |
| 33 // The group that shows up in chrome://tracing. | |
| 34 static const char kGroup[]; | |
|
Dan Beam
2015/04/23 22:32:19
don't really care where this lives; it's arguable
| |
| 35 | |
| 36 private: | |
| 37 // The file path being traced. | |
| 38 std::string path_; | |
|
Dan Beam
2015/04/24 03:45:18
Note to self: const
| |
| 39 | |
| 40 // The event to trace (e.g. "Read", "Write"). | |
| 41 const char* event_; | |
| 42 | |
| 43 // Number of bytes involved in this event. Not reported if 0. | |
| 44 size_t bytes_; | |
|
Dan Beam
2015/04/24 03:45:18
Also const if it's too hard to update with real by
| |
| 45 | |
| 46 DISALLOW_COPY_AND_ASSIGN(ScopedFileTrace); | |
| 47 }; | |
| 48 | |
| 49 } // namespace base | |
| 50 | |
| 51 #endif // BASE_TRACE_EVENT_SCOPED_FILE_TRACE_H_ | |
| OLD | NEW |