OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_tracing.h" | 7 #include "base/files/file_tracing.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
| 10 #include "build/build_config.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 | 13 |
13 File::Info::Info() | 14 File::Info::Info() |
14 : size(0), | 15 : size(0), |
15 is_directory(false), | 16 is_directory(false), |
16 is_symbolic_link(false) { | 17 is_symbolic_link(false) { |
17 } | 18 } |
18 | 19 |
19 File::Info::~Info() { | 20 File::Info::~Info() { |
20 } | 21 } |
21 | 22 |
22 File::File() | 23 File::File() |
23 : error_details_(FILE_ERROR_FAILED), | 24 : error_details_(FILE_ERROR_FAILED), |
24 created_(false), | 25 created_(false), |
25 async_(false) { | 26 async_(false) { |
26 } | 27 } |
27 | 28 |
28 #if !defined(OS_NACL) | 29 #if !defined(OS_NACL) |
29 File::File(const FilePath& path, uint32 flags) | 30 File::File(const FilePath& path, uint32_t flags) |
30 : error_details_(FILE_OK), | 31 : error_details_(FILE_OK), created_(false), async_(false) { |
31 created_(false), | |
32 async_(false) { | |
33 Initialize(path, flags); | 32 Initialize(path, flags); |
34 } | 33 } |
35 #endif | 34 #endif |
36 | 35 |
37 File::File(PlatformFile platform_file) | 36 File::File(PlatformFile platform_file) |
38 : file_(platform_file), | 37 : file_(platform_file), |
39 error_details_(FILE_OK), | 38 error_details_(FILE_OK), |
40 created_(false), | 39 created_(false), |
41 async_(false) { | 40 async_(false) { |
42 #if defined(OS_POSIX) | 41 #if defined(OS_POSIX) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 Close(); | 75 Close(); |
77 SetPlatformFile(other.TakePlatformFile()); | 76 SetPlatformFile(other.TakePlatformFile()); |
78 tracing_path_ = other.tracing_path_; | 77 tracing_path_ = other.tracing_path_; |
79 error_details_ = other.error_details(); | 78 error_details_ = other.error_details(); |
80 created_ = other.created(); | 79 created_ = other.created(); |
81 async_ = other.async_; | 80 async_ = other.async_; |
82 return *this; | 81 return *this; |
83 } | 82 } |
84 | 83 |
85 #if !defined(OS_NACL) | 84 #if !defined(OS_NACL) |
86 void File::Initialize(const FilePath& path, uint32 flags) { | 85 void File::Initialize(const FilePath& path, uint32_t flags) { |
87 if (path.ReferencesParent()) { | 86 if (path.ReferencesParent()) { |
88 error_details_ = FILE_ERROR_ACCESS_DENIED; | 87 error_details_ = FILE_ERROR_ACCESS_DENIED; |
89 return; | 88 return; |
90 } | 89 } |
91 if (FileTracing::IsCategoryEnabled()) | 90 if (FileTracing::IsCategoryEnabled()) |
92 tracing_path_ = path; | 91 tracing_path_ = path; |
93 SCOPED_FILE_TRACE("Initialize"); | 92 SCOPED_FILE_TRACE("Initialize"); |
94 DoInitialize(path, flags); | 93 DoInitialize(path, flags); |
95 } | 94 } |
96 #endif | 95 #endif |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 140 |
142 bool File::Flush() { | 141 bool File::Flush() { |
143 ElapsedTimer timer; | 142 ElapsedTimer timer; |
144 SCOPED_FILE_TRACE("Flush"); | 143 SCOPED_FILE_TRACE("Flush"); |
145 bool return_value = DoFlush(); | 144 bool return_value = DoFlush(); |
146 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); | 145 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); |
147 return return_value; | 146 return return_value; |
148 } | 147 } |
149 | 148 |
150 } // namespace base | 149 } // namespace base |
OLD | NEW |