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" |
11 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 11 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 12 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
12 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" | 13 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" |
13 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" | 14 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
14 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
15 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
16 #include "content/public/test/mock_special_storage_policy.h" | 17 #include "content/public/test/mock_special_storage_policy.h" |
17 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "webkit/browser/quota/quota_manager.h" | 20 #include "webkit/browser/quota/quota_manager.h" |
20 #include "webkit/browser/quota/special_storage_policy.h" | 21 #include "webkit/browser/quota/special_storage_policy.h" |
21 #include "webkit/common/database/database_identifier.h" | 22 #include "webkit/common/database/database_identifier.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 241 |
241 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { | 242 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { |
242 const GURL kTestOrigin("http://test/"); | 243 const GURL kTestOrigin("http://test/"); |
243 | 244 |
244 base::ScopedTempDir temp_dir; | 245 base::ScopedTempDir temp_dir; |
245 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 246 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
246 | 247 |
247 scoped_refptr<IndexedDBContextImpl> context = new IndexedDBContextImpl( | 248 scoped_refptr<IndexedDBContextImpl> context = new IndexedDBContextImpl( |
248 temp_dir.path(), special_storage_policy_, NULL, task_runner_); | 249 temp_dir.path(), special_storage_policy_, NULL, task_runner_); |
249 | 250 |
250 scoped_refptr<IndexedDBFactory> factory = context->GetIDBFactory(); | 251 scoped_refptr<IndexedDBFactoryImpl> factory = |
| 252 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); |
251 | 253 |
252 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); | 254 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
253 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( | 255 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
254 new MockIndexedDBDatabaseCallbacks()); | 256 new MockIndexedDBDatabaseCallbacks()); |
255 const int64 transaction_id = 1; | 257 const int64 transaction_id = 1; |
256 IndexedDBPendingConnection connection( | 258 IndexedDBPendingConnection connection( |
257 callbacks, | 259 callbacks, |
258 db_callbacks, | 260 db_callbacks, |
259 0 /* child_process_id */, | 261 0 /* child_process_id */, |
260 transaction_id, | 262 transaction_id, |
(...skipping 13 matching lines...) Expand all Loading... |
274 | 276 |
275 // Simulate the write failure. | 277 // Simulate the write failure. |
276 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 278 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
277 callbacks->connection()->database()->TransactionCommitFailed(status); | 279 callbacks->connection()->database()->TransactionCommitFailed(status); |
278 | 280 |
279 EXPECT_TRUE(db_callbacks->forced_close_called()); | 281 EXPECT_TRUE(db_callbacks->forced_close_called()); |
280 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 282 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
281 } | 283 } |
282 | 284 |
283 } // namespace content | 285 } // namespace content |
OLD | NEW |