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

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

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

Powered by Google App Engine
This is Rietveld 408576698