Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 backing_store, | 52 backing_store, |
| 53 factory, | 53 factory, |
| 54 IndexedDBDatabase::Identifier()); | 54 IndexedDBDatabase::Identifier()); |
| 55 | 55 |
| 56 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 56 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 57 | 57 |
| 58 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); | 58 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); |
| 59 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( | 59 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( |
| 60 new MockIndexedDBDatabaseCallbacks()); | 60 new MockIndexedDBDatabaseCallbacks()); |
| 61 const int64 transaction_id1 = 1; | 61 const int64 transaction_id1 = 1; |
| 62 db->OpenConnection(request1, | 62 IndexedDBPendingConnection connection1( |
| 63 callbacks1, | 63 request1, |
| 64 transaction_id1, | 64 callbacks1, |
| 65 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 65 0 /* fake child_process_id */, |
|
jsbell
2014/03/12 23:40:49
For consistency, make this a const int?
ericu
2014/03/12 23:56:37
Done.
| |
| 66 transaction_id1, | |
| 67 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 68 db->OpenConnection(connection1); | |
| 66 | 69 |
| 67 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0 | 70 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0 |
| 68 | 71 |
| 69 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks()); | 72 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks()); |
| 70 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2( | 73 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2( |
| 71 new MockIndexedDBDatabaseCallbacks()); | 74 new MockIndexedDBDatabaseCallbacks()); |
| 72 const int64 transaction_id2 = 2; | 75 const int64 transaction_id2 = 2; |
| 73 db->OpenConnection(request2, | 76 IndexedDBPendingConnection connection2( |
| 74 callbacks2, | 77 request2, |
| 75 transaction_id2, | 78 callbacks2, |
| 76 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 79 0 /* fake child_process_id */, |
| 80 transaction_id2, | |
| 81 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 82 db->OpenConnection(connection2); | |
| 77 | 83 |
| 78 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection | 84 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection |
| 79 | 85 |
| 80 request1->connection()->ForceClose(); | 86 request1->connection()->ForceClose(); |
| 81 EXPECT_FALSE(request1->connection()->IsConnected()); | 87 EXPECT_FALSE(request1->connection()->IsConnected()); |
| 82 | 88 |
| 83 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection | 89 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection |
| 84 | 90 |
| 85 request2->connection()->ForceClose(); | 91 request2->connection()->ForceClose(); |
| 86 EXPECT_FALSE(request2->connection()->IsConnected()); | 92 EXPECT_FALSE(request2->connection()->IsConnected()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 102 backing_store, | 108 backing_store, |
| 103 factory, | 109 factory, |
| 104 IndexedDBDatabase::Identifier()); | 110 IndexedDBDatabase::Identifier()); |
| 105 | 111 |
| 106 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 112 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 107 | 113 |
| 108 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks( | 114 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks( |
| 109 new MockIndexedDBDatabaseCallbacks()); | 115 new MockIndexedDBDatabaseCallbacks()); |
| 110 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks()); | 116 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks()); |
| 111 const int64 upgrade_transaction_id = 3; | 117 const int64 upgrade_transaction_id = 3; |
| 112 database->OpenConnection(request, | 118 IndexedDBPendingConnection connection( |
| 113 callbacks, | 119 request, |
| 114 upgrade_transaction_id, | 120 callbacks, |
| 115 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 121 0 /* fake child_process_id */, |
| 122 upgrade_transaction_id, | |
| 123 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 124 database->OpenConnection(connection); | |
| 116 EXPECT_EQ(database, request->connection()->database()); | 125 EXPECT_EQ(database, request->connection()->database()); |
| 117 | 126 |
| 118 const int64 transaction_id = 123; | 127 const int64 transaction_id = 123; |
| 119 const std::vector<int64> scope; | 128 const std::vector<int64> scope; |
| 120 database->CreateTransaction(transaction_id, | 129 database->CreateTransaction(transaction_id, |
| 121 request->connection(), | 130 request->connection(), |
| 122 scope, | 131 scope, |
| 123 indexed_db::TRANSACTION_READ_ONLY); | 132 indexed_db::TRANSACTION_READ_ONLY); |
| 124 | 133 |
| 125 request->connection()->ForceClose(); | 134 request->connection()->ForceClose(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 backing_store, | 169 backing_store, |
| 161 factory, | 170 factory, |
| 162 IndexedDBDatabase::Identifier()); | 171 IndexedDBDatabase::Identifier()); |
| 163 | 172 |
| 164 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 173 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 165 | 174 |
| 166 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); | 175 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); |
| 167 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( | 176 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( |
| 168 new MockIndexedDBDatabaseCallbacks()); | 177 new MockIndexedDBDatabaseCallbacks()); |
| 169 const int64 transaction_id1 = 1; | 178 const int64 transaction_id1 = 1; |
| 170 db->OpenConnection(request1, | 179 IndexedDBPendingConnection connection( |
| 171 callbacks1, | 180 request1, |
| 172 transaction_id1, | 181 callbacks1, |
| 173 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 182 0 /* fake child_process_id */, |
| 183 transaction_id1, | |
| 184 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 185 db->OpenConnection(connection); | |
| 174 | 186 |
| 175 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 187 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 176 | 188 |
| 177 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); | 189 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); |
| 178 db->DeleteDatabase(request2); | 190 db->DeleteDatabase(request2); |
| 179 | 191 |
| 180 EXPECT_TRUE(request2->blocked_called()); | 192 EXPECT_TRUE(request2->blocked_called()); |
| 181 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 193 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 182 | 194 |
| 183 db->Close(request1->connection(), true /* forced */); | 195 db->Close(request1->connection(), true /* forced */); |
| 184 | 196 |
| 185 EXPECT_FALSE(db->backing_store()); | 197 EXPECT_FALSE(db->backing_store()); |
| 186 EXPECT_TRUE(backing_store->HasOneRef()); // local | 198 EXPECT_TRUE(backing_store->HasOneRef()); // local |
| 187 } | 199 } |
| 188 | 200 |
| 189 } // namespace content | 201 } // namespace content |
| OLD | NEW |