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

Side by Side Diff: gin/v8_platform.cc

Issue 2368483002: [gin] Add ConvertableToTraceFormatWrapper (Closed)
Patch Set: Align with v8-platform change. Created 4 years, 2 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 unified diff | Download patch
« gin/public/v8_platform.h ('K') | « gin/public/v8_platform.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "gin/public/v8_platform.h" 5 #include "gin/public/v8_platform.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "base/threading/worker_pool.h" 10 #include "base/threading/worker_pool.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const uint8_t* V8Platform::GetCategoryGroupEnabled(const char* name) { 79 const uint8_t* V8Platform::GetCategoryGroupEnabled(const char* name) {
80 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name); 80 return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(name);
81 } 81 }
82 82
83 const char* V8Platform::GetCategoryGroupName( 83 const char* V8Platform::GetCategoryGroupName(
84 const uint8_t* category_enabled_flag) { 84 const uint8_t* category_enabled_flag) {
85 return base::trace_event::TraceLog::GetCategoryGroupName( 85 return base::trace_event::TraceLog::GetCategoryGroupName(
86 category_enabled_flag); 86 category_enabled_flag);
87 } 87 }
88 88
89 uint64_t V8Platform::AddTraceEvent(char phase, 89 namespace {
90 const uint8_t* category_enabled_flag, 90
91 const char* name, 91 class ConvertableToTraceFormatWrapper
92 const char* scope, 92 : public base::trace_event::ConvertableToTraceFormat {
93 uint64_t id, 93 public:
94 uint64_t bind_id, 94 explicit ConvertableToTraceFormatWrapper(
jochen (gone - plz use gerrit) 2016/09/26 15:04:37 please add a virtual dtor
alph 2016/09/26 22:06:56 I wonder why? I'm fine with the default destructor
jochen (gone - plz use gerrit) 2016/09/27 19:09:04 Assuming you'd move this class to a header, it wou
alph 2016/09/27 19:24:23 Done. Though I don't see how it helps. :-) If I mo
95 int32_t num_args, 95 std::unique_ptr<v8::ConvertableToTraceFormat>& inner)
96 const char** arg_names, 96 : inner_(std::move(inner)) {}
97 const uint8_t* arg_types, 97 void AppendAsTraceFormat(std::string* out) const final {
98 const uint64_t* arg_values, 98 inner_->AppendAsTraceFormat(out);
99 unsigned int flags) { 99 }
100
101 private:
102 std::unique_ptr<v8::ConvertableToTraceFormat> inner_;
103 };
jochen (gone - plz use gerrit) 2016/09/26 15:04:37 disallow copy / assign
alph 2016/09/26 22:06:56 Done.
104
105 } // namespace
106
107 uint64_t V8Platform::AddTraceEvent(
108 char phase,
109 const uint8_t* category_enabled_flag,
110 const char* name,
111 const char* scope,
112 uint64_t id,
113 uint64_t bind_id,
114 int32_t num_args,
115 const char** arg_names,
116 const uint8_t* arg_types,
117 const uint64_t* arg_values,
118 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
119 unsigned int flags) {
100 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> convertables[2]; 120 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> convertables[2];
101 if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) { 121 if (num_args > 0 && arg_types[0] == TRACE_VALUE_TYPE_CONVERTABLE) {
102 convertables[0].reset( 122 convertables[0].reset(
103 reinterpret_cast<base::trace_event::ConvertableToTraceFormat*>( 123 new ConvertableToTraceFormatWrapper(arg_convertables[0]));
104 arg_values[0]));
105 } 124 }
106 if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) { 125 if (num_args > 1 && arg_types[1] == TRACE_VALUE_TYPE_CONVERTABLE) {
107 convertables[1].reset( 126 convertables[1].reset(
108 reinterpret_cast<base::trace_event::ConvertableToTraceFormat*>( 127 new ConvertableToTraceFormatWrapper(arg_convertables[1]));
109 arg_values[1]));
110 } 128 }
129 DCHECK(num_args <= 2);
jochen (gone - plz use gerrit) 2016/09/26 15:04:37 DCHECK_LT
alph 2016/09/26 22:06:56 Done.
111 base::trace_event::TraceEventHandle handle = 130 base::trace_event::TraceEventHandle handle =
112 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID( 131 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_BIND_ID(
113 phase, category_enabled_flag, name, scope, id, bind_id, num_args, 132 phase, category_enabled_flag, name, scope, id, bind_id, num_args,
114 arg_names, arg_types, (const long long unsigned int*)arg_values, 133 arg_names, arg_types, (const long long unsigned int*)arg_values,
115 convertables, flags); 134 convertables, flags);
116 uint64_t result; 135 uint64_t result;
117 memcpy(&result, &handle, sizeof(result)); 136 memcpy(&result, &handle, sizeof(result));
118 return result; 137 return result;
119 } 138 }
120 139
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 v8::Platform::TraceStateObserver* observer) { 202 v8::Platform::TraceStateObserver* observer) {
184 g_trace_state_dispatcher.Get().AddObserver(observer); 203 g_trace_state_dispatcher.Get().AddObserver(observer);
185 } 204 }
186 205
187 void V8Platform::RemoveTraceStateObserver( 206 void V8Platform::RemoveTraceStateObserver(
188 v8::Platform::TraceStateObserver* observer) { 207 v8::Platform::TraceStateObserver* observer) {
189 g_trace_state_dispatcher.Get().RemoveObserver(observer); 208 g_trace_state_dispatcher.Get().RemoveObserver(observer);
190 } 209 }
191 210
192 } // namespace gin 211 } // namespace gin
OLDNEW
« gin/public/v8_platform.h ('K') | « gin/public/v8_platform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698