Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 2 | // 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-doray | fc7952f0 | 2025-06-06 00:04:33 | [diff] [blame] | 8 | #include "base/trace_event/trace_event.h" |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 9 | |
| 10 | namespace content { |
| 11 | |
Alexandr Ilin | 3312663 | 2018-11-14 14:48:17 | [diff] [blame] | 12 | constexpr const char kFileTracingEventCategoryGroup[] = |
| 13 | TRACE_DISABLED_BY_DEFAULT("file"); |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 14 | |
| 15 | FileTracingProviderImpl::FileTracingProviderImpl() {} |
| 16 | FileTracingProviderImpl::~FileTracingProviderImpl() {} |
| 17 | |
| 18 | bool FileTracingProviderImpl::FileTracingCategoryIsEnabled() const { |
| 19 | bool enabled; |
| 20 | TRACE_EVENT_CATEGORY_GROUP_ENABLED(kFileTracingEventCategoryGroup, &enabled); |
| 21 | return enabled; |
| 22 | } |
| 23 | |
kulshin | 00e2bd6 | 2016-07-20 20:57:35 | [diff] [blame] | 24 | void FileTracingProviderImpl::FileTracingEnable(const void* id) { |
Etienne Pierre-doray | e0fb4b16 | 2025-08-07 16:44:48 | [diff] [blame] | 25 | TRACE_EVENT_BEGIN(kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, |
| 26 | perfetto::Track::FromPointer(id)); |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 27 | } |
| 28 | |
kulshin | 00e2bd6 | 2016-07-20 20:57:35 | [diff] [blame] | 29 | void FileTracingProviderImpl::FileTracingDisable(const void* id) { |
Etienne Pierre-doray | e0fb4b16 | 2025-08-07 16:44:48 | [diff] [blame] | 30 | // FILE_TRACING_PREFIX |
| 31 | TRACE_EVENT_END(kFileTracingEventCategoryGroup, |
| 32 | perfetto::Track::FromPointer(id)); |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 33 | } |
| 34 | |
kulshin | 00e2bd6 | 2016-07-20 20:57:35 | [diff] [blame] | 35 | void FileTracingProviderImpl::FileTracingEventBegin(const char* name, |
| 36 | const void* id, |
| 37 | const base::FilePath& path, |
| 38 | int64_t size) { |
Etienne Pierre-doray | e0fb4b16 | 2025-08-07 16:44:48 | [diff] [blame] | 39 | TRACE_EVENT_BEGIN(kFileTracingEventCategoryGroup, |
| 40 | perfetto::DynamicString(name), |
| 41 | perfetto::Track::FromPointer(id), "path", |
| 42 | path.AsUTF8Unsafe(), "size", size); |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 43 | } |
| 44 | |
kulshin | 00e2bd6 | 2016-07-20 20:57:35 | [diff] [blame] | 45 | void FileTracingProviderImpl::FileTracingEventEnd(const char* name, |
| 46 | const void* id) { |
Etienne Pierre-doray | e0fb4b16 | 2025-08-07 16:44:48 | [diff] [blame] | 47 | TRACE_EVENT_END(kFileTracingEventCategoryGroup, |
| 48 | perfetto::Track::FromPointer(id)); |
dbeam | 492dc31b | 2015-05-11 07:53:47 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } // namespace content |