summaryrefslogtreecommitdiff
path: root/base/files
diff options
context:
space:
mode:
Diffstat (limited to 'base/files')
-rw-r--r--base/files/dir_reader_fallback.h2
-rw-r--r--base/files/file.h10
-rw-r--r--base/files/file_path.cc11
-rw-r--r--base/files/file_path.h2
-rw-r--r--base/files/file_path_unittest.cc2
-rw-r--r--base/files/file_util_posix.cc4
6 files changed, 21 insertions, 10 deletions
diff --git a/base/files/dir_reader_fallback.h b/base/files/dir_reader_fallback.h
index 4bc199a922..d44c2279e4 100644
--- a/base/files/dir_reader_fallback.h
+++ b/base/files/dir_reader_fallback.h
@@ -11,7 +11,7 @@ class DirReaderFallback {
public:
// Open a directory. If |IsValid| is true, then |Next| can be called to start
// the iteration at the beginning of the directory.
- explicit DirReaderFallback(const char* /* directory_path */) {}
+ explicit DirReaderFallback(const char* directory_path) {}
// After construction, IsValid returns true iff the directory was
// successfully opened.
diff --git a/base/files/file.h b/base/files/file.h
index 94a9d5cf49..0155c7c259 100644
--- a/base/files/file.h
+++ b/base/files/file.h
@@ -255,6 +255,16 @@ class BASE_EXPORT File {
// Instructs the filesystem to flush the file to disk. (POSIX: fsync, Windows:
// FlushFileBuffers).
+ // Calling Flush() does not guarantee file integrity and thus is not a valid
+ // substitute for file integrity checks and recovery codepaths for malformed
+ // files. It can also be *really* slow, so avoid blocking on Flush(),
+ // especially please don't block shutdown on Flush().
+ // Latency percentiles of Flush() across all platforms as of July 2016:
+ // 50 % > 5 ms
+ // 10 % > 58 ms
+ // 1 % > 357 ms
+ // 0.1 % > 1.8 seconds
+ // 0.01 % > 7.6 seconds
bool Flush();
// Updates the file times.
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 9f67f9bc49..5b1eb29dd6 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -53,8 +53,6 @@ StringPieceType::size_type FindDriveLetter(StringPieceType path) {
(path[0] >= L'a' && path[0] <= L'z'))) {
return 1;
}
-#else
- (void)path; // Avoid an unused warning.
#endif // FILE_PATH_USES_DRIVE_LETTERS
return StringType::npos;
}
@@ -176,7 +174,7 @@ FilePath::FilePath() {
FilePath::FilePath(const FilePath& that) : path_(that.path_) {
}
-FilePath::FilePath(FilePath&& that) = default;
+FilePath::FilePath(FilePath&& that) noexcept = default;
FilePath::FilePath(StringPieceType path) {
path.CopyToString(&path_);
@@ -565,6 +563,12 @@ FilePath FilePath::StripTrailingSeparators() const {
}
bool FilePath::ReferencesParent() const {
+ if (path_.find(kParentDirectory) == StringType::npos) {
+ // GetComponents is quite expensive, so avoid calling it in the majority
+ // of cases where there isn't a kParentDirectory anywhere in the path.
+ return false;
+ }
+
std::vector<StringType> components;
GetComponents(&components);
@@ -1328,7 +1332,6 @@ FilePath FilePath::NormalizePathSeparatorsTo(CharType separator) const {
}
return FilePath(copy);
#else
- (void)separator; // Avoid an unused warning.
return *this;
#endif
}
diff --git a/base/files/file_path.h b/base/files/file_path.h
index 02846f6892..0be0ad0b10 100644
--- a/base/files/file_path.h
+++ b/base/files/file_path.h
@@ -184,7 +184,7 @@ class BASE_EXPORT FilePath {
// Constructs FilePath with the contents of |that|, which is left in valid but
// unspecified state.
- FilePath(FilePath&& that);
+ FilePath(FilePath&& that) noexcept;
// Replaces the contents with those of |that|, which is left in valid but
// unspecified state.
FilePath& operator=(FilePath&& that);
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc
index a091e62dd1..9f339527f5 100644
--- a/base/files/file_path_unittest.cc
+++ b/base/files/file_path_unittest.cc
@@ -1306,7 +1306,7 @@ TEST_F(FilePathTest, GetHFSDecomposedFormWithInvalidInput) {
FPL("\xf0\x28\x8c\xbc"),
FPL("\xf0\x28\x8c\x28"),
};
- for (const auto& invalid_input : cases) {
+ for (auto* invalid_input : cases) {
FilePath::StringType observed = FilePath::GetHFSDecomposedForm(
invalid_input);
EXPECT_TRUE(observed.empty());
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index a03ca8d8d8..3501e241e9 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -628,7 +628,7 @@ bool CreateTemporaryDirInDir(const FilePath& base_dir,
return CreateTemporaryDirInDirImpl(base_dir, mkdtemp_template, new_dir);
}
-bool CreateNewTempDirectory(const FilePath::StringType& /*prefix*/,
+bool CreateNewTempDirectory(const FilePath::StringType& prefix,
FilePath* new_temp_path) {
FilePath tmpdir;
if (!GetTempDir(&tmpdir))
@@ -934,8 +934,6 @@ bool GetShmemTempDir(bool executable, FilePath* path) {
*path = FilePath("/dev/shm");
return true;
}
-#else
- (void)executable; // Avoid unused warning when !defined(OS_LINUX).
#endif
return GetTempDir(path);
}