1 // Copyright 2015 The Chromium Authors. All rights reserved.
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"
8 #include "base/trace_event/trace_event.h"
9 
10 namespace content {
11 
12 constexpr const char kFileTracingEventCategoryGroup[] =
13     TRACE_DISABLED_BY_DEFAULT("file");
14 
FileTracingProviderImpl()15 FileTracingProviderImpl::FileTracingProviderImpl() {}
~FileTracingProviderImpl()16 FileTracingProviderImpl::~FileTracingProviderImpl() {}
17 
FileTracingCategoryIsEnabled() const18 bool FileTracingProviderImpl::FileTracingCategoryIsEnabled() const {
19   bool enabled;
20   TRACE_EVENT_CATEGORY_GROUP_ENABLED(kFileTracingEventCategoryGroup, &enabled);
21   return enabled;
22 }
23 
FileTracingEnable(const void * id)24 void FileTracingProviderImpl::FileTracingEnable(const void* id) {
25   TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(
26       kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id);
27 }
28 
FileTracingDisable(const void * id)29 void FileTracingProviderImpl::FileTracingDisable(const void* id) {
30   TRACE_EVENT_NESTABLE_ASYNC_END0(
31       kFileTracingEventCategoryGroup, FILE_TRACING_PREFIX, id);
32 }
33 
FileTracingEventBegin(const char * name,const void * id,const base::FilePath & path,int64_t size)34 void FileTracingProviderImpl::FileTracingEventBegin(const char* name,
35                                                     const void* id,
36                                                     const base::FilePath& path,
37                                                     int64_t size) {
38   TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(kFileTracingEventCategoryGroup, name, id,
39       "path", path.AsUTF8Unsafe(), "size", size);
40 }
41 
FileTracingEventEnd(const char * name,const void * id)42 void FileTracingProviderImpl::FileTracingEventEnd(const char* name,
43                                                   const void* id) {
44   TRACE_EVENT_NESTABLE_ASYNC_END0(kFileTracingEventCategoryGroup, name, id);
45 }
46 
47 }  // namespace content
48