OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/indexed_db/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (backing_store_->removals().size() != backing_store_->writes().size()) | 322 if (backing_store_->removals().size() != backing_store_->writes().size()) |
323 return false; | 323 return false; |
324 for (size_t i = 0; i < backing_store_->writes().size(); ++i) { | 324 for (size_t i = 0; i < backing_store_->writes().size(); ++i) { |
325 if (backing_store_->writes()[i].key() != backing_store_->removals()[i]) | 325 if (backing_store_->writes()[i].key() != backing_store_->removals()[i]) |
326 return false; | 326 return false; |
327 } | 327 } |
328 return true; | 328 return true; |
329 } | 329 } |
330 | 330 |
331 protected: | 331 protected: |
| 332 // Must be initialized before url_request_context_ |
| 333 content::TestBrowserThreadBundle thread_bundle_; |
| 334 |
332 base::ScopedTempDir temp_dir_; | 335 base::ScopedTempDir temp_dir_; |
333 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 336 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
334 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; | 337 scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; |
335 scoped_refptr<IndexedDBContextImpl> idb_context_; | 338 scoped_refptr<IndexedDBContextImpl> idb_context_; |
336 scoped_refptr<TestIDBFactory> idb_factory_; | 339 scoped_refptr<TestIDBFactory> idb_factory_; |
337 net::TestURLRequestContext url_request_context_; | 340 net::TestURLRequestContext url_request_context_; |
338 | 341 |
339 scoped_refptr<TestableIndexedDBBackingStore> backing_store_; | 342 scoped_refptr<TestableIndexedDBBackingStore> backing_store_; |
340 | 343 |
341 // Sample keys and values that are consistent. | 344 // Sample keys and values that are consistent. |
342 IndexedDBKey m_key1; | 345 IndexedDBKey m_key1; |
343 IndexedDBKey m_key2; | 346 IndexedDBKey m_key2; |
344 IndexedDBKey m_key3; | 347 IndexedDBKey m_key3; |
345 IndexedDBValue m_value1; | 348 IndexedDBValue m_value1; |
346 IndexedDBValue m_value2; | 349 IndexedDBValue m_value2; |
347 IndexedDBValue m_value3; | 350 IndexedDBValue m_value3; |
348 std::vector<IndexedDBBlobInfo> m_blob_info; | 351 std::vector<IndexedDBBlobInfo> m_blob_info; |
349 | 352 |
350 private: | 353 private: |
351 content::TestBrowserThreadBundle thread_bundle_; | |
352 | |
353 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStoreTest); | 354 DISALLOW_COPY_AND_ASSIGN(IndexedDBBackingStoreTest); |
354 }; | 355 }; |
355 | 356 |
356 class TestCallback : public IndexedDBBackingStore::BlobWriteCallback { | 357 class TestCallback : public IndexedDBBackingStore::BlobWriteCallback { |
357 public: | 358 public: |
358 TestCallback() : called(false), succeeded(false) {} | 359 TestCallback() : called(false), succeeded(false) {} |
359 virtual void Run(bool succeeded_in) OVERRIDE { | 360 virtual void Run(bool succeeded_in) OVERRIDE { |
360 called = true; | 361 called = true; |
361 succeeded = succeeded_in; | 362 succeeded = succeeded_in; |
362 } | 363 } |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 996 |
996 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); | 997 std::vector<base::string16> names = backing_store_->GetDatabaseNames(&s); |
997 EXPECT_TRUE(s.ok()); | 998 EXPECT_TRUE(s.ok()); |
998 EXPECT_EQ(names.size(), 1ULL); | 999 EXPECT_EQ(names.size(), 1ULL); |
999 EXPECT_EQ(names[0], db1_name); | 1000 EXPECT_EQ(names[0], db1_name); |
1000 } | 1001 } |
1001 | 1002 |
1002 } // namespace | 1003 } // namespace |
1003 | 1004 |
1004 } // namespace content | 1005 } // namespace content |
OLD | NEW |