Index: base/files/file.cc |
diff --git a/base/files/file.cc b/base/files/file.cc |
index 8030bf13734e8a6b20bfe4f8f45ccc738885e075..c848c3177bf458335d5cc72ab1cc3745b7d15578 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" |
namespace base { |
@@ -22,14 +23,16 @@ File::File() |
: error_details_(FILE_ERROR_FAILED), |
created_(false), |
async_(false) { |
+ TRACE_EVENT_ASYNC_BEGIN0(kTraceGroup, "File", this); |
} |
#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); |
+ TRACE_EVENT_ASYNC_BEGIN0(kTraceGroup, "File", this); |
+ Initialize(path, flags); |
} |
#endif |
@@ -41,30 +44,36 @@ File::File(PlatformFile platform_file) |
#if defined(OS_POSIX) |
DCHECK_GE(platform_file, -1); |
#endif |
+ TRACE_EVENT_ASYNC_BEGIN0(kTraceGroup, "File", this); |
} |
File::File(Error error_details) |
: error_details_(error_details), |
created_(false), |
async_(false) { |
+ TRACE_EVENT_ASYNC_BEGIN0(kTraceGroup, "File", this); |
} |
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_) { |
+ TRACE_EVENT_ASYNC_BEGIN0(kTraceGroup, "File", this); |
} |
File::~File() { |
// Go through the AssertIOAllowed logic. |
Close(); |
+ TRACE_EVENT_ASYNC_END0(kTraceGroup, "File", this); |
} |
File& File::operator=(RValue other) { |
if (this != other.object) { |
Close(); |
SetPlatformFile(other.object->TakePlatformFile()); |
+ path_ = other.object->path_; |
error_details_ = other.object->error_details(); |
created_ = other.object->created(); |
async_ = other.object->async_; |
@@ -73,12 +82,14 @@ 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_EVENT1(kTraceGroup, "Initialize", "path", path_.AsUTF8Unsafe()); |
+ DoInitialize(flags); |
} |
#endif |
@@ -126,6 +137,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(); |