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

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

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 | « base/files/file_posix.cc ('k') | 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"
11 11
12 #define FILE_TRACING_PREFIX "File" 12 #define FILE_TRACING_PREFIX "File"
13 13
14 #define SCOPED_FILE_TRACE_WITH_SIZE(name, size) \ 14 #define SCOPED_FILE_TRACE_WITH_SIZE(name, size) \
15 FileTracing::ScopedTrace scoped_file_trace; \ 15 FileTracing::ScopedTrace scoped_file_trace; \
16 if (scoped_file_trace.ShouldInitialize()) \ 16 if (FileTracing::IsCategoryEnabled()) \
17 scoped_file_trace.Initialize(FILE_TRACING_PREFIX "::" name, this, size) 17 scoped_file_trace.Initialize(FILE_TRACING_PREFIX "::" name, this, size)
18 18
19 #define SCOPED_FILE_TRACE(name) SCOPED_FILE_TRACE_WITH_SIZE(name, 0) 19 #define SCOPED_FILE_TRACE(name) SCOPED_FILE_TRACE_WITH_SIZE(name, 0)
20 20
21 namespace base { 21 namespace base {
22 22
23 class File; 23 class File;
24 class FilePath; 24 class FilePath;
25 25
26 class BASE_EXPORT FileTracing { 26 class BASE_EXPORT FileTracing {
27 public: 27 public:
28 // Whether the file tracing category is enabled.
29 static bool IsCategoryEnabled();
30
28 class Provider { 31 class Provider {
29 public: 32 public:
33 virtual ~Provider() = default;
34
30 // Whether the file tracing category is currently enabled. 35 // Whether the file tracing category is currently enabled.
31 virtual bool FileTracingCategoryIsEnabled() const = 0; 36 virtual bool FileTracingCategoryIsEnabled() const = 0;
32 37
33 // Enables file tracing for |id|. Must be called before recording events. 38 // Enables file tracing for |id|. Must be called before recording events.
34 virtual void FileTracingEnable(void* id) = 0; 39 virtual void FileTracingEnable(void* id) = 0;
35 40
36 // Disables file tracing for |id|. 41 // Disables file tracing for |id|.
37 virtual void FileTracingDisable(void* id) = 0; 42 virtual void FileTracingDisable(void* id) = 0;
38 43
39 // Begins an event for |id| with |name|. |path| tells where in the directory 44 // Begins an event for |id| with |name|. |path| tells where in the directory
(...skipping 14 matching lines...) Expand all
54 public: 59 public:
55 ScopedEnabler(); 60 ScopedEnabler();
56 ~ScopedEnabler(); 61 ~ScopedEnabler();
57 }; 62 };
58 63
59 class ScopedTrace { 64 class ScopedTrace {
60 public: 65 public:
61 ScopedTrace(); 66 ScopedTrace();
62 ~ScopedTrace(); 67 ~ScopedTrace();
63 68
64 // Whether this trace should be initialized or not.
65 bool ShouldInitialize() const;
66
67 // Called only if the tracing category is enabled. |name| is the name of the 69 // Called only if the tracing category is enabled. |name| is the name of the
68 // event to trace (e.g. "Read", "Write") and must have an application 70 // 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 71 // 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. 72 // outlive this class. |size| is the size (in bytes) of this event.
71 void Initialize(const char* name, File* file, int64 size); 73 void Initialize(const char* name, File* file, int64 size);
72 74
73 private: 75 private:
74 // The ID of this trace. Based on the |file| passed to |Initialize()|. Must 76 // The ID of this trace. Based on the |file| passed to |Initialize()|. Must
75 // outlive this class. 77 // outlive this class.
76 void* id_; 78 void* id_;
77 79
78 // The name of the event to trace (e.g. "Read", "Write"). Prefixed with 80 // The name of the event to trace (e.g. "Read", "Write"). Prefixed with
79 // "File". 81 // "File".
80 const char* name_; 82 const char* name_;
81 83
82 DISALLOW_COPY_AND_ASSIGN(ScopedTrace); 84 DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
83 }; 85 };
84 86
85 DISALLOW_COPY_AND_ASSIGN(FileTracing); 87 DISALLOW_COPY_AND_ASSIGN(FileTracing);
86 }; 88 };
87 89
88 } // namespace base 90 } // namespace base
89 91
90 #endif // BASE_FILES_FILE_TRACING_H_ 92 #endif // BASE_FILES_FILE_TRACING_H_
OLDNEW
« no previous file with comments | « base/files/file_posix.cc ('k') | base/files/file_tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698