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 <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 quota_manager_proxy_.get(), task_runner_.get()); | 271 quota_manager_proxy_.get(), task_runner_.get()); |
272 | 272 |
273 scoped_refptr<IndexedDBFactoryImpl> factory = | 273 scoped_refptr<IndexedDBFactoryImpl> factory = |
274 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); | 274 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); |
275 | 275 |
276 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); | 276 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
277 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( | 277 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
278 new MockIndexedDBDatabaseCallbacks()); | 278 new MockIndexedDBDatabaseCallbacks()); |
279 const int64_t transaction_id = 1; | 279 const int64_t transaction_id = 1; |
280 IndexedDBPendingConnection connection( | 280 IndexedDBPendingConnection connection( |
281 callbacks, | 281 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, |
282 db_callbacks, | 282 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
283 0 /* child_process_id */, | |
284 transaction_id, | |
285 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
286 factory->Open(base::ASCIIToUTF16("db"), | 283 factory->Open(base::ASCIIToUTF16("db"), |
287 connection, | 284 connection, |
288 NULL /* request_context */, | 285 NULL /* request_context */, |
289 kTestOrigin, | 286 kTestOrigin, |
290 temp_dir.path()); | 287 temp_dir.path()); |
291 | 288 |
292 EXPECT_TRUE(callbacks->connection()); | 289 EXPECT_TRUE(callbacks->connection()); |
293 | 290 |
294 // ConnectionOpened() is usually called by the dispatcher. | 291 // ConnectionOpened() is usually called by the dispatcher. |
295 context->ConnectionOpened(kTestOrigin, callbacks->connection()); | 292 context->ConnectionOpened(kTestOrigin, callbacks->connection()); |
296 | 293 |
297 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); | 294 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); |
298 | 295 |
299 // Simulate the write failure. | 296 // Simulate the write failure. |
300 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 297 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
301 callbacks->connection()->database()->TransactionCommitFailed(status); | 298 callbacks->connection()->database()->TransactionCommitFailed(status); |
302 | 299 |
303 EXPECT_TRUE(db_callbacks->forced_close_called()); | 300 EXPECT_TRUE(db_callbacks->forced_close_called()); |
304 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 301 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
305 } | 302 } |
306 | 303 |
307 } // namespace content | 304 } // namespace content |
OLD | NEW |