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

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

Issue 110983004: IndexedDB: More database<->transaction relationship simplification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years 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"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 IndexedDBBackingStore* backing_store, 132 IndexedDBBackingStore* backing_store,
133 IndexedDBFactory* factory, 133 IndexedDBFactory* factory,
134 const Identifier& unique_identifier) 134 const Identifier& unique_identifier)
135 : backing_store_(backing_store), 135 : backing_store_(backing_store),
136 metadata_(name, 136 metadata_(name,
137 kInvalidId, 137 kInvalidId,
138 kNoStringVersion, 138 kNoStringVersion,
139 IndexedDBDatabaseMetadata::NO_INT_VERSION, 139 IndexedDBDatabaseMetadata::NO_INT_VERSION,
140 kInvalidId), 140 kInvalidId),
141 identifier_(unique_identifier), 141 identifier_(unique_identifier),
142 factory_(factory), 142 factory_(factory) {
143 running_version_change_transaction_(NULL) {
144 DCHECK(!metadata_.name.empty()); 143 DCHECK(!metadata_.name.empty());
145 } 144 }
146 145
147 void IndexedDBDatabase::AddObjectStore( 146 void IndexedDBDatabase::AddObjectStore(
148 const IndexedDBObjectStoreMetadata& object_store, 147 const IndexedDBObjectStoreMetadata& object_store,
149 int64 new_max_object_store_id) { 148 int64 new_max_object_store_id) {
150 DCHECK(metadata_.object_stores.find(object_store.id) == 149 DCHECK(metadata_.object_stores.find(object_store.id) ==
151 metadata_.object_stores.end()); 150 metadata_.object_stores.end());
152 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) { 151 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) {
153 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id); 152 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id);
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 transaction->Abort(error); 1251 transaction->Abort(error);
1253 return; 1252 return;
1254 } 1253 }
1255 DCHECK(!pending_second_half_open_); 1254 DCHECK(!pending_second_half_open_);
1256 pending_second_half_open_.reset( 1255 pending_second_half_open_.reset(
1257 new PendingSuccessCall(callbacks, connection.get(), version)); 1256 new PendingSuccessCall(callbacks, connection.get(), version));
1258 callbacks->OnUpgradeNeeded( 1257 callbacks->OnUpgradeNeeded(
1259 old_version, connection.Pass(), metadata(), data_loss, data_loss_message); 1258 old_version, connection.Pass(), metadata(), data_loss, data_loss_message);
1260 } 1259 }
1261 1260
1262 void IndexedDBDatabase::TransactionStarted(IndexedDBTransaction* transaction) {
1263
1264 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) {
1265 DCHECK(!running_version_change_transaction_);
1266 running_version_change_transaction_ = transaction;
1267 }
1268 }
1269
1270 void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction, 1261 void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction,
1271 bool committed) { 1262 bool committed) {
1272 DCHECK(transactions_.find(transaction->id()) != transactions_.end()); 1263 DCHECK(transactions_.find(transaction->id()) != transactions_.end());
1273 DCHECK_EQ(transactions_[transaction->id()], transaction); 1264 DCHECK_EQ(transactions_[transaction->id()], transaction);
1274 transactions_.erase(transaction->id()); 1265 transactions_.erase(transaction->id());
1275 1266
1276 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { 1267 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) {
1277 DCHECK_EQ(transaction, running_version_change_transaction_);
1278 running_version_change_transaction_ = NULL;
1279
1280 if (pending_second_half_open_) { 1268 if (pending_second_half_open_) {
1281 if (committed) { 1269 if (committed) {
1282 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version); 1270 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version);
1283 DCHECK(metadata_.id != kInvalidId); 1271 DCHECK(metadata_.id != kInvalidId);
1284 1272
1285 // Connection was already minted for OnUpgradeNeeded callback. 1273 // Connection was already minted for OnUpgradeNeeded callback.
1286 scoped_ptr<IndexedDBConnection> connection; 1274 scoped_ptr<IndexedDBConnection> connection;
1287 pending_second_half_open_->Callbacks()->OnSuccess(connection.Pass(), 1275 pending_second_half_open_->Callbacks()->OnSuccess(connection.Pass(),
1288 this->metadata()); 1276 this->metadata());
1289 } else { 1277 } else {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 this, 1386 this,
1399 new IndexedDBBackingStore::Transaction(backing_store_))); 1387 new IndexedDBBackingStore::Transaction(backing_store_)));
1400 } 1388 }
1401 1389
1402 void IndexedDBDatabase::TransactionCreated(IndexedDBTransaction* transaction) { 1390 void IndexedDBDatabase::TransactionCreated(IndexedDBTransaction* transaction) {
1403 transactions_[transaction->id()] = transaction; 1391 transactions_[transaction->id()] = transaction;
1404 } 1392 }
1405 1393
1406 bool IndexedDBDatabase::IsOpenConnectionBlocked() const { 1394 bool IndexedDBDatabase::IsOpenConnectionBlocked() const {
1407 return !pending_delete_calls_.empty() || 1395 return !pending_delete_calls_.empty() ||
1408 running_version_change_transaction_ || 1396 transaction_coordinator_.IsRunningVersionChangeTransaction() ||
1409 pending_run_version_change_transaction_call_; 1397 pending_run_version_change_transaction_call_;
1410 } 1398 }
1411 1399
1412 void IndexedDBDatabase::OpenConnection( 1400 void IndexedDBDatabase::OpenConnection(
1413 scoped_refptr<IndexedDBCallbacks> callbacks, 1401 scoped_refptr<IndexedDBCallbacks> callbacks,
1414 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 1402 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
1415 int64 transaction_id, 1403 int64 transaction_id,
1416 int64 version) { 1404 int64 version) {
1417 const blink::WebIDBDataLoss kDataLoss = 1405 const blink::WebIDBDataLoss kDataLoss =
1418 blink::WebIDBDataLossNone; 1406 blink::WebIDBDataLossNone;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 const base::string16& previous_version, 1705 const base::string16& previous_version,
1718 int64 previous_int_version, 1706 int64 previous_int_version,
1719 IndexedDBTransaction* transaction) { 1707 IndexedDBTransaction* transaction) {
1720 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 1708 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
1721 DCHECK(!transaction); 1709 DCHECK(!transaction);
1722 metadata_.version = previous_version; 1710 metadata_.version = previous_version;
1723 metadata_.int_version = previous_int_version; 1711 metadata_.int_version = previous_int_version;
1724 } 1712 }
1725 1713
1726 } // namespace content 1714 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database.h ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698