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

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store.cc

Issue 19442002: Convert to new WebIDBTypes enums and accessors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix content/common/DEPS Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/indexed_db/indexed_db_backing_store_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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" 10 #include "base/strings/string_piece.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h" 13 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
14 #include "content/browser/indexed_db/indexed_db_metadata.h" 14 #include "content/browser/indexed_db/indexed_db_metadata.h"
15 #include "content/browser/indexed_db/indexed_db_tracing.h" 15 #include "content/browser/indexed_db/indexed_db_tracing.h"
16 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h" 16 #include "content/browser/indexed_db/leveldb/leveldb_comparator.h"
17 #include "content/browser/indexed_db/leveldb/leveldb_database.h" 17 #include "content/browser/indexed_db/leveldb/leveldb_database.h"
18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" 18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
20 #include "content/common/indexed_db/indexed_db_key.h" 20 #include "content/common/indexed_db/indexed_db_key.h"
21 #include "content/common/indexed_db/indexed_db_key_path.h" 21 #include "content/common/indexed_db/indexed_db_key_path.h"
22 #include "content/common/indexed_db/indexed_db_key_range.h" 22 #include "content/common/indexed_db/indexed_db_key_range.h"
23 #include "third_party/WebKit/public/platform/WebIDBKey.h" 23 #include "third_party/WebKit/public/platform/WebIDBTypes.h"
24 #include "third_party/WebKit/public/platform/WebIDBKeyPath.h"
25 24
26 using base::StringPiece; 25 using base::StringPiece;
27 26
28 // TODO(jsbell): Make blink push the version during the open() call. 27 // TODO(jsbell): Make blink push the version during the open() call.
29 static const uint32 kWireVersion = 2; 28 static const uint32 kWireVersion = 2;
30 29
31 namespace content { 30 namespace content {
32 31
33 static const int64 kKeyGeneratorInitialNumber = 32 static const int64 kKeyGeneratorInitialNumber =
34 1; // From the IndexedDB specification. 33 1; // From the IndexedDB specification.
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 { 979 {
981 StringPiece slice(it->Value()); 980 StringPiece slice(it->Value());
982 if (!DecodeBool(&slice, &has_key_path)) 981 if (!DecodeBool(&slice, &has_key_path))
983 INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES); 982 INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
984 } 983 }
985 // This check accounts for two layers of legacy coding: 984 // This check accounts for two layers of legacy coding:
986 // (1) Initially, has_key_path was added to distinguish null vs. string. 985 // (1) Initially, has_key_path was added to distinguish null vs. string.
987 // (2) Later, null vs. string vs. array was stored in the key_path itself. 986 // (2) Later, null vs. string vs. array was stored in the key_path itself.
988 // So this check is only relevant for string-type key_paths. 987 // So this check is only relevant for string-type key_paths.
989 if (!has_key_path && 988 if (!has_key_path &&
990 (key_path.type() == WebKit::WebIDBKeyPath::StringType && 989 (key_path.type() == WebKit::WebIDBKeyPathTypeString &&
991 !key_path.string().empty())) { 990 !key_path.string().empty())) {
992 INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES); 991 INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
993 break; 992 break;
994 } 993 }
995 if (!has_key_path) 994 if (!has_key_path)
996 key_path = IndexedDBKeyPath(); 995 key_path = IndexedDBKeyPath();
997 it->Next(); 996 it->Next();
998 } 997 }
999 998
1000 int64 key_generator_current_number = -1; 999 int64 key_generator_current_number = -1;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 it->IsValid() && CompareKeys(it->Key(), stop_key) < 0; 1347 it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
1349 it->Next()) { 1348 it->Next()) {
1350 const char* p = it->Key().begin(); 1349 const char* p = it->Key().begin();
1351 const char* limit = it->Key().end(); 1350 const char* limit = it->Key().end();
1352 1351
1353 ObjectStoreDataKey data_key; 1352 ObjectStoreDataKey data_key;
1354 p = ObjectStoreDataKey::Decode(p, limit, &data_key); 1353 p = ObjectStoreDataKey::Decode(p, limit, &data_key);
1355 DCHECK(p); 1354 DCHECK(p);
1356 1355
1357 scoped_ptr<IndexedDBKey> user_key = data_key.user_key(); 1356 scoped_ptr<IndexedDBKey> user_key = data_key.user_key();
1358 if (user_key->type() == WebKit::WebIDBKey::NumberType) { 1357 if (user_key->type() == WebKit::WebIDBKeyTypeNumber) {
1359 int64 n = static_cast<int64>(user_key->number()); 1358 int64 n = static_cast<int64>(user_key->number());
1360 if (n > max_numeric_key) 1359 if (n > max_numeric_key)
1361 max_numeric_key = n; 1360 max_numeric_key = n;
1362 } 1361 }
1363 } 1362 }
1364 1363
1365 *key_generator_current_number = max_numeric_key + 1; 1364 *key_generator_current_number = max_numeric_key + 1;
1366 return true; 1365 return true;
1367 } 1366 }
1368 1367
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2593 }
2595 2594
2596 void IndexedDBBackingStore::Transaction::Rollback() { 2595 void IndexedDBBackingStore::Transaction::Rollback() {
2597 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback"); 2596 IDB_TRACE("IndexedDBBackingStore::Transaction::Rollback");
2598 DCHECK(transaction_.get()); 2597 DCHECK(transaction_.get());
2599 transaction_->Rollback(); 2598 transaction_->Rollback();
2600 transaction_ = NULL; 2599 transaction_ = NULL;
2601 } 2600 }
2602 2601
2603 } // namespace content 2602 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/indexed_db/indexed_db_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698