Chromium Code Reviews| 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_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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 const int64 transaction_id_; | 78 const int64 transaction_id_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // PendingSuccessCall has a IndexedDBConnection* because the connection is now | 81 // PendingSuccessCall has a IndexedDBConnection* because the connection is now |
| 82 // owned elsewhere, but we need to cancel the success call if that connection | 82 // owned elsewhere, but we need to cancel the success call if that connection |
| 83 // closes before it is sent. | 83 // closes before it is sent. |
| 84 class IndexedDBDatabase::PendingSuccessCall { | 84 class IndexedDBDatabase::PendingSuccessCall { |
| 85 public: | 85 public: |
| 86 PendingSuccessCall(scoped_refptr<IndexedDBCallbacks> callbacks, | 86 PendingSuccessCall(scoped_refptr<IndexedDBCallbacks> callbacks, |
| 87 IndexedDBConnection* connection, | 87 IndexedDBConnection* connection, |
| 88 int64 transaction_id, | |
|
jsbell
2013/11/14 23:34:12
Nice!
| |
| 89 int64 version) | 88 int64 version) |
| 90 : callbacks_(callbacks), | 89 : callbacks_(callbacks), |
| 91 connection_(connection), | 90 connection_(connection), |
| 92 version_(version), | 91 version_(version) {} |
| 93 transaction_id_(transaction_id) {} | |
| 94 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } | 92 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } |
| 95 IndexedDBConnection* Connection() { return connection_; } | 93 IndexedDBConnection* Connection() { return connection_; } |
| 96 int64 Version() { return version_; } | 94 int64 Version() { return version_; } |
| 97 int64 TransactionId() const { return transaction_id_; } | |
| 98 | 95 |
| 99 private: | 96 private: |
| 100 scoped_refptr<IndexedDBCallbacks> callbacks_; | 97 scoped_refptr<IndexedDBCallbacks> callbacks_; |
| 101 IndexedDBConnection* connection_; | 98 IndexedDBConnection* connection_; |
| 102 int64 version_; | 99 int64 version_; |
| 103 const int64 transaction_id_; | |
| 104 }; | 100 }; |
| 105 | 101 |
| 106 class IndexedDBDatabase::PendingDeleteCall { | 102 class IndexedDBDatabase::PendingDeleteCall { |
| 107 public: | 103 public: |
| 108 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacks> callbacks) | 104 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacks> callbacks) |
| 109 : callbacks_(callbacks) {} | 105 : callbacks_(callbacks) {} |
| 110 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } | 106 scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } |
| 111 | 107 |
| 112 private: | 108 private: |
| 113 scoped_refptr<IndexedDBCallbacks> callbacks_; | 109 scoped_refptr<IndexedDBCallbacks> callbacks_; |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1252 blink::WebIDBDatabaseExceptionUnknownError, | 1248 blink::WebIDBDatabaseExceptionUnknownError, |
| 1253 ASCIIToUTF16( | 1249 ASCIIToUTF16( |
| 1254 "Internal error writing data to stable storage when " | 1250 "Internal error writing data to stable storage when " |
| 1255 "updating version.")); | 1251 "updating version.")); |
| 1256 callbacks->OnError(error); | 1252 callbacks->OnError(error); |
| 1257 transaction->Abort(error); | 1253 transaction->Abort(error); |
| 1258 return; | 1254 return; |
| 1259 } | 1255 } |
| 1260 DCHECK(!pending_second_half_open_); | 1256 DCHECK(!pending_second_half_open_); |
| 1261 pending_second_half_open_.reset(new PendingSuccessCall( | 1257 pending_second_half_open_.reset(new PendingSuccessCall( |
| 1262 callbacks, connection.get(), transaction->id(), version)); | 1258 callbacks, connection.get(), version)); |
| 1263 callbacks->OnUpgradeNeeded( | 1259 callbacks->OnUpgradeNeeded( |
| 1264 old_version, connection.Pass(), metadata(), data_loss, data_loss_message); | 1260 old_version, connection.Pass(), metadata(), data_loss, data_loss_message); |
| 1265 } | 1261 } |
| 1266 | 1262 |
| 1267 void IndexedDBDatabase::TransactionStarted(IndexedDBTransaction* transaction) { | 1263 void IndexedDBDatabase::TransactionStarted(IndexedDBTransaction* transaction) { |
| 1268 | 1264 |
| 1269 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { | 1265 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { |
| 1270 DCHECK(!running_version_change_transaction_); | 1266 DCHECK(!running_version_change_transaction_); |
| 1271 running_version_change_transaction_ = transaction; | 1267 running_version_change_transaction_ = transaction; |
| 1272 } | 1268 } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1723 const string16& previous_version, | 1719 const string16& previous_version, |
| 1724 int64 previous_int_version, | 1720 int64 previous_int_version, |
| 1725 IndexedDBTransaction* transaction) { | 1721 IndexedDBTransaction* transaction) { |
| 1726 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1722 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 1727 DCHECK(!transaction); | 1723 DCHECK(!transaction); |
| 1728 metadata_.version = previous_version; | 1724 metadata_.version = previous_version; |
| 1729 metadata_.int_version = previous_int_version; | 1725 metadata_.int_version = previous_int_version; |
| 1730 } | 1726 } |
| 1731 | 1727 |
| 1732 } // namespace content | 1728 } // namespace content |
| OLD | NEW |