Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/browser/tracing/file_tracing_provider_impl.h" | 5 #include "content/browser/tracing/file_tracing_provider_impl.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 void FileTracingProviderImpl::FileTracingEnable(void* id) { | 23 void FileTracingProviderImpl::FileTracingEnable(void* id) { |
| 24 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( | 24 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( |
| 25 kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id); | 25 kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void FileTracingProviderImpl::FileTracingDisable(void* id) { | 28 void FileTracingProviderImpl::FileTracingDisable(void* id) { |
| 29 TRACE_EVENT_NESTABLE_ASYNC_END0( | 29 TRACE_EVENT_NESTABLE_ASYNC_END0( |
| 30 kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id); | 30 kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id); |
| 31 } | 31 } |
| 32 | 32 |
| 33 #define TRACE_VARIED_PARAMS(BEGIN_OR_END) \ | |
|
dsinclair
2015/06/08 13:05:38
I'd prefer not to do this. It makes the code a lot
Dan Beam
2015/06/08 18:42:54
making the code noisier keeps the UI cleaner, but
| |
| 34 const bool has_path = !path.empty(); \ | |
| 35 const bool has_size = size > 0; \ | |
| 36 if (has_path && has_size) { \ | |
| 37 TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##2( \ | |
| 38 kFileTracingEventCategoryGroup, name, id, \ | |
| 39 "path", path.AsUTF8Unsafe(), "size", size); \ | |
| 40 } else if (has_path) { \ | |
| 41 TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##1( \ | |
| 42 kFileTracingEventCategoryGroup, name, id, \ | |
| 43 "path", path.AsUTF8Unsafe()); \ | |
| 44 } else if (has_size) { \ | |
| 45 TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##1( \ | |
| 46 kFileTracingEventCategoryGroup, name, id, \ | |
| 47 "size", size); \ | |
| 48 } else { \ | |
| 49 TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##0( \ | |
| 50 kFileTracingEventCategoryGroup, name, id); \ | |
| 51 } | |
| 52 | |
| 33 void FileTracingProviderImpl::FileTracingEventBegin( | 53 void FileTracingProviderImpl::FileTracingEventBegin( |
| 34 const char* name, void* id, const base::FilePath& path, int64 size) { | 54 const char* name, void* id, const base::FilePath& path, int64 size) { |
| 35 if (size) { | 55 TRACE_VARIED_PARAMS(BEGIN); |
|
oystein (OOO til 10th of July)
2015/06/05 22:06:25
The macro is cool, but I'm not really convinced it
Dan Beam
2015/06/06 01:57:25
I guess I could, but what happens if the params ch
oystein (OOO til 10th of July)
2015/06/08 18:53:47
Hmm... In what situations would the params change?
Dan Beam
2015/06/08 19:22:28
The current implementation wouldn't, but this leve
| |
| 36 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(kFileTracingEventCategoryGroup, name, id, | |
| 37 "path", path.AsUTF8Unsafe(), "size", size); | |
| 38 } else { | |
| 39 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(kFileTracingEventCategoryGroup, name, id, | |
| 40 "path", path.AsUTF8Unsafe()); | |
| 41 } | |
| 42 } | 56 } |
| 43 | 57 |
| 44 void FileTracingProviderImpl::FileTracingEventEnd( | 58 void FileTracingProviderImpl::FileTracingEventEnd( |
| 45 const char* name, void* id, const base::FilePath& path, int64 size) { | 59 const char* name, void* id, const base::FilePath& path, int64 size) { |
| 46 if (size) { | 60 TRACE_VARIED_PARAMS(END); |
| 47 TRACE_EVENT_NESTABLE_ASYNC_END2(kFileTracingEventCategoryGroup, name, id, | |
| 48 "path", path.AsUTF8Unsafe(), "size", size); | |
| 49 } else { | |
| 50 TRACE_EVENT_NESTABLE_ASYNC_END1(kFileTracingEventCategoryGroup, name, id, | |
| 51 "path", path.AsUTF8Unsafe()); | |
| 52 } | |
| 53 } | 61 } |
| 54 | 62 |
| 63 #undef TRACE_VARIED_PARAMS | |
| 64 | |
| 55 } // namespace content | 65 } // namespace content |
| OLD | NEW |