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

Side by Side Diff: webkit/browser/fileapi/sandbox_origin_database.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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/browser/fileapi/sandbox_origin_database.h" 5 #include "webkit/browser/fileapi/sandbox_origin_database.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_enumerator.h"
11 #include "base/format_macros.h" 12 #include "base/format_macros.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" 19 #include "third_party/leveldatabase/src/include/leveldb/db.h"
19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" 20 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
20 #include "webkit/common/fileapi/file_system_util.h" 21 #include "webkit/common/fileapi/file_system_util.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) { 121 bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) {
121 DCHECK(!db_.get()); 122 DCHECK(!db_.get());
122 if (!leveldb::RepairDB(db_path, leveldb::Options()).ok() || 123 if (!leveldb::RepairDB(db_path, leveldb::Options()).ok() ||
123 !Init(FAIL_IF_NONEXISTENT, FAIL_ON_CORRUPTION)) { 124 !Init(FAIL_IF_NONEXISTENT, FAIL_ON_CORRUPTION)) {
124 LOG(WARNING) << "Failed to repair SandboxOriginDatabase."; 125 LOG(WARNING) << "Failed to repair SandboxOriginDatabase.";
125 return false; 126 return false;
126 } 127 }
127 128
128 // See if the repaired entries match with what we have on disk. 129 // See if the repaired entries match with what we have on disk.
129 std::set<base::FilePath> directories; 130 std::set<base::FilePath> directories;
130 file_util::FileEnumerator file_enum(file_system_directory_, 131 base::FileEnumerator file_enum(file_system_directory_,
131 false /* recursive */, 132 false /* recursive */,
132 file_util::FileEnumerator::DIRECTORIES); 133 base::FileEnumerator::DIRECTORIES);
133 base::FilePath path_each; 134 base::FilePath path_each;
134 while (!(path_each = file_enum.Next()).empty()) 135 while (!(path_each = file_enum.Next()).empty())
135 directories.insert(path_each.BaseName()); 136 directories.insert(path_each.BaseName());
136 std::set<base::FilePath>::iterator db_dir_itr = 137 std::set<base::FilePath>::iterator db_dir_itr =
137 directories.find(base::FilePath(kOriginDatabaseName)); 138 directories.find(base::FilePath(kOriginDatabaseName));
138 // Make sure we have the database file in its directory and therefore we are 139 // Make sure we have the database file in its directory and therefore we are
139 // working on the correct path. 140 // working on the correct path.
140 DCHECK(db_dir_itr != directories.end()); 141 DCHECK(db_dir_itr != directories.end());
141 directories.erase(db_dir_itr); 142 directories.erase(db_dir_itr);
142 143
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); 329 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
329 if (!status.ok()) { 330 if (!status.ok()) {
330 HandleError(FROM_HERE, status); 331 HandleError(FROM_HERE, status);
331 return false; 332 return false;
332 } 333 }
333 *number = -1; 334 *number = -1;
334 return true; 335 return true;
335 } 336 }
336 337
337 } // namespace fileapi 338 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_directory_database.cc ('k') | webkit/plugins/npapi/plugin_list_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698