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 12 matching lines...) Expand all Loading... |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class IndexedDBTest : public testing::Test { | 25 class IndexedDBTest : public testing::Test { |
26 public: | 26 public: |
27 const GURL kNormalOrigin; | 27 const GURL kNormalOrigin; |
28 const GURL kSessionOnlyOrigin; | 28 const GURL kSessionOnlyOrigin; |
29 | 29 |
30 IndexedDBTest() | 30 IndexedDBTest() |
31 : kNormalOrigin("http://normal/"), | 31 : kNormalOrigin("http://normal/"), |
32 kSessionOnlyOrigin("http://session-only/"), | 32 kSessionOnlyOrigin("http://session-only/"), |
33 message_loop_(base::MessageLoop::TYPE_IO), | |
34 task_runner_(new base::TestSimpleTaskRunner), | 33 task_runner_(new base::TestSimpleTaskRunner), |
35 special_storage_policy_(new quota::MockSpecialStoragePolicy), | 34 special_storage_policy_(new quota::MockSpecialStoragePolicy), |
36 file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 35 file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
37 io_thread_(BrowserThread::IO, &message_loop_) { | 36 io_thread_(BrowserThread::IO, &message_loop_) { |
38 special_storage_policy_->AddSessionOnly(kSessionOnlyOrigin); | 37 special_storage_policy_->AddSessionOnly(kSessionOnlyOrigin); |
39 } | 38 } |
40 | 39 |
41 protected: | 40 protected: |
42 void FlushIndexedDBTaskRunner() { task_runner_->RunUntilIdle(); } | 41 void FlushIndexedDBTaskRunner() { task_runner_->RunUntilIdle(); } |
43 | 42 |
44 base::MessageLoop message_loop_; | 43 base::MessageLoopForIO message_loop_; |
45 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 44 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
46 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; | 45 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; |
47 | 46 |
48 private: | 47 private: |
49 BrowserThreadImpl file_thread_; | 48 BrowserThreadImpl file_thread_; |
50 BrowserThreadImpl io_thread_; | 49 BrowserThreadImpl io_thread_; |
51 | 50 |
52 DISALLOW_COPY_AND_ASSIGN(IndexedDBTest); | 51 DISALLOW_COPY_AND_ASSIGN(IndexedDBTest); |
53 }; | 52 }; |
54 | 53 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); | 263 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); |
265 | 264 |
266 // Simulate the write failure. | 265 // Simulate the write failure. |
267 callbacks->connection()->database()->TransactionCommitFailed(); | 266 callbacks->connection()->database()->TransactionCommitFailed(); |
268 | 267 |
269 EXPECT_TRUE(db_callbacks->forced_close_called()); | 268 EXPECT_TRUE(db_callbacks->forced_close_called()); |
270 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 269 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
271 } | 270 } |
272 | 271 |
273 } // namespace content | 272 } // namespace content |
OLD | NEW |