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

Unified Diff: src/tracing/trace-event.h

Issue 2367603002: [tracing] Support ConvertableToTraceFormat argument type. (Closed)
Patch Set: Created 4 years, 3 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 | « src/libplatform/tracing/trace-writer.cc ('k') | test/cctest/libplatform/test-tracing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/tracing/trace-event.h
diff --git a/src/tracing/trace-event.h b/src/tracing/trace-event.h
index 06f8990ec80e4f4463e3034d4b2987b2e821e480..85da5eddd730c130509910c5e1b22432e679f198 100644
--- a/src/tracing/trace-event.h
+++ b/src/tracing/trace-event.h
@@ -6,6 +6,7 @@
#define SRC_TRACING_TRACE_EVENT_H_
#include <stddef.h>
+#include <memory>
#include "base/trace_event/common/trace_event_common.h"
#include "include/v8-platform.h"
@@ -494,6 +495,18 @@ INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string,
#undef INTERNAL_DECLARE_SET_TRACE_VALUE
#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT
+static V8_INLINE void SetTraceValue(ConvertableToTraceFormat* convertable_value,
+ unsigned char* type, uint64_t* value) {
+ *type = TRACE_VALUE_TYPE_CONVERTABLE;
+ *value = static_cast<uint64_t>(reinterpret_cast<intptr_t>(convertable_value));
+}
+
+template <typename T>
+static V8_INLINE void SetTraceValue(std::unique_ptr<T>&& ptr,
caseq 2016/09/23 01:00:50 This does not look well -- we thus accept unique_p
alph 2016/09/23 06:33:24 Done.
+ unsigned char* type, uint64_t* value) {
+ SetTraceValue(ptr.release(), type, value);
+}
+
// These AddTraceEvent template
// function is defined here instead of in the macro, because the arg_values
// could be temporary objects, such as std::string. In order to store
@@ -514,28 +527,30 @@ template <class ARG1_TYPE>
static V8_INLINE uint64_t AddTraceEvent(
char phase, const uint8_t* category_group_enabled, const char* name,
const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags,
- const char* arg1_name, const ARG1_TYPE& arg1_val) {
+ const char* arg1_name, ARG1_TYPE&& arg1_val) {
const int num_args = 1;
- uint8_t arg_types[1];
- uint64_t arg_values[1];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
+ uint8_t arg_type;
+ uint64_t arg_value;
+ SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_type, &arg_value);
return TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, category_group_enabled, name, scope, id, bind_id, num_args,
- &arg1_name, arg_types, arg_values, flags);
+ &arg1_name, &arg_type, &arg_value, flags);
}
template <class ARG1_TYPE, class ARG2_TYPE>
static V8_INLINE uint64_t AddTraceEvent(
char phase, const uint8_t* category_group_enabled, const char* name,
const char* scope, uint64_t id, uint64_t bind_id, unsigned int flags,
- const char* arg1_name, const ARG1_TYPE& arg1_val, const char* arg2_name,
- const ARG2_TYPE& arg2_val) {
+ const char* arg1_name, ARG1_TYPE&& arg1_val, const char* arg2_name,
+ ARG2_TYPE&& arg2_val) {
const int num_args = 2;
const char* arg_names[2] = {arg1_name, arg2_name};
unsigned char arg_types[2];
uint64_t arg_values[2];
- SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]);
- SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]);
+ SetTraceValue(std::forward<ARG1_TYPE>(arg1_val), &arg_types[0],
+ &arg_values[0]);
+ SetTraceValue(std::forward<ARG2_TYPE>(arg2_val), &arg_types[1],
+ &arg_values[1]);
return TRACE_EVENT_API_ADD_TRACE_EVENT(
phase, category_group_enabled, name, scope, id, bind_id, num_args,
arg_names, arg_types, arg_values, flags);
« no previous file with comments | « src/libplatform/tracing/trace-writer.cc ('k') | test/cctest/libplatform/test-tracing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698