Index: base/trace_event/scoped_file_trace.cc |
diff --git a/base/trace_event/scoped_file_trace.cc b/base/trace_event/scoped_file_trace.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5073fead9749b40bacba12cca04214eefc82c682 |
--- /dev/null |
+++ b/base/trace_event/scoped_file_trace.cc |
@@ -0,0 +1,31 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/trace_event/scoped_file_trace.h" |
+ |
+#include "base/files/file_path.h" |
+#include "base/trace_event/trace_event.h" |
+ |
+namespace base { |
+ |
+// static |
+const char ScopedFileTrace::kGroup[] = TRACE_DISABLED_BY_DEFAULT("file"); |
+ |
+ScopedFileTrace::ScopedFileTrace( |
+ const FilePath& path, const char* event, size_t bytes) |
+ : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { |
Sami
2015/04/24 10:42:55
This causes some string copying and memory allocat
Dan Beam
2015/04/24 16:37:19
How is tracing disabled? At compile time or runtim
Dan Beam
2015/04/24 16:44:48
Or we could just add a bool tracing_enabled_.
Sami
2015/04/24 16:45:41
Tracing is enabled at runtime and included in all
Dan Beam
2015/04/24 17:29:50
We could if we want to duplicate some macros or re
Sami
2015/04/24 17:34:47
I'm not sure I follow? TRACE_EVENT<N> works fine w
|
+ if (bytes_) |
+ TRACE_EVENT_BEGIN2(kGroup, event_, "path", path_, "bytes", bytes_); |
+ else |
+ TRACE_EVENT_BEGIN1(kGroup, event_, "path", path_); |
+} |
+ |
+ScopedFileTrace::~ScopedFileTrace() { |
+ if (bytes_) |
+ TRACE_EVENT_END2(kGroup, event_, "path", path_, "bytes", bytes_); |
+ else |
+ TRACE_EVENT_END1(kGroup, event_, "path", path_); |
+} |
+ |
+} // namespace base |