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 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 class IndexedDBDatabase::OpenRequest | 113 class IndexedDBDatabase::OpenRequest |
| 114 : public IndexedDBDatabase::ConnectionRequest { | 114 : public IndexedDBDatabase::ConnectionRequest { |
| 115 public: | 115 public: |
| 116 OpenRequest(scoped_refptr<IndexedDBDatabase> db, | 116 OpenRequest(scoped_refptr<IndexedDBDatabase> db, |
| 117 std::unique_ptr<IndexedDBPendingConnection> pending_connection) | 117 std::unique_ptr<IndexedDBPendingConnection> pending_connection) |
| 118 : ConnectionRequest(db), pending_(std::move(pending_connection)) {} | 118 : ConnectionRequest(db), pending_(std::move(pending_connection)) {} |
| 119 | 119 |
| 120 void Perform() override { | 120 void Perform() override { |
| 121 if (!pending_->callbacks->IsValid()) { | |
| 122 db_->RequestComplete(this); | |
| 123 return; | |
| 124 } | |
| 125 | |
| 121 if (db_->metadata_.id == kInvalidId) { | 126 if (db_->metadata_.id == kInvalidId) { |
| 122 // The database was deleted then immediately re-opened; OpenInternal() | 127 // The database was deleted then immediately re-opened; OpenInternal() |
| 123 // recreates it in the backing store. | 128 // recreates it in the backing store. |
| 124 if (!db_->OpenInternal().ok()) { | 129 if (!db_->OpenInternal().ok()) { |
| 125 // TODO(jsbell): Consider including sanitized leveldb status message. | 130 // TODO(jsbell): Consider including sanitized leveldb status message. |
| 126 base::string16 message; | 131 base::string16 message; |
| 127 if (pending_->version == IndexedDBDatabaseMetadata::NO_VERSION) { | 132 if (pending_->version == IndexedDBDatabaseMetadata::NO_VERSION) { |
| 128 message = ASCIIToUTF16( | 133 message = ASCIIToUTF16( |
| 129 "Internal error opening database with no version specified."); | 134 "Internal error opening database with no version specified."); |
| 130 } else { | 135 } else { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 }; | 288 }; |
| 284 | 289 |
| 285 class IndexedDBDatabase::DeleteRequest | 290 class IndexedDBDatabase::DeleteRequest |
| 286 : public IndexedDBDatabase::ConnectionRequest { | 291 : public IndexedDBDatabase::ConnectionRequest { |
| 287 public: | 292 public: |
| 288 DeleteRequest(scoped_refptr<IndexedDBDatabase> db, | 293 DeleteRequest(scoped_refptr<IndexedDBDatabase> db, |
| 289 scoped_refptr<IndexedDBCallbacks> callbacks) | 294 scoped_refptr<IndexedDBCallbacks> callbacks) |
| 290 : ConnectionRequest(db), callbacks_(callbacks) {} | 295 : ConnectionRequest(db), callbacks_(callbacks) {} |
| 291 | 296 |
| 292 void Perform() override { | 297 void Perform() override { |
| 298 if (!callbacks_->IsValid()) { | |
|
cmumford
2016/10/03 18:39:26
I can see completing the open if disconnecting, bu
jsbell
2016/10/03 19:28:37
Could go either way, yeah. I decided this way for
cmumford
2016/10/03 20:03:34
My main worry is that a normal (i.e. not-crash) sh
jsbell
2016/10/03 20:57:58
That's a very good point, I hadn't considered that
| |
| 299 db_->RequestComplete(this); | |
| 300 return; | |
| 301 } | |
| 302 | |
| 293 if (db_->connections_.empty()) { | 303 if (db_->connections_.empty()) { |
| 294 // No connections, so delete immediately. | 304 // No connections, so delete immediately. |
| 295 DoDelete(); | 305 DoDelete(); |
| 296 return; | 306 return; |
| 297 } | 307 } |
| 298 | 308 |
| 299 // Front end ensures the event is not fired at connections that have | 309 // Front end ensures the event is not fired at connections that have |
| 300 // close_pending set. | 310 // close_pending set. |
| 301 const int64_t old_version = db_->metadata_.version; | 311 const int64_t old_version = db_->metadata_.version; |
| 302 const int64_t new_version = IndexedDBDatabaseMetadata::NO_VERSION; | 312 const int64_t new_version = IndexedDBDatabaseMetadata::NO_VERSION; |
| (...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2128 | 2138 |
| 2129 void IndexedDBDatabase::VersionChangeAbortOperation( | 2139 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 2130 int64_t previous_version, | 2140 int64_t previous_version, |
| 2131 IndexedDBTransaction* transaction) { | 2141 IndexedDBTransaction* transaction) { |
| 2132 DCHECK(!transaction); | 2142 DCHECK(!transaction); |
| 2133 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 2143 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 2134 metadata_.version = previous_version; | 2144 metadata_.version = previous_version; |
| 2135 } | 2145 } |
| 2136 | 2146 |
| 2137 } // namespace content | 2147 } // namespace content |
| OLD | NEW |