| OLD | NEW |
| 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/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_piece.h" | |
| 11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" | 12 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" |
| 14 #include "content/browser/indexed_db/indexed_db_metadata.h" | 13 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 15 #include "content/browser/indexed_db/indexed_db_tracing.h" | 14 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 16 #include "content/browser/indexed_db/indexed_db_value.h" | 15 #include "content/browser/indexed_db/indexed_db_value.h" |
| 17 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" | 16 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" |
| 18 #include "content/browser/indexed_db/leveldb/leveldb_database.h" | 17 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
| 19 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" | 18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" |
| 20 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" | 19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 204 } |
| 206 | 205 |
| 207 static int CompareKeys(const StringPiece& a, const StringPiece& b) { | 206 static int CompareKeys(const StringPiece& a, const StringPiece& b) { |
| 208 return Compare(a, b, false /*index_keys*/); | 207 return Compare(a, b, false /*index_keys*/); |
| 209 } | 208 } |
| 210 | 209 |
| 211 static int CompareIndexKeys(const StringPiece& a, const StringPiece& b) { | 210 static int CompareIndexKeys(const StringPiece& a, const StringPiece& b) { |
| 212 return Compare(a, b, true /*index_keys*/); | 211 return Compare(a, b, true /*index_keys*/); |
| 213 } | 212 } |
| 214 | 213 |
| 215 class Comparator : public LevelDBComparator { | 214 int IndexedDBBackingStore::Comparator::Compare(const StringPiece& a, |
| 216 public: | 215 const StringPiece& b) const { |
| 217 virtual int Compare(const StringPiece& a, const StringPiece& b) const | 216 return content::Compare(a, b, false /*index_keys*/); |
| 218 OVERRIDE { | 217 } |
| 219 return content::Compare(a, b, false /*index_keys*/); | 218 |
| 220 } | 219 const char* IndexedDBBackingStore::Comparator::Name() const { |
| 221 virtual const char* Name() const OVERRIDE { return "idb_cmp1"; } | 220 return "idb_cmp1"; |
| 222 }; | 221 } |
| 223 | 222 |
| 224 // 0 - Initial version. | 223 // 0 - Initial version. |
| 225 // 1 - Adds UserIntVersion to DatabaseMetaData. | 224 // 1 - Adds UserIntVersion to DatabaseMetaData. |
| 226 // 2 - Adds DataVersion to to global metadata. | 225 // 2 - Adds DataVersion to to global metadata. |
| 227 static const int64 kLatestKnownSchemaVersion = 2; | 226 static const int64 kLatestKnownSchemaVersion = 2; |
| 228 WARN_UNUSED_RESULT static bool IsSchemaKnown(LevelDBDatabase* db, bool* known) { | 227 WARN_UNUSED_RESULT static bool IsSchemaKnown(LevelDBDatabase* db, bool* known) { |
| 229 int64 db_schema_version = 0; | 228 int64 db_schema_version = 0; |
| 230 bool found = false; | 229 bool found = false; |
| 231 leveldb::Status s = | 230 leveldb::Status s = |
| 232 GetInt(db, SchemaVersionKey::Encode(), &db_schema_version, &found); | 231 GetInt(db, SchemaVersionKey::Encode(), &db_schema_version, &found); |
| (...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 } | 2644 } |
| 2646 | 2645 |
| 2647 void IndexedDBBackingStore::Transaction::Rollback() { | 2646 void IndexedDBBackingStore::Transaction::Rollback() { |
| 2648 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); | 2647 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); |
| 2649 DCHECK(transaction_.get()); | 2648 DCHECK(transaction_.get()); |
| 2650 transaction_->Rollback(); | 2649 transaction_->Rollback(); |
| 2651 transaction_ = NULL; | 2650 transaction_ = NULL; |
| 2652 } | 2651 } |
| 2653 | 2652 |
| 2654 } // namespace content | 2653 } // namespace content |
| OLD | NEW |