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

Side by Side Diff: content/browser/indexed_db/indexed_db_database.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
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_database.h" 5 #include "content/browser/indexed_db/indexed_db_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/indexed_db/indexed_db_backing_store.h" 15 #include "content/browser/indexed_db/indexed_db_backing_store.h"
16 #include "content/browser/indexed_db/indexed_db_connection.h" 16 #include "content/browser/indexed_db/indexed_db_connection.h"
17 #include "content/browser/indexed_db/indexed_db_cursor.h" 17 #include "content/browser/indexed_db/indexed_db_cursor.h"
18 #include "content/browser/indexed_db/indexed_db_factory.h" 18 #include "content/browser/indexed_db/indexed_db_factory.h"
19 #include "content/browser/indexed_db/indexed_db_index_writer.h" 19 #include "content/browser/indexed_db/indexed_db_index_writer.h"
20 #include "content/browser/indexed_db/indexed_db_tracing.h" 20 #include "content/browser/indexed_db/indexed_db_tracing.h"
21 #include "content/browser/indexed_db/indexed_db_transaction.h" 21 #include "content/browser/indexed_db/indexed_db_transaction.h"
22 #include "content/common/indexed_db/indexed_db_key_path.h" 22 #include "content/common/indexed_db/indexed_db_key_path.h"
23 #include "content/common/indexed_db/indexed_db_key_range.h" 23 #include "content/common/indexed_db/indexed_db_key_range.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 25 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
26 26
27 using base::Int64ToString16; 27 using base::Int64ToString16;
28 using WebKit::WebIDBKey; 28 using WebKit::WebIDBKeyTypeNumber;
29 29
30 namespace content { 30 namespace content {
31 31
32 class CreateObjectStoreOperation : public IndexedDBTransaction::Operation { 32 class CreateObjectStoreOperation : public IndexedDBTransaction::Operation {
33 public: 33 public:
34 CreateObjectStoreOperation( 34 CreateObjectStoreOperation(
35 scoped_refptr<IndexedDBBackingStore> backing_store, 35 scoped_refptr<IndexedDBBackingStore> backing_store,
36 const IndexedDBObjectStoreMetadata& object_store_metadata) 36 const IndexedDBObjectStoreMetadata& object_store_metadata)
37 : backing_store_(backing_store), 37 : backing_store_(backing_store),
38 object_store_metadata_(object_store_metadata) {} 38 object_store_metadata_(object_store_metadata) {}
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 object_store_id, 975 object_store_id,
976 &current_number); 976 &current_number);
977 if (!ok) { 977 if (!ok) {
978 LOG(ERROR) << "Failed to GetKeyGeneratorCurrentNumber"; 978 LOG(ERROR) << "Failed to GetKeyGeneratorCurrentNumber";
979 return make_scoped_ptr(new IndexedDBKey()); 979 return make_scoped_ptr(new IndexedDBKey());
980 } 980 }
981 if (current_number < 0 || current_number > max_generator_value) 981 if (current_number < 0 || current_number > max_generator_value)
982 return make_scoped_ptr(new IndexedDBKey()); 982 return make_scoped_ptr(new IndexedDBKey());
983 983
984 return make_scoped_ptr( 984 return make_scoped_ptr(
985 new IndexedDBKey(current_number, WebIDBKey::NumberType)); 985 new IndexedDBKey(current_number, WebIDBKeyTypeNumber));
986 } 986 }
987 987
988 static bool UpdateKeyGenerator( 988 static bool UpdateKeyGenerator(
989 scoped_refptr<IndexedDBBackingStore> backing_store, 989 scoped_refptr<IndexedDBBackingStore> backing_store,
990 scoped_refptr<IndexedDBTransaction> transaction, 990 scoped_refptr<IndexedDBTransaction> transaction,
991 int64 database_id, 991 int64 database_id,
992 int64 object_store_id, 992 int64 object_store_id,
993 const IndexedDBKey* key, 993 const IndexedDBKey* key,
994 bool check_current) { 994 bool check_current) {
995 DCHECK(key); 995 DCHECK(key);
996 DCHECK_EQ(WebIDBKey::NumberType, key->type()); 996 DCHECK_EQ(WebIDBKeyTypeNumber, key->type());
997 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber( 997 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber(
998 transaction->BackingStoreTransaction(), 998 transaction->BackingStoreTransaction(),
999 database_id, 999 database_id,
1000 object_store_id, 1000 object_store_id,
1001 static_cast<int64>(floor(key->number())) + 1, 1001 static_cast<int64>(floor(key->number())) + 1,
1002 check_current); 1002 check_current);
1003 } 1003 }
1004 1004
1005 void IndexedDBDatabase::Put(int64 transaction_id, 1005 void IndexedDBDatabase::Put(int64 transaction_id,
1006 int64 object_store_id, 1006 int64 object_store_id,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 IndexWriter* index_writer = index_writers[i]; 1129 IndexWriter* index_writer = index_writers[i];
1130 index_writer->WriteIndexKeys(record_identifier, 1130 index_writer->WriteIndexKeys(record_identifier,
1131 backing_store_, 1131 backing_store_,
1132 transaction->BackingStoreTransaction(), 1132 transaction->BackingStoreTransaction(),
1133 database_id_, 1133 database_id_,
1134 object_store_.id); 1134 object_store_.id);
1135 } 1135 }
1136 1136
1137 if (object_store_.auto_increment && 1137 if (object_store_.auto_increment &&
1138 put_mode_ != IndexedDBDatabase::CURSOR_UPDATE && 1138 put_mode_ != IndexedDBDatabase::CURSOR_UPDATE &&
1139 key->type() == WebIDBKey::NumberType) { 1139 key->type() == WebIDBKeyTypeNumber) {
1140 bool ok = UpdateKeyGenerator(backing_store_, 1140 bool ok = UpdateKeyGenerator(backing_store_,
1141 transaction, 1141 transaction,
1142 database_id_, 1142 database_id_,
1143 object_store_.id, 1143 object_store_.id,
1144 key.get(), 1144 key.get(),
1145 !key_was_generated); 1145 !key_was_generated);
1146 if (!ok) { 1146 if (!ok) {
1147 callbacks_->OnError( 1147 callbacks_->OnError(
1148 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 1148 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError,
1149 "Internal error updating key generator.")); 1149 "Internal error updating key generator."));
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 1925
1926 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( 1926 void IndexedDBDatabase::VersionChangeAbortOperation::Perform(
1927 IndexedDBTransaction* transaction) { 1927 IndexedDBTransaction* transaction) {
1928 IDB_TRACE("VersionChangeAbortOperation"); 1928 IDB_TRACE("VersionChangeAbortOperation");
1929 DCHECK(!transaction); 1929 DCHECK(!transaction);
1930 database_->metadata_.version = previous_version_; 1930 database_->metadata_.version = previous_version_;
1931 database_->metadata_.int_version = previous_int_version_; 1931 database_->metadata_.int_version = previous_int_version_;
1932 } 1932 }
1933 1933
1934 } // namespace content 1934 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698