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

Side by Side Diff: webkit/fileapi/file_system_database_test_helper.cc

Issue 13946004: FileAPI: Run database recovery on IOError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +test Created 7 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/fileapi/file_system_database_test_helper.h" 5 #include "webkit/fileapi/file_system_database_test_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 std::logical_not<char>()); 72 std::logical_not<char>());
73 73
74 int written_size = base::WritePlatformFile(file, offset, 74 int written_size = base::WritePlatformFile(file, offset,
75 vector_as_array(&buf), buf.size()); 75 vector_as_array(&buf), buf.size());
76 EXPECT_GT(written_size, 0); 76 EXPECT_GT(written_size, 0);
77 EXPECT_EQ(buf.size(), static_cast<size_t>(written_size)); 77 EXPECT_EQ(buf.size(), static_cast<size_t>(written_size));
78 78
79 base::ClosePlatformFile(file); 79 base::ClosePlatformFile(file);
80 } 80 }
81 81
82 void DeleteDatabaseFile(const base::FilePath& db_path,
83 leveldb::FileType type) {
84 file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
85 file_util::FileEnumerator::DIRECTORIES |
86 file_util::FileEnumerator::FILES);
87 base::FilePath file_path;
88 base::FilePath picked_file_path;
89 uint64 picked_file_number = kuint64max;
90
91 while (!(file_path = file_enum.Next()).empty()) {
92 uint64 number = kuint64max;
93 leveldb::FileType file_type;
94 EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
95 &number, &file_type));
96 if (file_type == type &&
97 (picked_file_number == kuint64max || picked_file_number < number)) {
98 picked_file_path = file_path;
99 picked_file_number = number;
kinuko 2013/04/10 06:23:49 Maybe we could just delete all files rather than p
tzik 2013/04/10 06:49:20 Done.
100 }
101 }
102
103 EXPECT_FALSE(picked_file_path.empty());
104 EXPECT_NE(kuint64max, picked_file_number);
105
106 file_util::Delete(picked_file_path, false);
107 }
108
82 } // namespace fileapi 109 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698