| 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> |
| 6 |
| 5 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/macros.h" |
| 7 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/indexed_db/indexed_db_connection.h" | 13 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 11 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 14 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 12 #include "content/browser/indexed_db/indexed_db_factory_impl.h" | 15 #include "content/browser/indexed_db/indexed_db_factory_impl.h" |
| 13 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" | 16 #include "content/browser/indexed_db/mock_indexed_db_callbacks.h" |
| 14 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" | 17 #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
| 15 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 16 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 259 |
| 257 scoped_refptr<IndexedDBContextImpl> context = new IndexedDBContextImpl( | 260 scoped_refptr<IndexedDBContextImpl> context = new IndexedDBContextImpl( |
| 258 temp_dir.path(), special_storage_policy_.get(), NULL, task_runner_.get()); | 261 temp_dir.path(), special_storage_policy_.get(), NULL, task_runner_.get()); |
| 259 | 262 |
| 260 scoped_refptr<IndexedDBFactoryImpl> factory = | 263 scoped_refptr<IndexedDBFactoryImpl> factory = |
| 261 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); | 264 static_cast<IndexedDBFactoryImpl*>(context->GetIDBFactory()); |
| 262 | 265 |
| 263 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); | 266 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
| 264 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( | 267 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
| 265 new MockIndexedDBDatabaseCallbacks()); | 268 new MockIndexedDBDatabaseCallbacks()); |
| 266 const int64 transaction_id = 1; | 269 const int64_t transaction_id = 1; |
| 267 IndexedDBPendingConnection connection( | 270 IndexedDBPendingConnection connection( |
| 268 callbacks, | 271 callbacks, |
| 269 db_callbacks, | 272 db_callbacks, |
| 270 0 /* child_process_id */, | 273 0 /* child_process_id */, |
| 271 transaction_id, | 274 transaction_id, |
| 272 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 275 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); |
| 273 factory->Open(base::ASCIIToUTF16("db"), | 276 factory->Open(base::ASCIIToUTF16("db"), |
| 274 connection, | 277 connection, |
| 275 NULL /* request_context */, | 278 NULL /* request_context */, |
| 276 kTestOrigin, | 279 kTestOrigin, |
| 277 temp_dir.path()); | 280 temp_dir.path()); |
| 278 | 281 |
| 279 EXPECT_TRUE(callbacks->connection()); | 282 EXPECT_TRUE(callbacks->connection()); |
| 280 | 283 |
| 281 // ConnectionOpened() is usually called by the dispatcher. | 284 // ConnectionOpened() is usually called by the dispatcher. |
| 282 context->ConnectionOpened(kTestOrigin, callbacks->connection()); | 285 context->ConnectionOpened(kTestOrigin, callbacks->connection()); |
| 283 | 286 |
| 284 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); | 287 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); |
| 285 | 288 |
| 286 // Simulate the write failure. | 289 // Simulate the write failure. |
| 287 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 290 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
| 288 callbacks->connection()->database()->TransactionCommitFailed(status); | 291 callbacks->connection()->database()->TransactionCommitFailed(status); |
| 289 | 292 |
| 290 EXPECT_TRUE(db_callbacks->forced_close_called()); | 293 EXPECT_TRUE(db_callbacks->forced_close_called()); |
| 291 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 294 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
| 292 } | 295 } |
| 293 | 296 |
| 294 } // namespace content | 297 } // namespace content |
| OLD | NEW |