| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2013 Google Inc. All rights reserved. | 2  * Copyright (C) 2013 Google Inc. All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions are | 5  * modification, are permitted provided that the following conditions are | 
| 6  * met: | 6  * met: | 
| 7  * | 7  * | 
| 8  *     * Redistributions of source code must retain the above copyright | 8  *     * Redistributions of source code must retain the above copyright | 
| 9  * notice, this list of conditions and the following disclaimer. | 9  * notice, this list of conditions and the following disclaimer. | 
| 10  *     * Redistributions in binary form must reproduce the above | 10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 94     EXPECT_CALL(*backend, close()) | 94     EXPECT_CALL(*backend, close()) | 
| 95         .Times(1); | 95         .Times(1); | 
| 96     Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), back
     end.release(), FakeIDBDatabaseCallbacks::create()); | 96     Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), back
     end.release(), FakeIDBDatabaseCallbacks::create()); | 
| 97 | 97 | 
| 98     const int64_t transactionId = 1234; | 98     const int64_t transactionId = 1234; | 
| 99     const HashSet<String> transactionScope = HashSet<String>(); | 99     const HashSet<String> transactionScope = HashSet<String>(); | 
| 100     Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta
     te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); | 100     Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta
     te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); | 
| 101     PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 101     PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 
| 102     set.add(transaction); | 102     set.add(transaction); | 
| 103 | 103 | 
| 104     ThreadHeap::collectAllGarbage(); | 104     Heap::collectAllGarbage(); | 
| 105     EXPECT_EQ(1u, set.size()); | 105     EXPECT_EQ(1u, set.size()); | 
| 106 | 106 | 
| 107     Persistent<IDBRequest> request = IDBRequest::create(getScriptState(), IDBAny
     ::createUndefined(), transaction.get()); | 107     Persistent<IDBRequest> request = IDBRequest::create(getScriptState(), IDBAny
     ::createUndefined(), transaction.get()); | 
| 108     deactivateNewTransactions(); | 108     deactivateNewTransactions(); | 
| 109 | 109 | 
| 110     ThreadHeap::collectAllGarbage(); | 110     Heap::collectAllGarbage(); | 
| 111     EXPECT_EQ(1u, set.size()); | 111     EXPECT_EQ(1u, set.size()); | 
| 112 | 112 | 
| 113     // This will generate an abort() call to the back end which is dropped by th
     e fake proxy, | 113     // This will generate an abort() call to the back end which is dropped by th
     e fake proxy, | 
| 114     // so an explicit onAbort call is made. | 114     // so an explicit onAbort call is made. | 
| 115     getExecutionContext()->stopActiveDOMObjects(); | 115     getExecutionContext()->stopActiveDOMObjects(); | 
| 116     transaction->onAbort(DOMException::create(AbortError, "Aborted")); | 116     transaction->onAbort(DOMException::create(AbortError, "Aborted")); | 
| 117     transaction.clear(); | 117     transaction.clear(); | 
| 118 | 118 | 
| 119     ThreadHeap::collectAllGarbage(); | 119     Heap::collectAllGarbage(); | 
| 120     EXPECT_EQ(0u, set.size()); | 120     EXPECT_EQ(0u, set.size()); | 
| 121 } | 121 } | 
| 122 | 122 | 
| 123 TEST_F(IDBTransactionTest, TransactionFinish) | 123 TEST_F(IDBTransactionTest, TransactionFinish) | 
| 124 { | 124 { | 
| 125     const int64_t transactionId = 1234; | 125     const int64_t transactionId = 1234; | 
| 126 | 126 | 
| 127     OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 127     OwnPtr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); | 
| 128     EXPECT_CALL(*backend, commit(transactionId)) | 128     EXPECT_CALL(*backend, commit(transactionId)) | 
| 129         .Times(1); | 129         .Times(1); | 
| 130     EXPECT_CALL(*backend, close()) | 130     EXPECT_CALL(*backend, close()) | 
| 131         .Times(1); | 131         .Times(1); | 
| 132     Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), back
     end.release(), FakeIDBDatabaseCallbacks::create()); | 132     Persistent<IDBDatabase> db = IDBDatabase::create(getExecutionContext(), back
     end.release(), FakeIDBDatabaseCallbacks::create()); | 
| 133 | 133 | 
| 134     const HashSet<String> transactionScope = HashSet<String>(); | 134     const HashSet<String> transactionScope = HashSet<String>(); | 
| 135     Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta
     te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); | 135     Persistent<IDBTransaction> transaction = IDBTransaction::create(getScriptSta
     te(), transactionId, transactionScope, WebIDBTransactionModeReadOnly, db.get()); | 
| 136     PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 136     PersistentHeapHashSet<WeakMember<IDBTransaction>> set; | 
| 137     set.add(transaction); | 137     set.add(transaction); | 
| 138 | 138 | 
| 139     ThreadHeap::collectAllGarbage(); | 139     Heap::collectAllGarbage(); | 
| 140     EXPECT_EQ(1u, set.size()); | 140     EXPECT_EQ(1u, set.size()); | 
| 141 | 141 | 
| 142     deactivateNewTransactions(); | 142     deactivateNewTransactions(); | 
| 143 | 143 | 
| 144     ThreadHeap::collectAllGarbage(); | 144     Heap::collectAllGarbage(); | 
| 145     EXPECT_EQ(1u, set.size()); | 145     EXPECT_EQ(1u, set.size()); | 
| 146 | 146 | 
| 147     transaction.clear(); | 147     transaction.clear(); | 
| 148 | 148 | 
| 149     ThreadHeap::collectAllGarbage(); | 149     Heap::collectAllGarbage(); | 
| 150     EXPECT_EQ(1u, set.size()); | 150     EXPECT_EQ(1u, set.size()); | 
| 151 | 151 | 
| 152     // Stop the context, so events don't get queued (which would keep the transa
     ction alive). | 152     // Stop the context, so events don't get queued (which would keep the transa
     ction alive). | 
| 153     getExecutionContext()->stopActiveDOMObjects(); | 153     getExecutionContext()->stopActiveDOMObjects(); | 
| 154 | 154 | 
| 155     // Fire an abort to make sure this doesn't free the transaction during use. 
     The test | 155     // Fire an abort to make sure this doesn't free the transaction during use. 
     The test | 
| 156     // will not fail if it is, but ASAN would notice the error. | 156     // will not fail if it is, but ASAN would notice the error. | 
| 157     db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); | 157     db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); | 
| 158 | 158 | 
| 159     // onAbort() should have cleared the transaction's reference to the database
     . | 159     // onAbort() should have cleared the transaction's reference to the database
     . | 
| 160     ThreadHeap::collectAllGarbage(); | 160     Heap::collectAllGarbage(); | 
| 161     EXPECT_EQ(0u, set.size()); | 161     EXPECT_EQ(0u, set.size()); | 
| 162 } | 162 } | 
| 163 | 163 | 
| 164 } // namespace | 164 } // namespace | 
| 165 } // namespace blink | 165 } // namespace blink | 
| OLD | NEW | 
|---|