Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: content/browser/indexed_db/indexed_db_unittest.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 base::FilePath normal_path; 59 base::FilePath normal_path;
60 base::FilePath session_only_path; 60 base::FilePath session_only_path;
61 61
62 // Create the scope which will ensure we run the destructor of the context 62 // Create the scope which will ensure we run the destructor of the context
63 // which should trigger the clean up. 63 // which should trigger the clean up.
64 { 64 {
65 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl( 65 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl(
66 temp_dir.path(), special_storage_policy_, NULL, task_runner_); 66 temp_dir.path(), special_storage_policy_, NULL, task_runner_);
67 67
68 normal_path = idb_context->GetFilePathForTesting( 68 normal_path = idb_context->GetFilePathForTesting(
69 webkit_database::GetIdentifierFromOrigin(kNormalOrigin)); 69 storage::GetIdentifierFromOrigin(kNormalOrigin));
70 session_only_path = idb_context->GetFilePathForTesting( 70 session_only_path = idb_context->GetFilePathForTesting(
71 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); 71 storage::GetIdentifierFromOrigin(kSessionOnlyOrigin));
72 ASSERT_TRUE(base::CreateDirectory(normal_path)); 72 ASSERT_TRUE(base::CreateDirectory(normal_path));
73 ASSERT_TRUE(base::CreateDirectory(session_only_path)); 73 ASSERT_TRUE(base::CreateDirectory(session_only_path));
74 FlushIndexedDBTaskRunner(); 74 FlushIndexedDBTaskRunner();
75 message_loop_.RunUntilIdle(); 75 message_loop_.RunUntilIdle();
76 } 76 }
77 77
78 FlushIndexedDBTaskRunner(); 78 FlushIndexedDBTaskRunner();
79 message_loop_.RunUntilIdle(); 79 message_loop_.RunUntilIdle();
80 80
81 EXPECT_TRUE(base::DirectoryExists(normal_path)); 81 EXPECT_TRUE(base::DirectoryExists(normal_path));
(...skipping 11 matching lines...) Expand all
93 { 93 {
94 // Create some indexedDB paths. 94 // Create some indexedDB paths.
95 // With the levelDB backend, these are directories. 95 // With the levelDB backend, these are directories.
96 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl( 96 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl(
97 temp_dir.path(), special_storage_policy_, NULL, task_runner_); 97 temp_dir.path(), special_storage_policy_, NULL, task_runner_);
98 98
99 // Save session state. This should bypass the destruction-time deletion. 99 // Save session state. This should bypass the destruction-time deletion.
100 idb_context->SetForceKeepSessionState(); 100 idb_context->SetForceKeepSessionState();
101 101
102 normal_path = idb_context->GetFilePathForTesting( 102 normal_path = idb_context->GetFilePathForTesting(
103 webkit_database::GetIdentifierFromOrigin(kNormalOrigin)); 103 storage::GetIdentifierFromOrigin(kNormalOrigin));
104 session_only_path = idb_context->GetFilePathForTesting( 104 session_only_path = idb_context->GetFilePathForTesting(
105 webkit_database::GetIdentifierFromOrigin(kSessionOnlyOrigin)); 105 storage::GetIdentifierFromOrigin(kSessionOnlyOrigin));
106 ASSERT_TRUE(base::CreateDirectory(normal_path)); 106 ASSERT_TRUE(base::CreateDirectory(normal_path));
107 ASSERT_TRUE(base::CreateDirectory(session_only_path)); 107 ASSERT_TRUE(base::CreateDirectory(session_only_path));
108 message_loop_.RunUntilIdle(); 108 message_loop_.RunUntilIdle();
109 } 109 }
110 110
111 // Make sure we wait until the destructor has run. 111 // Make sure we wait until the destructor has run.
112 message_loop_.RunUntilIdle(); 112 message_loop_.RunUntilIdle();
113 113
114 // No data was cleared because of SetForceKeepSessionState. 114 // No data was cleared because of SetForceKeepSessionState.
115 EXPECT_TRUE(base::DirectoryExists(normal_path)); 115 EXPECT_TRUE(base::DirectoryExists(normal_path));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 scoped_refptr<ForceCloseDBCallbacks> open_callbacks = 167 scoped_refptr<ForceCloseDBCallbacks> open_callbacks =
168 new ForceCloseDBCallbacks(idb_context, kTestOrigin); 168 new ForceCloseDBCallbacks(idb_context, kTestOrigin);
169 169
170 scoped_refptr<ForceCloseDBCallbacks> closed_callbacks = 170 scoped_refptr<ForceCloseDBCallbacks> closed_callbacks =
171 new ForceCloseDBCallbacks(idb_context, kTestOrigin); 171 new ForceCloseDBCallbacks(idb_context, kTestOrigin);
172 172
173 IndexedDBFactory* factory = idb_context->GetIDBFactory(); 173 IndexedDBFactory* factory = idb_context->GetIDBFactory();
174 174
175 test_path = idb_context->GetFilePathForTesting( 175 test_path = idb_context->GetFilePathForTesting(
176 webkit_database::GetIdentifierFromOrigin(kTestOrigin)); 176 storage::GetIdentifierFromOrigin(kTestOrigin));
177 177
178 IndexedDBPendingConnection open_connection(open_callbacks, 178 IndexedDBPendingConnection open_connection(open_callbacks,
179 open_db_callbacks, 179 open_db_callbacks,
180 0 /* child_process_id */, 180 0 /* child_process_id */,
181 0 /* host_transaction_id */, 181 0 /* host_transaction_id */,
182 0 /* version */); 182 0 /* version */);
183 factory->Open(base::ASCIIToUTF16("opendb"), 183 factory->Open(base::ASCIIToUTF16("opendb"),
184 open_connection, 184 open_connection,
185 NULL /* request_context */, 185 NULL /* request_context */,
186 kTestOrigin, 186 kTestOrigin,
(...skipping 29 matching lines...) Expand all
216 216
217 TEST_F(IndexedDBTest, DeleteFailsIfDirectoryLocked) { 217 TEST_F(IndexedDBTest, DeleteFailsIfDirectoryLocked) {
218 base::ScopedTempDir temp_dir; 218 base::ScopedTempDir temp_dir;
219 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 219 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
220 const GURL kTestOrigin("http://test/"); 220 const GURL kTestOrigin("http://test/");
221 221
222 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl( 222 scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl(
223 temp_dir.path(), special_storage_policy_, NULL, task_runner_); 223 temp_dir.path(), special_storage_policy_, NULL, task_runner_);
224 224
225 base::FilePath test_path = idb_context->GetFilePathForTesting( 225 base::FilePath test_path = idb_context->GetFilePathForTesting(
226 webkit_database::GetIdentifierFromOrigin(kTestOrigin)); 226 storage::GetIdentifierFromOrigin(kTestOrigin));
227 ASSERT_TRUE(base::CreateDirectory(test_path)); 227 ASSERT_TRUE(base::CreateDirectory(test_path));
228 228
229 scoped_ptr<LevelDBLock> lock = 229 scoped_ptr<LevelDBLock> lock =
230 LevelDBDatabase::LockForTesting(test_path); 230 LevelDBDatabase::LockForTesting(test_path);
231 ASSERT_TRUE(lock); 231 ASSERT_TRUE(lock);
232 232
233 idb_context->TaskRunner()->PostTask( 233 idb_context->TaskRunner()->PostTask(
234 FROM_HERE, 234 FROM_HERE,
235 base::Bind( 235 base::Bind(
236 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin)); 236 &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 // Simulate the write failure. 277 // Simulate the write failure.
278 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); 278 leveldb::Status status = leveldb::Status::IOError("Simulated failure");
279 callbacks->connection()->database()->TransactionCommitFailed(status); 279 callbacks->connection()->database()->TransactionCommitFailed(status);
280 280
281 EXPECT_TRUE(db_callbacks->forced_close_called()); 281 EXPECT_TRUE(db_callbacks->forced_close_called());
282 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); 282 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin));
283 } 283 }
284 284
285 } // namespace content 285 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698