11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include <string.h>
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include "include/libplatform/v8-tracing.h"
81cb0ef41Sopenharmony_ci#include "src/base/logging.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciclass Isolate;
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cinamespace platform {
151cb0ef41Sopenharmony_cinamespace tracing {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciTraceConfig* TraceConfig::CreateDefaultTraceConfig() {
181cb0ef41Sopenharmony_ci  TraceConfig* trace_config = new TraceConfig();
191cb0ef41Sopenharmony_ci  trace_config->included_categories_.push_back("v8");
201cb0ef41Sopenharmony_ci  return trace_config;
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cibool TraceConfig::IsCategoryGroupEnabled(const char* category_group) const {
241cb0ef41Sopenharmony_ci  std::stringstream category_stream(category_group);
251cb0ef41Sopenharmony_ci  while (category_stream.good()) {
261cb0ef41Sopenharmony_ci    std::string category;
271cb0ef41Sopenharmony_ci    getline(category_stream, category, ',');
281cb0ef41Sopenharmony_ci    for (const auto& included_category : included_categories_) {
291cb0ef41Sopenharmony_ci      if (category == included_category) return true;
301cb0ef41Sopenharmony_ci    }
311cb0ef41Sopenharmony_ci  }
321cb0ef41Sopenharmony_ci  return false;
331cb0ef41Sopenharmony_ci}
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_civoid TraceConfig::AddIncludedCategory(const char* included_category) {
361cb0ef41Sopenharmony_ci  DCHECK(included_category != nullptr && strlen(included_category) > 0);
371cb0ef41Sopenharmony_ci  included_categories_.push_back(included_category);
381cb0ef41Sopenharmony_ci}
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci}  // namespace tracing
411cb0ef41Sopenharmony_ci}  // namespace platform
421cb0ef41Sopenharmony_ci}  // namespace v8
43