OLD | NEW |
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 "storage/browser/fileapi/sandbox_origin_database.h" | 5 #include "storage/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/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 std::vector<OriginRecord>* origins) { | 284 std::vector<OriginRecord>* origins) { |
285 DCHECK(origins); | 285 DCHECK(origins); |
286 if (!Init(CREATE_IF_NONEXISTENT, REPAIR_ON_CORRUPTION)) { | 286 if (!Init(CREATE_IF_NONEXISTENT, REPAIR_ON_CORRUPTION)) { |
287 origins->clear(); | 287 origins->clear(); |
288 return false; | 288 return false; |
289 } | 289 } |
290 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); | 290 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); |
291 std::string origin_key_prefix = OriginToOriginKey(std::string()); | 291 std::string origin_key_prefix = OriginToOriginKey(std::string()); |
292 iter->Seek(origin_key_prefix); | 292 iter->Seek(origin_key_prefix); |
293 origins->clear(); | 293 origins->clear(); |
294 while (iter->Valid() && | 294 while (iter->Valid() && base::StartsWithASCII(iter->key().ToString(), |
295 StartsWithASCII(iter->key().ToString(), origin_key_prefix, true)) { | 295 origin_key_prefix, true)) { |
296 std::string origin = | 296 std::string origin = |
297 iter->key().ToString().substr(origin_key_prefix.length()); | 297 iter->key().ToString().substr(origin_key_prefix.length()); |
298 base::FilePath path = StringToFilePath(iter->value().ToString()); | 298 base::FilePath path = StringToFilePath(iter->value().ToString()); |
299 origins->push_back(OriginRecord(origin, path)); | 299 origins->push_back(OriginRecord(origin, path)); |
300 iter->Next(); | 300 iter->Next(); |
301 } | 301 } |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 void SandboxOriginDatabase::DropDatabase() { | 305 void SandboxOriginDatabase::DropDatabase() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 340 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
341 if (!status.ok()) { | 341 if (!status.ok()) { |
342 HandleError(FROM_HERE, status); | 342 HandleError(FROM_HERE, status); |
343 return false; | 343 return false; |
344 } | 344 } |
345 *number = -1; | 345 *number = -1; |
346 return true; | 346 return true; |
347 } | 347 } |
348 | 348 |
349 } // namespace storage | 349 } // namespace storage |
OLD | NEW |