blob: ec9ca0b5fdf609ebbbbbeaa39c9fd09f09566255 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2015 The Chromium Authors
dbeam492dc31b2015-05-11 07:53:472// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "content/browser/tracing/file_tracing_provider_impl.h"
6
7#include "base/files/file_path.h"
Etienne Pierre-dorayfc7952f02025-06-06 00:04:338#include "base/trace_event/trace_event.h"
dbeam492dc31b2015-05-11 07:53:479
10namespace content {
11
Alexandr Ilin33126632018-11-14 14:48:1712constexpr const char kFileTracingEventCategoryGroup[] =
13 TRACE_DISABLED_BY_DEFAULT("file");
dbeam492dc31b2015-05-11 07:53:4714
15FileTracingProviderImpl::FileTracingProviderImpl() {}
16FileTracingProviderImpl::~FileTracingProviderImpl() {}
17
18bool FileTracingProviderImpl::FileTracingCategoryIsEnabled() const {
19 bool enabled;
20 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kFileTracingEventCategoryGroup, &enabled);
21 return enabled;
22}
23
kulshin00e2bd62016-07-20 20:57:3524void FileTracingProviderImpl::FileTracingEnable(const void* id) {
Etienne Pierre-doraye0fb4b162025-08-07 16:44:4825 TRACE_EVENT_BEGIN(kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX,
26 perfetto::Track::FromPointer(id));
dbeam492dc31b2015-05-11 07:53:4727}
28
kulshin00e2bd62016-07-20 20:57:3529void FileTracingProviderImpl::FileTracingDisable(const void* id) {
Etienne Pierre-doraye0fb4b162025-08-07 16:44:4830 // FILE_TRACING_PREFIX
31 TRACE_EVENT_END(kFileTracingEventCategoryGroup,
32 perfetto::Track::FromPointer(id));
dbeam492dc31b2015-05-11 07:53:4733}
34
kulshin00e2bd62016-07-20 20:57:3535void FileTracingProviderImpl::FileTracingEventBegin(const char* name,
36 const void* id,
37 const base::FilePath& path,
38 int64_t size) {
Etienne Pierre-doraye0fb4b162025-08-07 16:44:4839 TRACE_EVENT_BEGIN(kFileTracingEventCategoryGroup,
40 perfetto::DynamicString(name),
41 perfetto::Track::FromPointer(id), "path",
42 path.AsUTF8Unsafe(), "size", size);
dbeam492dc31b2015-05-11 07:53:4743}
44
kulshin00e2bd62016-07-20 20:57:3545void FileTracingProviderImpl::FileTracingEventEnd(const char* name,
46 const void* id) {
Etienne Pierre-doraye0fb4b162025-08-07 16:44:4847 TRACE_EVENT_END(kFileTracingEventCategoryGroup,
48 perfetto::Track::FromPointer(id));
dbeam492dc31b2015-05-11 07:53:4749}
50
51} // namespace content