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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_database.cc

Issue 17462005: IndexedDB: Replace transaction's AVLTree with std::map (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased; store node pointers in map to avoid copies Created 7 years, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/indexed_db/leveldb/leveldb_database.h" 5 #include "content/browser/indexed_db/leveldb/leveldb_database.h"
6 6
7 #include <cerrno> 7 #include <cerrno>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 base::SysInfo::AmountOfFreeDiskSpace(file_name) / 1024; 114 base::SysInfo::AmountOfFreeDiskSpace(file_name) / 1024;
115 if (free_disk_space_in_k_bytes < 0) { 115 if (free_disk_space_in_k_bytes < 0) {
116 base::Histogram::FactoryGet( 116 base::Histogram::FactoryGet(
117 "WebCore.IndexedDB.LevelDB.FreeDiskSpaceFailure", 117 "WebCore.IndexedDB.LevelDB.FreeDiskSpaceFailure",
118 1, 118 1,
119 2 /*boundary*/, 119 2 /*boundary*/,
120 2 /*boundary*/ + 1, 120 2 /*boundary*/ + 1,
121 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(1 /*sample*/); 121 base::HistogramBase::kUmaTargetedHistogramFlag)->Add(1 /*sample*/);
122 return -1; 122 return -1;
123 } 123 }
124 int clamped_disk_space_k_bytes = 124 int clamped_disk_space_k_bytes = free_disk_space_in_k_bytes > INT_MAX
125 free_disk_space_in_k_bytes > INT_MAX ? INT_MAX 125 ? INT_MAX
126 : free_disk_space_in_k_bytes; 126 : free_disk_space_in_k_bytes;
127 const uint64 histogram_max = static_cast<uint64>(1e9); 127 const uint64 histogram_max = static_cast<uint64>(1e9);
128 COMPILE_ASSERT(histogram_max <= INT_MAX, histogram_max_too_big); 128 COMPILE_ASSERT(histogram_max <= INT_MAX, histogram_max_too_big);
129 base::Histogram::FactoryGet(name, 129 base::Histogram::FactoryGet(name,
130 1, 130 1,
131 histogram_max, 131 histogram_max,
132 11 /*buckets*/, 132 11 /*buckets*/,
133 base::HistogramBase::kUmaTargetedHistogramFlag) 133 base::HistogramBase::kUmaTargetedHistogramFlag)
134 ->Add(clamped_disk_space_k_bytes); 134 ->Add(clamped_disk_space_k_bytes);
135 return clamped_disk_space_k_bytes; 135 return clamped_disk_space_k_bytes;
136 } 136 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 LEVEL_DB_MAX_ERROR, 261 LEVEL_DB_MAX_ERROR,
262 LEVEL_DB_MAX_ERROR + 1, 262 LEVEL_DB_MAX_ERROR + 1,
263 base::HistogramBase::kUmaTargetedHistogramFlag) 263 base::HistogramBase::kUmaTargetedHistogramFlag)
264 ->Add(leveldb_error); 264 ->Add(leveldb_error);
265 if (s.IsIOError()) 265 if (s.IsIOError())
266 ParseAndHistogramIOErrorDetails(histogram_name, s); 266 ParseAndHistogramIOErrorDetails(histogram_name, s);
267 else 267 else
268 ParseAndHistogramCorruptionDetails(histogram_name, s); 268 ParseAndHistogramCorruptionDetails(histogram_name, s);
269 } 269 }
270 270
271 leveldb::Status LevelDBDatabase::Open( 271 leveldb::Status LevelDBDatabase::Open(const base::FilePath& file_name,
272 const base::FilePath& file_name, 272 const LevelDBComparator* comparator,
273 const LevelDBComparator* comparator, 273 scoped_ptr<LevelDBDatabase>* result,
274 scoped_ptr<LevelDBDatabase>* result, 274 bool* is_disk_full) {
275 bool* is_disk_full) {
276 scoped_ptr<ComparatorAdapter> comparator_adapter( 275 scoped_ptr<ComparatorAdapter> comparator_adapter(
277 new ComparatorAdapter(comparator)); 276 new ComparatorAdapter(comparator));
278 277
279 leveldb::DB* db; 278 leveldb::DB* db;
280 const leveldb::Status s = 279 const leveldb::Status s =
281 OpenDB(comparator_adapter.get(), leveldb::IDBEnv(), file_name, &db); 280 OpenDB(comparator_adapter.get(), leveldb::IDBEnv(), file_name, &db);
282 281
283 if (!s.ok()) { 282 if (!s.ok()) {
284 HistogramLevelDBError("WebCore.IndexedDB.LevelDBOpenErrors", s); 283 HistogramLevelDBError("WebCore.IndexedDB.LevelDBOpenErrors", s);
285 int free_space_k_bytes = CheckFreeSpace("Failure", file_name); 284 int free_space_k_bytes = CheckFreeSpace("Failure", file_name);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 460
462 scoped_ptr<leveldb::Iterator> i(db_->NewIterator(read_options)); 461 scoped_ptr<leveldb::Iterator> i(db_->NewIterator(read_options));
463 return scoped_ptr<LevelDBIterator>(new IteratorImpl(i.Pass())); 462 return scoped_ptr<LevelDBIterator>(new IteratorImpl(i.Pass()));
464 } 463 }
465 464
466 const LevelDBComparator* LevelDBDatabase::Comparator() const { 465 const LevelDBComparator* LevelDBDatabase::Comparator() const {
467 return comparator_; 466 return comparator_;
468 } 467 }
469 468
470 } // namespace content 469 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698