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.
5 #include "base/files/file_tracing.h"
7 #include "base/files/file.h"
12 FileTracing::Provider
* g_provider
= nullptr;
16 bool FileTracing::IsCategoryEnabled() {
17 return g_provider
&& g_provider
->FileTracingCategoryIsEnabled();
21 void FileTracing::SetProvider(FileTracing::Provider
* provider
) {
22 g_provider
= provider
;
25 FileTracing::ScopedEnabler::ScopedEnabler() {
27 g_provider
->FileTracingEnable(this);
30 FileTracing::ScopedEnabler::~ScopedEnabler() {
32 g_provider
->FileTracingDisable(this);
35 FileTracing::ScopedTrace::ScopedTrace() : id_(nullptr) {}
37 FileTracing::ScopedTrace::~ScopedTrace() {
38 if (id_
&& g_provider
)
39 g_provider
->FileTracingEventEnd(name_
, id_
);
42 void FileTracing::ScopedTrace::Initialize(
43 const char* name
, File
* file
, int64 size
) {
44 id_
= &file
->trace_enabler_
;
46 g_provider
->FileTracingEventBegin(name_
, id_
, file
->tracing_path_
, size
);