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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 115 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
116 } | 116 } |
117 | 117 |
118 IndexedDBContextImpl* GetContext() { | 118 IndexedDBContextImpl* GetContext() { |
119 StoragePartition* partition = | 119 StoragePartition* partition = |
120 BrowserContext::GetDefaultStoragePartition( | 120 BrowserContext::GetDefaultStoragePartition( |
121 shell()->web_contents()->GetBrowserContext()); | 121 shell()->web_contents()->GetBrowserContext()); |
122 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); | 122 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); |
123 } | 123 } |
124 | 124 |
125 void SetQuota(int per_host_quota_kilobytes) { | 125 void SetQuota(int quota_kilobytes) { |
126 SetTempQuota(per_host_quota_kilobytes, | 126 const int kTemporaryStorageQuotaSize = |
127 BrowserContext::GetDefaultStoragePartition( | 127 quota_kilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; |
128 shell()->web_contents()->GetBrowserContext()) | 128 SetTempQuota(kTemporaryStorageQuotaSize, |
129 ->GetQuotaManager()); | 129 BrowserContext::GetDefaultStoragePartition( |
| 130 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); |
130 } | 131 } |
131 | 132 |
132 static void SetTempQuota(int per_host_quota_kilobytes, | 133 static void SetTempQuota(int64_t bytes, scoped_refptr<QuotaManager> qm) { |
133 scoped_refptr<QuotaManager> qm) { | |
134 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 134 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
135 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 135 BrowserThread::PostTask( |
136 base::Bind(&IndexedDBBrowserTest::SetTempQuota, | 136 BrowserThread::IO, FROM_HERE, |
137 per_host_quota_kilobytes, qm)); | 137 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); |
138 return; | 138 return; |
139 } | 139 } |
140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
141 const int KB = 1024; | 141 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); |
142 qm->SetQuotaSettings( | 142 // Don't return until the quota has been set. |
143 storage::GetHardCodedSettings(per_host_quota_kilobytes * KB)); | 143 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 144 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB))); |
| 145 ASSERT_TRUE(helper->Run()); |
144 } | 146 } |
145 | 147 |
146 virtual int64_t RequestDiskUsage() { | 148 virtual int64_t RequestDiskUsage() { |
147 PostTaskAndReplyWithResult( | 149 PostTaskAndReplyWithResult( |
148 GetContext()->TaskRunner(), | 150 GetContext()->TaskRunner(), |
149 FROM_HERE, | 151 FROM_HERE, |
150 base::Bind(&IndexedDBContext::GetOriginDiskUsage, | 152 base::Bind(&IndexedDBContext::GetOriginDiskUsage, |
151 GetContext(), | 153 GetContext(), |
152 GURL("file:///")), | 154 GURL("file:///")), |
153 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, | 155 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 command_line->AppendSwitch(switches::kSingleProcess); | 855 command_line->AppendSwitch(switches::kSingleProcess); |
854 } | 856 } |
855 }; | 857 }; |
856 | 858 |
857 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 859 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
858 RenderThreadShutdownTest) { | 860 RenderThreadShutdownTest) { |
859 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 861 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
860 } | 862 } |
861 | 863 |
862 } // namespace content | 864 } // namespace content |
OLD | NEW |