Chromium Code Reviews| Index: base/files/file_tracing.cc |
| diff --git a/base/files/file_tracing.cc b/base/files/file_tracing.cc |
| index a1919c464bb0db922634749c695189a097cd39ba..c25772db8ab5a101f47885ce58016eb576687dd7 100644 |
| --- a/base/files/file_tracing.cc |
| +++ b/base/files/file_tracing.cc |
| @@ -27,13 +27,11 @@ FileTracing::ScopedEnabler::~ScopedEnabler() { |
| g_provider->FileTracingDisable(this); |
| } |
| -FileTracing::ScopedTrace::ScopedTrace() : initialized_(false) {} |
| +FileTracing::ScopedTrace::ScopedTrace() : id_(nullptr) {} |
| FileTracing::ScopedTrace::~ScopedTrace() { |
| - if (initialized_ && g_provider) { |
| - g_provider->FileTracingEventEnd( |
| - name_, &file_->trace_enabler_, file_->path_, size_); |
| - } |
| + if (id_ && g_provider) |
| + g_provider->FileTracingEventEnd(name_, id_); |
| } |
| bool FileTracing::ScopedTrace::ShouldInitialize() const { |
| @@ -42,15 +40,13 @@ bool FileTracing::ScopedTrace::ShouldInitialize() const { |
| void FileTracing::ScopedTrace::Initialize( |
| const char* name, File* file, int64 size) { |
| - file_ = file; |
| + if (!g_provider) |
|
Dan Beam
2015/06/08 21:10:30
this prevents ends without corresponding begins
|
| + return; |
| + |
| + id_ = &file->trace_enabler_; |
| name_ = name; |
| - size_ = size; |
| - initialized_ = true; |
| - if (g_provider) { |
| - g_provider->FileTracingEventBegin( |
| - name_, &file_->trace_enabler_, file_->path_, size_); |
| - } |
| + g_provider->FileTracingEventBegin(name_, id_, file->path_, size); |
| } |
| } // namespace base |