| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_FILES_FILE_TRACING_H_ | 5 #ifndef BASE_FILES_FILE_TRACING_H_ |
| 6 #define BASE_FILES_FILE_TRACING_H_ | 6 #define BASE_FILES_FILE_TRACING_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 static bool IsCategoryEnabled(); | 30 static bool IsCategoryEnabled(); |
| 31 | 31 |
| 32 class Provider { | 32 class Provider { |
| 33 public: | 33 public: |
| 34 virtual ~Provider() = default; | 34 virtual ~Provider() = default; |
| 35 | 35 |
| 36 // Whether the file tracing category is currently enabled. | 36 // Whether the file tracing category is currently enabled. |
| 37 virtual bool FileTracingCategoryIsEnabled() const = 0; | 37 virtual bool FileTracingCategoryIsEnabled() const = 0; |
| 38 | 38 |
| 39 // Enables file tracing for |id|. Must be called before recording events. | 39 // Enables file tracing for |id|. Must be called before recording events. |
| 40 virtual void FileTracingEnable(void* id) = 0; | 40 virtual void FileTracingEnable(const void* id) = 0; |
| 41 | 41 |
| 42 // Disables file tracing for |id|. | 42 // Disables file tracing for |id|. |
| 43 virtual void FileTracingDisable(void* id) = 0; | 43 virtual void FileTracingDisable(const void* id) = 0; |
| 44 | 44 |
| 45 // Begins an event for |id| with |name|. |path| tells where in the directory | 45 // Begins an event for |id| with |name|. |path| tells where in the directory |
| 46 // structure the event is happening (and may be blank). |size| is the number | 46 // structure the event is happening (and may be blank). |size| is the number |
| 47 // of bytes involved in the event. | 47 // of bytes involved in the event. |
| 48 virtual void FileTracingEventBegin(const char* name, | 48 virtual void FileTracingEventBegin(const char* name, |
| 49 void* id, | 49 const void* id, |
| 50 const FilePath& path, | 50 const FilePath& path, |
| 51 int64_t size) = 0; | 51 int64_t size) = 0; |
| 52 | 52 |
| 53 // Ends an event for |id| with |name|. | 53 // Ends an event for |id| with |name|. |
| 54 virtual void FileTracingEventEnd(const char* name, void* id) = 0; | 54 virtual void FileTracingEventEnd(const char* name, const void* id) = 0; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // Sets a global file tracing provider to query categories and record events. | 57 // Sets a global file tracing provider to query categories and record events. |
| 58 static void SetProvider(Provider* provider); | 58 static void SetProvider(Provider* provider); |
| 59 | 59 |
| 60 // Enables file tracing while in scope. | 60 // Enables file tracing while in scope. |
| 61 class ScopedEnabler { | 61 class ScopedEnabler { |
| 62 public: | 62 public: |
| 63 ScopedEnabler(); | 63 ScopedEnabler(); |
| 64 ~ScopedEnabler(); | 64 ~ScopedEnabler(); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class ScopedTrace { | 67 class ScopedTrace { |
| 68 public: | 68 public: |
| 69 ScopedTrace(); | 69 ScopedTrace(); |
| 70 ~ScopedTrace(); | 70 ~ScopedTrace(); |
| 71 | 71 |
| 72 // Called only if the tracing category is enabled. |name| is the name of the | 72 // Called only if the tracing category is enabled. |name| is the name of the |
| 73 // event to trace (e.g. "Read", "Write") and must have an application | 73 // event to trace (e.g. "Read", "Write") and must have an application |
| 74 // lifetime (e.g. static or literal). |file| is the file being traced; must | 74 // lifetime (e.g. static or literal). |file| is the file being traced; must |
| 75 // outlive this class. |size| is the size (in bytes) of this event. | 75 // outlive this class. |size| is the size (in bytes) of this event. |
| 76 void Initialize(const char* name, File* file, int64_t size); | 76 void Initialize(const char* name, const File* file, int64_t size); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 // The ID of this trace. Based on the |file| passed to |Initialize()|. Must | 79 // The ID of this trace. Based on the |file| passed to |Initialize()|. Must |
| 80 // outlive this class. | 80 // outlive this class. |
| 81 void* id_; | 81 const void* id_; |
| 82 | 82 |
| 83 // The name of the event to trace (e.g. "Read", "Write"). Prefixed with | 83 // The name of the event to trace (e.g. "Read", "Write"). Prefixed with |
| 84 // "File". | 84 // "File". |
| 85 const char* name_; | 85 const char* name_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(ScopedTrace); | 87 DISALLOW_COPY_AND_ASSIGN(ScopedTrace); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(FileTracing); | 90 DISALLOW_COPY_AND_ASSIGN(FileTracing); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace base | 93 } // namespace base |
| 94 | 94 |
| 95 #endif // BASE_FILES_FILE_TRACING_H_ | 95 #endif // BASE_FILES_FILE_TRACING_H_ |
| OLD | NEW |