Chromium Code Reviews| Index: base/files/file.cc |
| diff --git a/base/files/file.cc b/base/files/file.cc |
| index 4c0e5ded47c90d000a7fb6e80ff1e5a160445743..8b8720c0f558936d5079e33b49ca6717db89e7a7 100644 |
| --- a/base/files/file.cc |
| +++ b/base/files/file.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/files/file_path.h" |
| #include "base/metrics/histogram.h" |
| #include "base/timer/elapsed_timer.h" |
| +#include "base/trace_event/trace_event.h" |
| #if defined(OS_POSIX) |
| #include "base/files/file_posix_hooks_internal.h" |
| @@ -29,11 +30,11 @@ File::File() |
| } |
| #if !defined(OS_NACL) |
| -File::File(const FilePath& name, uint32 flags) |
| +File::File(const FilePath& path, uint32 flags) |
| : error_details_(FILE_OK), |
| created_(false), |
| async_(false) { |
| - Initialize(name, flags); |
| + Initialize(path, flags); |
| } |
| #endif |
| @@ -57,18 +58,21 @@ File::File(Error error_details) |
| File::File(RValue other) |
| : file_(other.object->TakePlatformFile()), |
| + path_(other.object->path_), |
| error_details_(other.object->error_details()), |
| created_(other.object->created()), |
| async_(other.object->async_) { |
| #if defined(OS_POSIX) |
| - if (IsValid()) |
| - ProtectFileDescriptor(GetPlatformFile()); |
| + if (IsValid()) |
| + ProtectFileDescriptor(GetPlatformFile()); |
| #endif |
| } |
| File::~File() { |
| // Go through the AssertIOAllowed logic. |
| Close(); |
| + TRACE_EVENT_ASYNC_END1(kTraceGroup, "File", this, |
|
Lei Zhang
2015/04/27 22:55:55
We may not always call TRACE_EVENT_ASYNC_BEGIN1()
Dan Beam
2015/04/28 03:17:11
not sure but just made this TRACE_EVENT_ASYNC_{BEG
|
| + "path", path_.AsUTF8Unsafe()); |
|
Dan Beam
2015/04/24 22:27:02
should I be passing along the path here?
|
| } |
| File& File::operator=(RValue other) { |
| @@ -83,12 +87,15 @@ File& File::operator=(RValue other) { |
| } |
| #if !defined(OS_NACL) |
| -void File::Initialize(const FilePath& name, uint32 flags) { |
| - if (name.ReferencesParent()) { |
| +void File::Initialize(const FilePath& path, uint32 flags) { |
| + path_ = path; |
| + if (path_.ReferencesParent()) { |
| error_details_ = FILE_ERROR_ACCESS_DENIED; |
| return; |
| } |
| - DoInitialize(name, flags); |
| + TRACE_EVENT_ASYNC_BEGIN1(kTraceGroup, "File", this, |
| + "path", path_.AsUTF8Unsafe()); |
| + DoInitialize(flags); |
| } |
| #endif |
| @@ -136,6 +143,9 @@ std::string File::ErrorToString(Error error) { |
| return ""; |
| } |
| +// static |
| +const char File::kTraceGroup[] = TRACE_DISABLED_BY_DEFAULT("file"); |
| + |
| bool File::Flush() { |
| ElapsedTimer timer; |
| bool return_value = DoFlush(); |