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

Unified Diff: content/browser/tracing/file_tracing_provider_impl.cc

Issue 1149083012: Simplify file tracing end events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tracing/file_tracing_provider_impl.cc
diff --git a/content/browser/tracing/file_tracing_provider_impl.cc b/content/browser/tracing/file_tracing_provider_impl.cc
index 21fcf07b5d908df74fb5ebc301caf035904cd97f..c9d6dee08fea77a705dcfbb9da83a4854a567bcb 100644
--- a/content/browser/tracing/file_tracing_provider_impl.cc
+++ b/content/browser/tracing/file_tracing_provider_impl.cc
@@ -30,26 +30,36 @@ void FileTracingProviderImpl::FileTracingDisable(void* id) {
kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id);
}
+#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
+ const bool has_path = !path.empty(); \
+ const bool has_size = size > 0; \
+ if (has_path && has_size) { \
+ TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##2( \
+ kFileTracingEventCategoryGroup, name, id, \
+ "path", path.AsUTF8Unsafe(), "size", size); \
+ } else if (has_path) { \
+ TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##1( \
+ kFileTracingEventCategoryGroup, name, id, \
+ "path", path.AsUTF8Unsafe()); \
+ } else if (has_size) { \
+ TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##1( \
+ kFileTracingEventCategoryGroup, name, id, \
+ "size", size); \
+ } else { \
+ TRACE_EVENT_NESTABLE_ASYNC_##BEGIN_OR_END##0( \
+ kFileTracingEventCategoryGroup, name, id); \
+ }
+
void FileTracingProviderImpl::FileTracingEventBegin(
const char* name, void* id, const base::FilePath& path, int64 size) {
- if (size) {
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(kFileTracingEventCategoryGroup, name, id,
- "path", path.AsUTF8Unsafe(), "size", size);
- } else {
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(kFileTracingEventCategoryGroup, name, id,
- "path", path.AsUTF8Unsafe());
- }
+ 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
}
void FileTracingProviderImpl::FileTracingEventEnd(
const char* name, void* id, const base::FilePath& path, int64 size) {
- if (size) {
- TRACE_EVENT_NESTABLE_ASYNC_END2(kFileTracingEventCategoryGroup, name, id,
- "path", path.AsUTF8Unsafe(), "size", size);
- } else {
- TRACE_EVENT_NESTABLE_ASYNC_END1(kFileTracingEventCategoryGroup, name, id,
- "path", path.AsUTF8Unsafe());
- }
+ TRACE_VARIED_PARAMS(END);
}
+#undef TRACE_VARIED_PARAMS
+
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698