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

Side by Side Diff: storage/browser/fileapi/sandbox_directory_database.cc

Issue 1242023005: Remove legacy StartsWithASCII function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: y Created 5 years, 5 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
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 "storage/browser/fileapi/sandbox_directory_database.h" 5 #include "storage/browser/fileapi/sandbox_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <set> 9 #include <set>
10 #include <stack> 10 #include <stack>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 bool DatabaseCheckHelper::ScanDatabase() { 198 bool DatabaseCheckHelper::ScanDatabase() {
199 // Scans all database entries sequentially to verify each of them has unique 199 // Scans all database entries sequentially to verify each of them has unique
200 // backing file. 200 // backing file.
201 int64 max_file_id = -1; 201 int64 max_file_id = -1;
202 std::set<FileId> file_ids; 202 std::set<FileId> file_ids;
203 203
204 scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); 204 scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions()));
205 for (itr->SeekToFirst(); itr->Valid(); itr->Next()) { 205 for (itr->SeekToFirst(); itr->Valid(); itr->Next()) {
206 std::string key = itr->key().ToString(); 206 std::string key = itr->key().ToString();
207 if (base::StartsWithASCII(key, kChildLookupPrefix, true)) { 207 if (base::StartsWith(key, kChildLookupPrefix,
208 base::CompareCase::SENSITIVE)) {
208 // key: "CHILD_OF:<parent_id>:<name>" 209 // key: "CHILD_OF:<parent_id>:<name>"
209 // value: "<child_id>" 210 // value: "<child_id>"
210 ++num_hierarchy_links_in_db_; 211 ++num_hierarchy_links_in_db_;
211 } else if (key == kLastFileIdKey) { 212 } else if (key == kLastFileIdKey) {
212 // key: "LAST_FILE_ID" 213 // key: "LAST_FILE_ID"
213 // value: "<last_file_id>" 214 // value: "<last_file_id>"
214 if (last_file_id_ >= 0 || 215 if (last_file_id_ >= 0 ||
215 !base::StringToInt64(itr->value().ToString(), &last_file_id_)) 216 !base::StringToInt64(itr->value().ToString(), &last_file_id_))
216 return false; 217 return false;
217 218
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 FileId parent_id, std::vector<FileId>* children) { 473 FileId parent_id, std::vector<FileId>* children) {
473 // Check to add later: fail if parent is a file, at least in debug builds. 474 // Check to add later: fail if parent is a file, at least in debug builds.
474 if (!Init(REPAIR_ON_CORRUPTION)) 475 if (!Init(REPAIR_ON_CORRUPTION))
475 return false; 476 return false;
476 DCHECK(children); 477 DCHECK(children);
477 std::string child_key_prefix = GetChildListingKeyPrefix(parent_id); 478 std::string child_key_prefix = GetChildListingKeyPrefix(parent_id);
478 479
479 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); 480 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions()));
480 iter->Seek(child_key_prefix); 481 iter->Seek(child_key_prefix);
481 children->clear(); 482 children->clear();
482 while (iter->Valid() && base::StartsWithASCII(iter->key().ToString(), 483 while (iter->Valid() && base::StartsWith(iter->key().ToString(),
483 child_key_prefix, true)) { 484 child_key_prefix,
485 base::CompareCase::SENSITIVE)) {
484 std::string child_id_string = iter->value().ToString(); 486 std::string child_id_string = iter->value().ToString();
485 FileId child_id; 487 FileId child_id;
486 if (!base::StringToInt64(child_id_string, &child_id)) { 488 if (!base::StringToInt64(child_id_string, &child_id)) {
487 LOG(ERROR) << "Hit database corruption!"; 489 LOG(ERROR) << "Hit database corruption!";
488 return false; 490 return false;
489 } 491 }
490 children->push_back(child_id); 492 children->push_back(child_id);
491 iter->Next(); 493 iter->Next();
492 } 494 }
493 return true; 495 return true;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 940
939 void SandboxDirectoryDatabase::HandleError( 941 void SandboxDirectoryDatabase::HandleError(
940 const tracked_objects::Location& from_here, 942 const tracked_objects::Location& from_here,
941 const leveldb::Status& status) { 943 const leveldb::Status& status) {
942 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " 944 LOG(ERROR) << "SandboxDirectoryDatabase failed at: "
943 << from_here.ToString() << " with error: " << status.ToString(); 945 << from_here.ToString() << " with error: " << status.ToString();
944 db_.reset(); 946 db_.reset();
945 } 947 }
946 948
947 } // namespace storage 949 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/obfuscated_file_util.cc ('k') | storage/browser/fileapi/sandbox_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698