| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 virtual int64_t RequestDiskUsage() { | 146 virtual int64_t RequestDiskUsage() { |
| 147 PostTaskAndReplyWithResult( | 147 PostTaskAndReplyWithResult( |
| 148 GetContext()->TaskRunner(), | 148 GetContext()->TaskRunner(), |
| 149 FROM_HERE, | 149 FROM_HERE, |
| 150 base::Bind(&IndexedDBContext::GetOriginDiskUsage, | 150 base::Bind(&IndexedDBContext::GetOriginDiskUsage, |
| 151 GetContext(), | 151 GetContext(), |
| 152 GURL("file:///")), | 152 GURL("file:///")), |
| 153 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, | 153 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, |
| 154 base::Unretained(this))); | 154 base::Unretained(this))); |
| 155 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 155 scoped_refptr<base::ThreadTestHelper> helper( |
| 156 BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); | 156 new base::ThreadTestHelper(GetContext()->TaskRunner())); |
| 157 EXPECT_TRUE(helper->Run()); | 157 EXPECT_TRUE(helper->Run()); |
| 158 // Wait for DidGetDiskUsage to be called. | 158 // Wait for DidGetDiskUsage to be called. |
| 159 base::RunLoop().RunUntilIdle(); | 159 base::RunLoop().RunUntilIdle(); |
| 160 return disk_usage_; | 160 return disk_usage_; |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual int RequestBlobFileCount() { | 163 virtual int RequestBlobFileCount() { |
| 164 PostTaskAndReplyWithResult( | 164 PostTaskAndReplyWithResult( |
| 165 GetContext()->TaskRunner(), FROM_HERE, | 165 GetContext()->TaskRunner(), FROM_HERE, |
| 166 base::Bind(&IndexedDBContextImpl::GetOriginBlobFileCount, GetContext(), | 166 base::Bind(&IndexedDBContextImpl::GetOriginBlobFileCount, GetContext(), |
| 167 Origin(GURL("file:///"))), | 167 Origin(GURL("file:///"))), |
| 168 base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, | 168 base::Bind(&IndexedDBBrowserTest::DidGetBlobFileCount, |
| 169 base::Unretained(this))); | 169 base::Unretained(this))); |
| 170 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 170 scoped_refptr<base::ThreadTestHelper> helper( |
| 171 BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); | 171 new base::ThreadTestHelper(GetContext()->TaskRunner())); |
| 172 EXPECT_TRUE(helper->Run()); | 172 EXPECT_TRUE(helper->Run()); |
| 173 // Wait for DidGetBlobFileCount to be called. | 173 // Wait for DidGetBlobFileCount to be called. |
| 174 base::RunLoop().RunUntilIdle(); | 174 base::RunLoop().RunUntilIdle(); |
| 175 return blob_file_count_; | 175 return blob_file_count_; |
| 176 } | 176 } |
| 177 | 177 |
| 178 private: | 178 private: |
| 179 static MockBrowserTestIndexedDBClassFactory* GetTestClassFactory() { | 179 static MockBrowserTestIndexedDBClassFactory* GetTestClassFactory() { |
| 180 static ::base::LazyInstance<MockBrowserTestIndexedDBClassFactory>::Leaky | 180 static ::base::LazyInstance<MockBrowserTestIndexedDBClassFactory>::Leaky |
| 181 s_factory = LAZY_INSTANCE_INITIALIZER; | 181 s_factory = LAZY_INSTANCE_INITIALIZER; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { | 327 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { |
| 328 public: | 328 public: |
| 329 IndexedDBBrowserTestWithPreexistingLevelDB() {} | 329 IndexedDBBrowserTestWithPreexistingLevelDB() {} |
| 330 void SetUpOnMainThread() override { | 330 void SetUpOnMainThread() override { |
| 331 scoped_refptr<IndexedDBContextImpl> context = GetContext(); | 331 scoped_refptr<IndexedDBContextImpl> context = GetContext(); |
| 332 context->TaskRunner()->PostTask( | 332 context->TaskRunner()->PostTask( |
| 333 FROM_HERE, | 333 FROM_HERE, |
| 334 base::Bind( | 334 base::Bind( |
| 335 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); | 335 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); |
| 336 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 336 scoped_refptr<base::ThreadTestHelper> helper( |
| 337 BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); | 337 new base::ThreadTestHelper(GetContext()->TaskRunner())); |
| 338 ASSERT_TRUE(helper->Run()); | 338 ASSERT_TRUE(helper->Run()); |
| 339 } | 339 } |
| 340 | 340 |
| 341 virtual std::string EnclosingLevelDBDir() = 0; | 341 virtual std::string EnclosingLevelDBDir() = 0; |
| 342 | 342 |
| 343 private: | 343 private: |
| 344 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTestWithPreexistingLevelDB); | 344 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTestWithPreexistingLevelDB); |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 class IndexedDBBrowserTestWithVersion0Schema : public | 347 class IndexedDBBrowserTestWithVersion0Schema : public |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 SimpleTest(GetTestUrl("indexeddb", "write_4mb_blob.html")); | 492 SimpleTest(GetTestUrl("indexeddb", "write_4mb_blob.html")); |
| 493 int64_t size = RequestDiskUsage(); | 493 int64_t size = RequestDiskUsage(); |
| 494 // This assertion assumes that we do not compress blobs. | 494 // This assertion assumes that we do not compress blobs. |
| 495 EXPECT_GT(size, 4 << 20 /* 4 MB */); | 495 EXPECT_GT(size, 4 << 20 /* 4 MB */); |
| 496 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. | 496 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. |
| 497 GetContext()->TaskRunner()->PostTask( | 497 GetContext()->TaskRunner()->PostTask( |
| 498 FROM_HERE, | 498 FROM_HERE, |
| 499 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const GURL&)>( | 499 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const GURL&)>( |
| 500 &IndexedDBContextImpl::DeleteForOrigin), | 500 &IndexedDBContextImpl::DeleteForOrigin), |
| 501 GetContext(), GURL("file:///"))); | 501 GetContext(), GURL("file:///"))); |
| 502 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 502 scoped_refptr<base::ThreadTestHelper> helper( |
| 503 BrowserMainLoop::GetInstance()->indexed_db_thread()->task_runner())); | 503 new base::ThreadTestHelper(GetContext()->TaskRunner())); |
| 504 ASSERT_TRUE(helper->Run()); | 504 ASSERT_TRUE(helper->Run()); |
| 505 EXPECT_EQ(0, RequestDiskUsage()); | 505 EXPECT_EQ(0, RequestDiskUsage()); |
| 506 } | 506 } |
| 507 | 507 |
| 508 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DiskFullOnCommit) { | 508 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DiskFullOnCommit) { |
| 509 // Ignore several preceding transactions: | 509 // Ignore several preceding transactions: |
| 510 // * The test calls deleteDatabase() which opens the backing store: | 510 // * The test calls deleteDatabase() which opens the backing store: |
| 511 // #1: IndexedDBBackingStore::OpenBackingStore | 511 // #1: IndexedDBBackingStore::OpenBackingStore |
| 512 // => IndexedDBBackingStore::SetUpMetadata | 512 // => IndexedDBBackingStore::SetUpMetadata |
| 513 // #2: IndexedDBBackingStore::OpenBackingStore | 513 // #2: IndexedDBBackingStore::OpenBackingStore |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 command_line->AppendSwitch(switches::kSingleProcess); | 852 command_line->AppendSwitch(switches::kSingleProcess); |
| 853 } | 853 } |
| 854 }; | 854 }; |
| 855 | 855 |
| 856 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 856 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
| 857 RenderThreadShutdownTest) { | 857 RenderThreadShutdownTest) { |
| 858 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 858 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
| 859 } | 859 } |
| 860 | 860 |
| 861 } // namespace content | 861 } // namespace content |
| OLD | NEW |