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

Side by Side Diff: base/files/file_tracing.h

Issue 1149083012: Simplify file tracing end events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: thestig@ review Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/files/file_tracing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 19 matching lines...) Expand all
30 // Whether the file tracing category is currently enabled. 30 // Whether the file tracing category is currently enabled.
31 virtual bool FileTracingCategoryIsEnabled() const = 0; 31 virtual bool FileTracingCategoryIsEnabled() const = 0;
32 32
33 // Enables file tracing for |id|. Must be called before recording events. 33 // Enables file tracing for |id|. Must be called before recording events.
34 virtual void FileTracingEnable(void* id) = 0; 34 virtual void FileTracingEnable(void* id) = 0;
35 35
36 // Disables file tracing for |id|. 36 // Disables file tracing for |id|.
37 virtual void FileTracingDisable(void* id) = 0; 37 virtual void FileTracingDisable(void* id) = 0;
38 38
39 // Begins an event for |id| with |name|. |path| tells where in the directory 39 // Begins an event for |id| with |name|. |path| tells where in the directory
40 // structure the event is happening (and may be blank). |size| is reported 40 // structure the event is happening (and may be blank). |size| is the number
41 // if not 0. 41 // of bytes involved in the event.
42 virtual void FileTracingEventBegin( 42 virtual void FileTracingEventBegin(
43 const char* name, void* id, const FilePath& path, int64 size) = 0; 43 const char* name, void* id, const FilePath& path, int64 size) = 0;
44 44
45 // Ends an event for |id| with |name|. |path| tells where in the directory 45 // Ends an event for |id| with |name|.
46 // structure the event is happening (and may be blank). |size| is reported 46 virtual void FileTracingEventEnd(const char* name, void* id) = 0;
47 // if not 0.
48 virtual void FileTracingEventEnd(
49 const char* name, void* id, const FilePath& path, int64 size) = 0;
50 }; 47 };
51 48
52 // Sets a global file tracing provider to query categories and record events. 49 // Sets a global file tracing provider to query categories and record events.
53 static void SetProvider(Provider* provider); 50 static void SetProvider(Provider* provider);
54 51
55 // Enables file tracing while in scope. 52 // Enables file tracing while in scope.
56 class ScopedEnabler { 53 class ScopedEnabler {
57 public: 54 public:
58 ScopedEnabler(); 55 ScopedEnabler();
59 ~ScopedEnabler(); 56 ~ScopedEnabler();
60 }; 57 };
61 58
62 class ScopedTrace { 59 class ScopedTrace {
63 public: 60 public:
64 ScopedTrace(); 61 ScopedTrace();
65 ~ScopedTrace(); 62 ~ScopedTrace();
66 63
67 // Whether this trace should be initialized or not. 64 // Whether this trace should be initialized or not.
68 bool ShouldInitialize() const; 65 bool ShouldInitialize() const;
69 66
70 // Called only if the tracing category is enabled. 67 // Called only if the tracing category is enabled. |name| is the name of the
71 void Initialize(const char* event, File* file, int64 size); 68 // event to trace (e.g. "Read", "Write") and must have an application
69 // lifetime (e.g. static or literal). |file| is the file being traced; must
70 // outlive this class. |size| is the size (in bytes) of this event.
71 void Initialize(const char* name, File* file, int64 size);
72 72
73 private: 73 private:
74 // True if |Initialize()| has been called. Don't touch |path_|, |event_|, 74 // The ID of this trace. Based on the |file| passed to |Initialize()|. Must
75 // or |bytes_| if |initialized_| is false. 75 // outlive this class.
76 bool initialized_; 76 void* id_;
77 77
78 // The event name to trace (e.g. "Read", "Write"). Prefixed with "File". 78 // The name of the event to trace (e.g. "Read", "Write"). Prefixed with
79 // "File".
79 const char* name_; 80 const char* name_;
80 81
81 // The file being traced. Must outlive this class.
82 File* file_;
83
84 // The size (in bytes) of this trace. Not reported if 0.
85 int64 size_;
86
87 DISALLOW_COPY_AND_ASSIGN(ScopedTrace); 82 DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
88 }; 83 };
89 84
90 DISALLOW_COPY_AND_ASSIGN(FileTracing); 85 DISALLOW_COPY_AND_ASSIGN(FileTracing);
91 }; 86 };
92 87
93 } // namespace base 88 } // namespace base
94 89
95 #endif // BASE_FILES_FILE_TRACING_H_ 90 #endif // BASE_FILES_FILE_TRACING_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/file_tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698