OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/trace_event/scoped_file_trace.h" | |
6 | |
7 #include "base/files/file_path.h" | |
8 #include "base/trace_event/trace_event.h" | |
9 | |
10 namespace base { | |
11 | |
12 // static | |
13 const char ScopedFileTrace::kGroup[] = TRACE_DISABLED_BY_DEFAULT("file"); | |
14 | |
15 ScopedFileTrace::ScopedFileTrace( | |
16 const FilePath& path, const char* event, size_t bytes) | |
17 : 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
| |
18 if (bytes_) | |
19 TRACE_EVENT_BEGIN2(kGroup, event_, "path", path_, "bytes", bytes_); | |
20 else | |
21 TRACE_EVENT_BEGIN1(kGroup, event_, "path", path_); | |
22 } | |
23 | |
24 ScopedFileTrace::~ScopedFileTrace() { | |
25 if (bytes_) | |
26 TRACE_EVENT_END2(kGroup, event_, "path", path_, "bytes", bytes_); | |
27 else | |
28 TRACE_EVENT_END1(kGroup, event_, "path", path_); | |
29 } | |
30 | |
31 } // namespace base | |
OLD | NEW |