OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/indexed_db/indexed_db_connection.h" | 10 #include "content/browser/indexed_db/indexed_db_connection.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 webkit_database::GetIdentifierFromOrigin(kTestOrigin)); | 175 webkit_database::GetIdentifierFromOrigin(kTestOrigin)); |
176 | 176 |
177 IndexedDBPendingConnection open_connection(open_callbacks, | 177 IndexedDBPendingConnection open_connection(open_callbacks, |
178 open_db_callbacks, | 178 open_db_callbacks, |
179 0 /* child_process_id */, | 179 0 /* child_process_id */, |
180 0 /* host_transaction_id */, | 180 0 /* host_transaction_id */, |
181 0 /* version */); | 181 0 /* version */); |
182 factory->Open(base::ASCIIToUTF16("opendb"), | 182 factory->Open(base::ASCIIToUTF16("opendb"), |
183 open_connection, | 183 open_connection, |
184 kTestOrigin, | 184 kTestOrigin, |
185 idb_context->data_path()); | 185 idb_context->data_path(), |
| 186 NULL /* task_runner */); |
186 IndexedDBPendingConnection closed_connection(closed_callbacks, | 187 IndexedDBPendingConnection closed_connection(closed_callbacks, |
187 closed_db_callbacks, | 188 closed_db_callbacks, |
188 0 /* child_process_id */, | 189 0 /* child_process_id */, |
189 0 /* host_transaction_id */, | 190 0 /* host_transaction_id */, |
190 0 /* version */); | 191 0 /* version */); |
191 factory->Open(base::ASCIIToUTF16("closeddb"), | 192 factory->Open(base::ASCIIToUTF16("closeddb"), |
192 closed_connection, | 193 closed_connection, |
193 kTestOrigin, | 194 kTestOrigin, |
194 idb_context->data_path()); | 195 idb_context->data_path(), |
| 196 NULL /* task_runner */); |
195 | 197 |
196 closed_callbacks->connection()->Close(); | 198 closed_callbacks->connection()->Close(); |
197 | 199 |
198 idb_context->TaskRunner()->PostTask( | 200 idb_context->TaskRunner()->PostTask( |
199 FROM_HERE, | 201 FROM_HERE, |
200 base::Bind( | 202 base::Bind( |
201 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin)); | 203 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin)); |
202 FlushIndexedDBTaskRunner(); | 204 FlushIndexedDBTaskRunner(); |
203 message_loop_.RunUntilIdle(); | 205 message_loop_.RunUntilIdle(); |
204 } | 206 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); | 252 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
251 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( | 253 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
252 new MockIndexedDBDatabaseCallbacks()); | 254 new MockIndexedDBDatabaseCallbacks()); |
253 const int64 transaction_id = 1; | 255 const int64 transaction_id = 1; |
254 IndexedDBPendingConnection connection( | 256 IndexedDBPendingConnection connection( |
255 callbacks, | 257 callbacks, |
256 db_callbacks, | 258 db_callbacks, |
257 0 /* child_process_id */, | 259 0 /* child_process_id */, |
258 transaction_id, | 260 transaction_id, |
259 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 261 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); |
260 factory->Open( | 262 factory->Open(base::ASCIIToUTF16("db"), |
261 base::ASCIIToUTF16("db"), connection, kTestOrigin, temp_dir.path()); | 263 connection, |
| 264 kTestOrigin, |
| 265 temp_dir.path(), |
| 266 task_runner_); |
262 | 267 |
263 EXPECT_TRUE(callbacks->connection()); | 268 EXPECT_TRUE(callbacks->connection()); |
264 | 269 |
265 // ConnectionOpened() is usually called by the dispatcher. | 270 // ConnectionOpened() is usually called by the dispatcher. |
266 context->ConnectionOpened(kTestOrigin, callbacks->connection()); | 271 context->ConnectionOpened(kTestOrigin, callbacks->connection()); |
267 | 272 |
268 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); | 273 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); |
269 | 274 |
270 // Simulate the write failure. | 275 // Simulate the write failure. |
271 callbacks->connection()->database()->TransactionCommitFailed(); | 276 callbacks->connection()->database()->TransactionCommitFailed(); |
272 | 277 |
273 EXPECT_TRUE(db_callbacks->forced_close_called()); | 278 EXPECT_TRUE(db_callbacks->forced_close_called()); |
274 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 279 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
275 } | 280 } |
276 | 281 |
277 } // namespace content | 282 } // namespace content |
OLD | NEW |