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

Side by Side Diff: trunk/src/webkit/fileapi/file_system_origin_database.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_origin_database.h" 5 #include "webkit/fileapi/file_system_origin_database.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h"
11 #include "base/format_macros.h" 10 #include "base/format_macros.h"
12 #include "base/location.h" 11 #include "base/location.h"
13 #include "base/logging.h" 12 #include "base/logging.h"
14 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
15 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
16 #include "base/string_util.h" 15 #include "base/string_util.h"
17 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" 17 #include "third_party/leveldatabase/src/include/leveldb/db.h"
19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 18 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
20 #include "webkit/fileapi/file_system_util.h" 19 #include "webkit/fileapi/file_system_util.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 bool FileSystemOriginDatabase::RepairDatabase(const std::string& db_path) { 126 bool FileSystemOriginDatabase::RepairDatabase(const std::string& db_path) {
128 DCHECK(!db_.get()); 127 DCHECK(!db_.get());
129 if (!leveldb::RepairDB(db_path, leveldb::Options()).ok() || 128 if (!leveldb::RepairDB(db_path, leveldb::Options()).ok() ||
130 !Init(FAIL_ON_CORRUPTION)) { 129 !Init(FAIL_ON_CORRUPTION)) {
131 LOG(WARNING) << "Failed to repair FileSystemOriginDatabase."; 130 LOG(WARNING) << "Failed to repair FileSystemOriginDatabase.";
132 return false; 131 return false;
133 } 132 }
134 133
135 // See if the repaired entries match with what we have on disk. 134 // See if the repaired entries match with what we have on disk.
136 std::set<base::FilePath> directories; 135 std::set<base::FilePath> directories;
137 base::FileEnumerator file_enum(file_system_directory_, 136 file_util::FileEnumerator file_enum(file_system_directory_,
138 false /* recursive */, 137 false /* recursive */,
139 base::FileEnumerator::DIRECTORIES); 138 file_util::FileEnumerator::DIRECTORIES);
140 base::FilePath path_each; 139 base::FilePath path_each;
141 while (!(path_each = file_enum.Next()).empty()) 140 while (!(path_each = file_enum.Next()).empty())
142 directories.insert(path_each.BaseName()); 141 directories.insert(path_each.BaseName());
143 std::set<base::FilePath>::iterator db_dir_itr = 142 std::set<base::FilePath>::iterator db_dir_itr =
144 directories.find(base::FilePath(kOriginDatabaseName)); 143 directories.find(base::FilePath(kOriginDatabaseName));
145 // Make sure we have the database file in its directory and therefore we are 144 // Make sure we have the database file in its directory and therefore we are
146 // working on the correct path. 145 // working on the correct path.
147 DCHECK(db_dir_itr != directories.end()); 146 DCHECK(db_dir_itr != directories.end());
148 directories.erase(db_dir_itr); 147 directories.erase(db_dir_itr);
149 148
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); 324 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
326 if (!status.ok()) { 325 if (!status.ok()) {
327 HandleError(FROM_HERE, status); 326 HandleError(FROM_HERE, status);
328 return false; 327 return false;
329 } 328 }
330 *number = -1; 329 *number = -1;
331 return true; 330 return true;
332 } 331 }
333 332
334 } // namespace fileapi 333 } // namespace fileapi
OLDNEW
« no previous file with comments | « trunk/src/webkit/fileapi/file_system_directory_database.cc ('k') | trunk/src/webkit/fileapi/isolated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698