#include "services/tracing/public/cpp/tracing_features.h"
#include "arkweb/build/features/features.h"
#include <string>
#include "base/command_line.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
#include "base/tracing_buildflags.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "components/tracing/common/tracing_switches.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/android_info.h"
#endif
namespace features {
namespace {
BASE_FEATURE(kPerfettoBackendParams,
"kPerfettoBackendParams",
base::FEATURE_DISABLED_BY_DEFAULT);
}
BASE_FEATURE(kTracingServiceInProcess,
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CASTOS)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
BASE_FEATURE(kEnablePerfettoSystemTracing,
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
BASE_FEATURE(kEnablePerfettoSystemBackgroundTracing,
base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE_PARAM(int,
kPerfettoSMBPageSizeBytes,
&kPerfettoBackendParams,
"page_size_bytes",
tracing::kDefaultSMBPageSizeBytes);
BASE_FEATURE_PARAM(int,
kPerfettoSharedMemorySizeBytes,
&kPerfettoBackendParams,
"shared_memory_size_bytes",
tracing::kDefaultSharedMemorySizeBytes);
}
namespace tracing {
bool ShouldSetupSystemTracing() {
#if BUILDFLAG(IS_ANDROID) && !BUILDFLAG(ARKWEB_COMPOSITE_RENDER)
if (base::android::android_info::is_debug_android()) {
return true;
}
#endif
if (base::FeatureList::GetInstance()) {
return base::FeatureList::IsEnabled(features::kEnablePerfettoSystemTracing);
}
return features::kEnablePerfettoSystemTracing.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT;
}
bool SystemBackgroundTracingEnabled() {
return ShouldSetupSystemTracing() &&
base::FeatureList::IsEnabled(
features::kEnablePerfettoSystemBackgroundTracing);
}
}