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(kFileTracingEventCategoryGroup, name_, |
| 20 file_, "path", file_->unsafe_path_.AsUTF8Unsafe(), "size", size_); |
| 21 } else { |
| 22 TRACE_EVENT_NESTABLE_ASYNC_END1(kFileTracingEventCategoryGroup, name_, |
| 23 file_, "path", file_->unsafe_path_.AsUTF8Unsafe()); |
| 24 } |
| 25 } |
| 26 } |
| 27 |
| 28 void ScopedFileTrace::Initialize(const char* name, File* file, int64 size) { |
| 29 file_ = file; |
| 30 name_ = name; |
| 31 size_ = size; |
| 32 initialized_ = true; |
| 33 |
| 34 if (size_) { |
| 35 TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(kFileTracingEventCategoryGroup, name_, |
| 36 file_, "path", file_->unsafe_path_.AsUTF8Unsafe(), "size", size_); |
| 37 } else { |
| 38 TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(kFileTracingEventCategoryGroup, name_, |
| 39 file_, "path", file_->unsafe_path_.AsUTF8Unsafe()); |
| 40 } |
| 41 } |
| 42 |
| 43 } // namespace base |
OLD | NEW |