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

Unified Diff: base/trace_event/scoped_file_trace.cc

Issue 1072133006: Add granular file tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@do-initialize
Patch Set: add async file tracing Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698