| OLD | NEW |
| (Empty) |
| 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 "base/files/file_tracing.h" | |
| 6 | |
| 7 #include "base/files/file.h" | |
| 8 #include "base/files/file_path.h" | |
| 9 | |
| 10 namespace base { | |
| 11 | |
| 12 const char kFileTracingEventCategoryGroup[] = TRACE_DISABLED_BY_DEFAULT("file"); | |
| 13 | |
| 14 ScopedFileTrace::ScopedFileTrace() : initialized_(false) {} | |
| 15 | |
| 16 ScopedFileTrace::~ScopedFileTrace() { | |
| 17 if (initialized_) { | |
| 18 if (size_) { | |
| 19 TRACE_EVENT_NESTABLE_ASYNC_END2( | |
| 20 kFileTracingEventCategoryGroup, name_, &file_->trace_enabler_, | |
| 21 "path", file_->path_.AsUTF8Unsafe(), "size", size_); | |
| 22 } else { | |
| 23 TRACE_EVENT_NESTABLE_ASYNC_END1( | |
| 24 kFileTracingEventCategoryGroup, name_, &file_->trace_enabler_, | |
| 25 "path", file_->path_.AsUTF8Unsafe()); | |
| 26 } | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 void ScopedFileTrace::Initialize(const char* name, File* file, int64 size) { | |
| 31 file_ = file; | |
| 32 name_ = name; | |
| 33 size_ = size; | |
| 34 initialized_ = true; | |
| 35 | |
| 36 if (size_) { | |
| 37 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2( | |
| 38 kFileTracingEventCategoryGroup, name_, &file_->trace_enabler_, | |
| 39 "path", file_->path_.AsUTF8Unsafe(), "size", size_); | |
| 40 } else { | |
| 41 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1( | |
| 42 kFileTracingEventCategoryGroup, name_, &file_->trace_enabler_, | |
| 43 "path", file_->path_.AsUTF8Unsafe()); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 } // namespace base | |
| OLD | NEW |