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

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

Issue 14824006: Revert 198820 "Move FileEnumerator to its own file, do some refa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h"
13 #include "base/stl_util.h" 12 #include "base/stl_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/fileapi/file_system_util.h" 14 #include "webkit/fileapi/file_system_util.h"
16 15
17 namespace fileapi { 16 namespace fileapi {
18 17
19 void CorruptDatabase(const base::FilePath& db_path, 18 void CorruptDatabase(const base::FilePath& db_path,
20 leveldb::FileType type, 19 leveldb::FileType type,
21 ptrdiff_t offset, 20 ptrdiff_t offset,
22 size_t size) { 21 size_t size) {
23 base::FileEnumerator file_enum(db_path, false /* not recursive */, 22 file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
24 base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); 23 file_util::FileEnumerator::DIRECTORIES |
24 file_util::FileEnumerator::FILES);
25 base::FilePath file_path; 25 base::FilePath file_path;
26 base::FilePath picked_file_path; 26 base::FilePath picked_file_path;
27 uint64 picked_file_number = kuint64max; 27 uint64 picked_file_number = kuint64max;
28 28
29 while (!(file_path = file_enum.Next()).empty()) { 29 while (!(file_path = file_enum.Next()).empty()) {
30 uint64 number = kuint64max; 30 uint64 number = kuint64max;
31 leveldb::FileType file_type; 31 leveldb::FileType file_type;
32 EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()), 32 EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
33 &number, &file_type)); 33 &number, &file_type));
34 if (file_type == type && 34 if (file_type == type &&
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 82 void DeleteDatabaseFile(const base::FilePath& db_path,
83 leveldb::FileType type) { 83 leveldb::FileType type) {
84 base::FileEnumerator file_enum(db_path, false /* not recursive */, 84 file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
85 base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES); 85 file_util::FileEnumerator::DIRECTORIES |
86 file_util::FileEnumerator::FILES);
86 base::FilePath file_path; 87 base::FilePath file_path;
87 while (!(file_path = file_enum.Next()).empty()) { 88 while (!(file_path = file_enum.Next()).empty()) {
88 uint64 number = kuint64max; 89 uint64 number = kuint64max;
89 leveldb::FileType file_type; 90 leveldb::FileType file_type;
90 EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()), 91 EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
91 &number, &file_type)); 92 &number, &file_type));
92 if (file_type == type) { 93 if (file_type == type) {
93 file_util::Delete(file_path, false); 94 file_util::Delete(file_path, false);
94 // We may have multiple files for the same type, so don't break here. 95 // We may have multiple files for the same type, so don't break here.
95 } 96 }
96 } 97 }
97 98
98 } 99 }
99 100
100 } // namespace fileapi 101 } // namespace fileapi
OLDNEW
« no previous file with comments | « trunk/src/webkit/dom_storage/dom_storage_context.cc ('k') | trunk/src/webkit/fileapi/file_system_directory_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698