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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBTransactionTest.cpp

Issue 2657443005: Migrate WTF::HashSet::add() to ::insert() [part 1 of N] (Closed)
Patch Set: Created 3 years, 10 months 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
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 TEST(IDBTransactionTest, EnsureLifetime) { 66 TEST(IDBTransactionTest, EnsureLifetime) {
67 V8TestingScope scope; 67 V8TestingScope scope;
68 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 68 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
69 EXPECT_CALL(*backend, close()).Times(1); 69 EXPECT_CALL(*backend, close()).Times(1);
70 Persistent<IDBDatabase> db = 70 Persistent<IDBDatabase> db =
71 IDBDatabase::create(scope.getExecutionContext(), std::move(backend), 71 IDBDatabase::create(scope.getExecutionContext(), std::move(backend),
72 FakeIDBDatabaseCallbacks::create()); 72 FakeIDBDatabaseCallbacks::create());
73 73
74 const int64_t transactionId = 1234; 74 const int64_t transactionId = 1234;
75 HashSet<String> transactionScope = HashSet<String>(); 75 HashSet<String> transactionScope = HashSet<String>();
76 transactionScope.add("test-store-name"); 76 transactionScope.insert("test-store-name");
77 Persistent<IDBTransaction> transaction = 77 Persistent<IDBTransaction> transaction =
78 IDBTransaction::createNonVersionChange( 78 IDBTransaction::createNonVersionChange(
79 scope.getScriptState(), transactionId, transactionScope, 79 scope.getScriptState(), transactionId, transactionScope,
80 WebIDBTransactionModeReadOnly, db.get()); 80 WebIDBTransactionModeReadOnly, db.get());
81 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; 81 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
82 set.add(transaction); 82 set.insert(transaction);
83 83
84 ThreadState::current()->collectAllGarbage(); 84 ThreadState::current()->collectAllGarbage();
85 EXPECT_EQ(1u, set.size()); 85 EXPECT_EQ(1u, set.size());
86 86
87 Persistent<IDBRequest> request = IDBRequest::create( 87 Persistent<IDBRequest> request = IDBRequest::create(
88 scope.getScriptState(), IDBAny::createUndefined(), transaction.get()); 88 scope.getScriptState(), IDBAny::createUndefined(), transaction.get());
89 deactivateNewTransactions(scope.isolate()); 89 deactivateNewTransactions(scope.isolate());
90 90
91 ThreadState::current()->collectAllGarbage(); 91 ThreadState::current()->collectAllGarbage();
92 EXPECT_EQ(1u, set.size()); 92 EXPECT_EQ(1u, set.size());
(...skipping 13 matching lines...) Expand all
106 const int64_t transactionId = 1234; 106 const int64_t transactionId = 1234;
107 107
108 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create(); 108 std::unique_ptr<MockWebIDBDatabase> backend = MockWebIDBDatabase::create();
109 EXPECT_CALL(*backend, commit(transactionId)).Times(1); 109 EXPECT_CALL(*backend, commit(transactionId)).Times(1);
110 EXPECT_CALL(*backend, close()).Times(1); 110 EXPECT_CALL(*backend, close()).Times(1);
111 Persistent<IDBDatabase> db = 111 Persistent<IDBDatabase> db =
112 IDBDatabase::create(scope.getExecutionContext(), std::move(backend), 112 IDBDatabase::create(scope.getExecutionContext(), std::move(backend),
113 FakeIDBDatabaseCallbacks::create()); 113 FakeIDBDatabaseCallbacks::create());
114 114
115 HashSet<String> transactionScope = HashSet<String>(); 115 HashSet<String> transactionScope = HashSet<String>();
116 transactionScope.add("test-store-name"); 116 transactionScope.insert("test-store-name");
117 Persistent<IDBTransaction> transaction = 117 Persistent<IDBTransaction> transaction =
118 IDBTransaction::createNonVersionChange( 118 IDBTransaction::createNonVersionChange(
119 scope.getScriptState(), transactionId, transactionScope, 119 scope.getScriptState(), transactionId, transactionScope,
120 WebIDBTransactionModeReadOnly, db.get()); 120 WebIDBTransactionModeReadOnly, db.get());
121 PersistentHeapHashSet<WeakMember<IDBTransaction>> set; 121 PersistentHeapHashSet<WeakMember<IDBTransaction>> set;
122 set.add(transaction); 122 set.insert(transaction);
123 123
124 ThreadState::current()->collectAllGarbage(); 124 ThreadState::current()->collectAllGarbage();
125 EXPECT_EQ(1u, set.size()); 125 EXPECT_EQ(1u, set.size());
126 126
127 deactivateNewTransactions(scope.isolate()); 127 deactivateNewTransactions(scope.isolate());
128 128
129 ThreadState::current()->collectAllGarbage(); 129 ThreadState::current()->collectAllGarbage();
130 EXPECT_EQ(1u, set.size()); 130 EXPECT_EQ(1u, set.size());
131 131
132 transaction.clear(); 132 transaction.clear();
133 133
134 ThreadState::current()->collectAllGarbage(); 134 ThreadState::current()->collectAllGarbage();
135 EXPECT_EQ(1u, set.size()); 135 EXPECT_EQ(1u, set.size());
136 136
137 // Stop the context, so events don't get queued (which would keep the 137 // Stop the context, so events don't get queued (which would keep the
138 // transaction alive). 138 // transaction alive).
139 scope.getExecutionContext()->notifyContextDestroyed(); 139 scope.getExecutionContext()->notifyContextDestroyed();
140 140
141 // Fire an abort to make sure this doesn't free the transaction during use. 141 // Fire an abort to make sure this doesn't free the transaction during use.
142 // The test will not fail if it is, but ASAN would notice the error. 142 // The test will not fail if it is, but ASAN would notice the error.
143 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted")); 143 db->onAbort(transactionId, DOMException::create(AbortError, "Aborted"));
144 144
145 // onAbort() should have cleared the transaction's reference to the database. 145 // onAbort() should have cleared the transaction's reference to the database.
146 ThreadState::current()->collectAllGarbage(); 146 ThreadState::current()->collectAllGarbage();
147 EXPECT_EQ(0u, set.size()); 147 EXPECT_EQ(0u, set.size());
148 } 148 }
149 149
150 } // namespace 150 } // namespace
151 } // namespace blink 151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698