Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: base/files/file_tracing.cc

Issue 1072133006: Add granular file tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@do-initialize
Patch Set: win fixes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698