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

Unified Diff: ppapi/cpp/dev/trace_event_dev.cc

Issue 12212198: Add C++ Trace Event support to PPAPI/NaCl SDK (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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: ppapi/cpp/dev/trace_event_dev.cc
diff --git a/ppapi/cpp/dev/trace_event_dev.cc b/ppapi/cpp/dev/trace_event_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..99854f0d30c8ff2e05a7cb1ea6b0df80d30aed38
--- /dev/null
+++ b/ppapi/cpp/dev/trace_event_dev.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 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 "ppapi/cpp/dev/trace_event_dev.h"
+
+#include "ppapi/c/dev/ppb_trace_event_dev.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Trace_Event_Dev>() {
+ return PPB_TRACE_EVENT_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+namespace trace_events {
+
+const unsigned char* GetCategoryEnabled(const char* category_name) {
+ // This casting is due to limitations in PPAPI. It is unable to return
+ // a const pointer, and all pointer return types are necessarily void*.
+ return reinterpret_cast<const unsigned char*>(
+ get_interface<PPB_Trace_Event_Dev>()->GetCategoryEnabled(category_name));
+}
+
+void AddTraceEvent(char phase,
+ const unsigned char* category_enabled,
+ const char* name,
+ unsigned long long id,
+ int num_args,
+ const char** arg_names,
+ const unsigned char* arg_types,
+ const uint64_t* arg_values,
+ unsigned char flags) {
+ // This casting is due to limitations in PPAPI. 'in' parameters of type mem_t
+ // in the IDL are always const void*.
+ get_interface<PPB_Trace_Event_Dev>()->AddTraceEvent(phase,
+ reinterpret_cast<const void*>(category_enabled), name, id, num_args,
+ arg_names, arg_types, arg_values, flags);
+}
+
+void SetThreadName(const char* thread_name) {
+ get_interface<PPB_Trace_Event_Dev>()->SetThreadName(thread_name);
+}
+
+
+} // namespace trace_events
+
+} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698