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 "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/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 HandleError(FROM_HERE, status); | 258 HandleError(FROM_HERE, status); |
259 return false; | 259 return false; |
260 } | 260 } |
261 | 261 |
262 bool FileSystemOriginDatabase::ListAllOrigins( | 262 bool FileSystemOriginDatabase::ListAllOrigins( |
263 std::vector<OriginRecord>* origins) { | 263 std::vector<OriginRecord>* origins) { |
264 if (!Init(REPAIR_ON_CORRUPTION)) | 264 if (!Init(REPAIR_ON_CORRUPTION)) |
265 return false; | 265 return false; |
266 DCHECK(origins); | 266 DCHECK(origins); |
267 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); | 267 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); |
268 std::string origin_key_prefix = OriginToOriginKey(""); | 268 std::string origin_key_prefix = OriginToOriginKey(std::string()); |
269 iter->Seek(origin_key_prefix); | 269 iter->Seek(origin_key_prefix); |
270 origins->clear(); | 270 origins->clear(); |
271 while (iter->Valid() && | 271 while (iter->Valid() && |
272 StartsWithASCII(iter->key().ToString(), origin_key_prefix, true)) { | 272 StartsWithASCII(iter->key().ToString(), origin_key_prefix, true)) { |
273 std::string origin = | 273 std::string origin = |
274 iter->key().ToString().substr(origin_key_prefix.length()); | 274 iter->key().ToString().substr(origin_key_prefix.length()); |
275 base::FilePath path = StringToFilePath(iter->value().ToString()); | 275 base::FilePath path = StringToFilePath(iter->value().ToString()); |
276 origins->push_back(OriginRecord(origin, path)); | 276 origins->push_back(OriginRecord(origin, path)); |
277 iter->Next(); | 277 iter->Next(); |
278 } | 278 } |
(...skipping 30 matching lines...) Expand all Loading... |
309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
310 if (!status.ok()) { | 310 if (!status.ok()) { |
311 HandleError(FROM_HERE, status); | 311 HandleError(FROM_HERE, status); |
312 return false; | 312 return false; |
313 } | 313 } |
314 *number = -1; | 314 *number = -1; |
315 return true; | 315 return true; |
316 } | 316 } |
317 | 317 |
318 } // namespace fileapi | 318 } // namespace fileapi |
OLD | NEW |