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

Side by Side Diff: src/d8.cc

Issue 2462143002: [Tracing] Remove unused excluded categories list. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « include/libplatform/v8-tracing.h ('k') | src/libplatform/tracing/trace-config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 <errno.h> 5 #include <errno.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // String options that can be used to initialize TraceOptions. 198 // String options that can be used to initialize TraceOptions.
199 const char kRecordUntilFull[] = "record-until-full"; 199 const char kRecordUntilFull[] = "record-until-full";
200 const char kRecordContinuously[] = "record-continuously"; 200 const char kRecordContinuously[] = "record-continuously";
201 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible"; 201 const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
202 202
203 const char kRecordModeParam[] = "record_mode"; 203 const char kRecordModeParam[] = "record_mode";
204 const char kEnableSystraceParam[] = "enable_systrace"; 204 const char kEnableSystraceParam[] = "enable_systrace";
205 const char kEnableArgumentFilterParam[] = "enable_argument_filter"; 205 const char kEnableArgumentFilterParam[] = "enable_argument_filter";
206 const char kIncludedCategoriesParam[] = "included_categories"; 206 const char kIncludedCategoriesParam[] = "included_categories";
207 const char kExcludedCategoriesParam[] = "excluded_categories";
208 207
209 class TraceConfigParser { 208 class TraceConfigParser {
210 public: 209 public:
211 static void FillTraceConfig(v8::Isolate* isolate, 210 static void FillTraceConfig(v8::Isolate* isolate,
212 platform::tracing::TraceConfig* trace_config, 211 platform::tracing::TraceConfig* trace_config,
213 const char* json_str) { 212 const char* json_str) {
214 HandleScope outer_scope(isolate); 213 HandleScope outer_scope(isolate);
215 Local<Context> context = Context::New(isolate); 214 Local<Context> context = Context::New(isolate);
216 Context::Scope context_scope(context); 215 Context::Scope context_scope(context);
217 HandleScope inner_scope(isolate); 216 HandleScope inner_scope(isolate);
218 217
219 Local<String> source = 218 Local<String> source =
220 String::NewFromUtf8(isolate, json_str, NewStringType::kNormal) 219 String::NewFromUtf8(isolate, json_str, NewStringType::kNormal)
221 .ToLocalChecked(); 220 .ToLocalChecked();
222 Local<Value> result = JSON::Parse(context, source).ToLocalChecked(); 221 Local<Value> result = JSON::Parse(context, source).ToLocalChecked();
223 Local<v8::Object> trace_config_object = Local<v8::Object>::Cast(result); 222 Local<v8::Object> trace_config_object = Local<v8::Object>::Cast(result);
224 223
225 trace_config->SetTraceRecordMode( 224 trace_config->SetTraceRecordMode(
226 GetTraceRecordMode(isolate, context, trace_config_object)); 225 GetTraceRecordMode(isolate, context, trace_config_object));
227 if (GetBoolean(isolate, context, trace_config_object, 226 if (GetBoolean(isolate, context, trace_config_object,
228 kEnableSystraceParam)) { 227 kEnableSystraceParam)) {
229 trace_config->EnableSystrace(); 228 trace_config->EnableSystrace();
230 } 229 }
231 if (GetBoolean(isolate, context, trace_config_object, 230 if (GetBoolean(isolate, context, trace_config_object,
232 kEnableArgumentFilterParam)) { 231 kEnableArgumentFilterParam)) {
233 trace_config->EnableArgumentFilter(); 232 trace_config->EnableArgumentFilter();
234 } 233 }
235 UpdateCategoriesList(isolate, context, trace_config_object, 234 UpdateIncludedCategoriesList(isolate, context, trace_config_object,
236 kIncludedCategoriesParam, trace_config); 235 trace_config);
237 UpdateCategoriesList(isolate, context, trace_config_object,
238 kExcludedCategoriesParam, trace_config);
239 } 236 }
240 237
241 private: 238 private:
242 static bool GetBoolean(v8::Isolate* isolate, Local<Context> context, 239 static bool GetBoolean(v8::Isolate* isolate, Local<Context> context,
243 Local<v8::Object> object, const char* property) { 240 Local<v8::Object> object, const char* property) {
244 Local<Value> value = GetValue(isolate, context, object, property); 241 Local<Value> value = GetValue(isolate, context, object, property);
245 if (value->IsNumber()) { 242 if (value->IsNumber()) {
246 Local<Boolean> v8_boolean = value->ToBoolean(context).ToLocalChecked(); 243 Local<Boolean> v8_boolean = value->ToBoolean(context).ToLocalChecked();
247 return v8_boolean->Value(); 244 return v8_boolean->Value();
248 } 245 }
249 return false; 246 return false;
250 } 247 }
251 248
252 static int UpdateCategoriesList( 249 static int UpdateIncludedCategoriesList(
253 v8::Isolate* isolate, Local<Context> context, Local<v8::Object> object, 250 v8::Isolate* isolate, Local<Context> context, Local<v8::Object> object,
254 const char* property, platform::tracing::TraceConfig* trace_config) { 251 platform::tracing::TraceConfig* trace_config) {
255 Local<Value> value = GetValue(isolate, context, object, property); 252 Local<Value> value =
253 GetValue(isolate, context, object, kIncludedCategoriesParam);
256 if (value->IsArray()) { 254 if (value->IsArray()) {
257 Local<Array> v8_array = Local<Array>::Cast(value); 255 Local<Array> v8_array = Local<Array>::Cast(value);
258 for (int i = 0, length = v8_array->Length(); i < length; ++i) { 256 for (int i = 0, length = v8_array->Length(); i < length; ++i) {
259 Local<Value> v = v8_array->Get(context, i) 257 Local<Value> v = v8_array->Get(context, i)
260 .ToLocalChecked() 258 .ToLocalChecked()
261 ->ToString(context) 259 ->ToString(context)
262 .ToLocalChecked(); 260 .ToLocalChecked();
263 String::Utf8Value str(v->ToString(context).ToLocalChecked()); 261 String::Utf8Value str(v->ToString(context).ToLocalChecked());
264 if (kIncludedCategoriesParam == property) { 262 trace_config->AddIncludedCategory(*str);
265 trace_config->AddIncludedCategory(*str);
266 } else {
267 trace_config->AddExcludedCategory(*str);
268 }
269 } 263 }
270 return v8_array->Length(); 264 return v8_array->Length();
271 } 265 }
272 return 0; 266 return 0;
273 } 267 }
274 268
275 static platform::tracing::TraceRecordMode GetTraceRecordMode( 269 static platform::tracing::TraceRecordMode GetTraceRecordMode(
276 v8::Isolate* isolate, Local<Context> context, Local<v8::Object> object) { 270 v8::Isolate* isolate, Local<Context> context, Local<v8::Object> object) {
277 Local<Value> value = GetValue(isolate, context, object, kRecordModeParam); 271 Local<Value> value = GetValue(isolate, context, object, kRecordModeParam);
278 if (value->IsString()) { 272 if (value->IsString()) {
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 } 2962 }
2969 2963
2970 } // namespace v8 2964 } // namespace v8
2971 2965
2972 2966
2973 #ifndef GOOGLE3 2967 #ifndef GOOGLE3
2974 int main(int argc, char* argv[]) { 2968 int main(int argc, char* argv[]) {
2975 return v8::Shell::Main(argc, argv); 2969 return v8::Shell::Main(argc, argv);
2976 } 2970 }
2977 #endif 2971 #endif
OLDNEW
« no previous file with comments | « include/libplatform/v8-tracing.h ('k') | src/libplatform/tracing/trace-config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698