| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 TitleWatcher title_watcher(shell->web_contents(), expected_title16); | 70 TitleWatcher title_watcher(shell->web_contents(), expected_title16); |
| 71 NavigateToURL(shell, url); | 71 NavigateToURL(shell, url); |
| 72 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 72 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 IndexedDBContextImpl* GetContext() { | 75 IndexedDBContextImpl* GetContext() { |
| 76 StoragePartition* partition = | 76 StoragePartition* partition = |
| 77 BrowserContext::GetDefaultStoragePartition( | 77 BrowserContext::GetDefaultStoragePartition( |
| 78 shell()->web_contents()->GetBrowserContext()); | 78 shell()->web_contents()->GetBrowserContext()); |
| 79 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); | 79 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); |
| 80 }; | 80 } |
| 81 | 81 |
| 82 void SetQuota(int quotaKilobytes) { | 82 void SetQuota(int quotaKilobytes) { |
| 83 const int kTemporaryStorageQuotaSize = quotaKilobytes | 83 const int kTemporaryStorageQuotaSize = quotaKilobytes |
| 84 * 1024 * QuotaManager::kPerHostTemporaryPortion; | 84 * 1024 * QuotaManager::kPerHostTemporaryPortion; |
| 85 SetTempQuota(kTemporaryStorageQuotaSize, | 85 SetTempQuota(kTemporaryStorageQuotaSize, |
| 86 BrowserContext::GetDefaultStoragePartition( | 86 BrowserContext::GetDefaultStoragePartition( |
| 87 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); | 87 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { | 90 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { |
| 91 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 91 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 92 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
| 93 BrowserThread::IO, FROM_HERE, | 93 BrowserThread::IO, FROM_HERE, |
| 94 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); | 94 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 98 qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); | 98 qm->SetTemporaryGlobalOverrideQuota(bytes, quota::QuotaCallback()); |
| 99 // Don't return until the quota has been set. | 99 // Don't return until the quota has been set. |
| 100 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 100 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 101 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get())); | 101 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); |
| 102 ASSERT_TRUE(helper->Run()); | 102 ASSERT_TRUE(helper->Run()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual int64 RequestDiskUsage() { | 105 virtual int64 RequestDiskUsage() { |
| 106 PostTaskAndReplyWithResult( | 106 PostTaskAndReplyWithResult( |
| 107 GetContext()->TaskRunner(), | 107 GetContext()->TaskRunner(), |
| 108 FROM_HERE, | 108 FROM_HERE, |
| 109 base::Bind(&IndexedDBContext::GetOriginDiskUsage, | 109 base::Bind(&IndexedDBContext::GetOriginDiskUsage, |
| 110 GetContext(), | 110 GetContext(), |
| 111 GURL("file:///")), | 111 GURL("file:///")), |
| 112 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); | 112 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, this)); |
| 113 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 113 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 114 BrowserMainLoop::GetInstance()->indexed_db_thread() | 114 BrowserMainLoop::GetInstance()->indexed_db_thread()-> |
| 115 ->message_loop_proxy().get())); | 115 message_loop_proxy())); |
| 116 EXPECT_TRUE(helper->Run()); | 116 EXPECT_TRUE(helper->Run()); |
| 117 // Wait for DidGetDiskUsage to be called. | 117 // Wait for DidGetDiskUsage to be called. |
| 118 base::MessageLoop::current()->RunUntilIdle(); | 118 base::MessageLoop::current()->RunUntilIdle(); |
| 119 return disk_usage_; | 119 return disk_usage_; |
| 120 } | 120 } |
| 121 private: | 121 private: |
| 122 virtual void DidGetDiskUsage(int64 bytes) { | 122 virtual void DidGetDiskUsage(int64 bytes) { |
| 123 EXPECT_GT(bytes, 0); | 123 EXPECT_GT(bytes, 0); |
| 124 disk_usage_ = bytes; | 124 disk_usage_ = bytes; |
| 125 } | 125 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { | 251 class IndexedDBBrowserTestWithPreexistingLevelDB : public IndexedDBBrowserTest { |
| 252 public: | 252 public: |
| 253 virtual void SetUpOnMainThread() OVERRIDE { | 253 virtual void SetUpOnMainThread() OVERRIDE { |
| 254 scoped_refptr<IndexedDBContextImpl> context = GetContext(); | 254 scoped_refptr<IndexedDBContextImpl> context = GetContext(); |
| 255 context->TaskRunner()->PostTask( | 255 context->TaskRunner()->PostTask( |
| 256 FROM_HERE, | 256 FROM_HERE, |
| 257 base::Bind( | 257 base::Bind( |
| 258 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); | 258 &CopyLevelDBToProfile, shell(), context, EnclosingLevelDBDir())); |
| 259 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 259 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 260 BrowserMainLoop::GetInstance()->indexed_db_thread() | 260 BrowserMainLoop::GetInstance()->indexed_db_thread()-> |
| 261 ->message_loop_proxy().get())); | 261 message_loop_proxy())); |
| 262 ASSERT_TRUE(helper->Run()); | 262 ASSERT_TRUE(helper->Run()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 virtual std::string EnclosingLevelDBDir() = 0; | 265 virtual std::string EnclosingLevelDBDir() = 0; |
| 266 | 266 |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 class IndexedDBBrowserTestWithVersion0Schema : public | 269 class IndexedDBBrowserTestWithVersion0Schema : public |
| 270 IndexedDBBrowserTestWithPreexistingLevelDB { | 270 IndexedDBBrowserTestWithPreexistingLevelDB { |
| 271 virtual std::string EnclosingLevelDBDir() OVERRIDE { | 271 virtual std::string EnclosingLevelDBDir() OVERRIDE { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); | 416 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); |
| 417 | 417 |
| 418 base::KillProcess( | 418 base::KillProcess( |
| 419 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); | 419 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); |
| 420 shell()->Close(); | 420 shell()->Close(); |
| 421 | 421 |
| 422 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 422 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 423 } | 423 } |
| 424 | 424 |
| 425 } // namespace content | 425 } // namespace content |
| OLD | NEW |