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_FILES_FILE_TRACING_H_ | |
| 6 #define BASE_FILES_FILE_TRACING_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/trace_event/trace_event.h" | |
| 11 | |
| 12 #define FILE_TRACING_PREFIX "base::File" | |
|
oystein (OOO til 10th of July)
2015/05/01 18:15:31
I'm not sure if "base" is really adding any useful
Dan Beam
2015/05/01 23:29:04
just to match code, removed (noticed many places o
| |
| 13 | |
| 14 #define FILE_TRACING_BEGIN() \ | |
| 15 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( \ | |
| 16 base::kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, this); | |
| 17 | |
| 18 #define FILE_TRACING_END() \ | |
| 19 TRACE_EVENT_NESTABLE_ASYNC_END0( \ | |
| 20 base::kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, this); | |
| 21 | |
| 22 #define SCOPED_FILE_TRACE_WITH_SIZE(name, size) \ | |
| 23 base::ScopedFileTrace trace; \ | |
| 24 bool category_enabled; \ | |
|
oystein (OOO til 10th of July)
2015/05/01 18:15:31
nit: call the scope something other than "trace" (
Dan Beam
2015/05/01 23:29:04
Done.
| |
| 25 TRACE_EVENT_CATEGORY_GROUP_ENABLED( \ | |
| 26 base::kFileTracingEventCategoryGroup, &category_enabled); \ | |
| 27 if (category_enabled) \ | |
| 28 trace.Initialize(FILE_TRACING_PREFIX "::" name, this, size); | |
| 29 | |
| 30 #define SCOPED_FILE_TRACE(name) SCOPED_FILE_TRACE_WITH_SIZE(name, 0) | |
| 31 | |
| 32 namespace base { | |
| 33 | |
| 34 class File; | |
| 35 | |
| 36 extern const char kFileTracingEventCategoryGroup[]; | |
| 37 | |
| 38 class ScopedFileTrace { | |
| 39 public: | |
| 40 ScopedFileTrace(); | |
| 41 ~ScopedFileTrace(); | |
| 42 | |
| 43 // Called only if the tracing category is enabled. | |
| 44 void Initialize(const char* event, File* file, int64 size); | |
| 45 | |
| 46 private: | |
| 47 // True if |Initialize()| has been called. Don't touch |path_|, |event_|, | |
| 48 // or |bytes_| if |initialized_| is false. | |
| 49 bool initialized_; | |
| 50 | |
| 51 // The event name to trace (e.g. "Read", "Write"). Prefixed with "base::File". | |
| 52 const char* name_; | |
| 53 | |
| 54 // The file being traced. Must outlive this class. | |
| 55 File* file_; | |
| 56 | |
| 57 // The size (in bytes) of this trace. Not reported if 0. | |
| 58 int64 size_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(ScopedFileTrace); | |
| 61 }; | |
| 62 | |
| 63 } // namespace base | |
| 64 | |
| 65 #endif // BASE_FILES_FILE_TRACING_H_ | |
| OLD | NEW |