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 quota_kilobytes) { | 125 void SetQuota(int per_host_quota_kilobytes) { |
126 const int kTemporaryStorageQuotaSize = | 126 SetTempQuota(per_host_quota_kilobytes, |
127 quota_kilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; | |
128 SetTempQuota(kTemporaryStorageQuotaSize, | |
129 BrowserContext::GetDefaultStoragePartition( | 127 BrowserContext::GetDefaultStoragePartition( |
130 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); | 128 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); |
131 } | 129 } |
132 | 130 |
133 static void SetTempQuota(int64_t bytes, scoped_refptr<QuotaManager> qm) { | 131 static void SetTempQuota(int per_host_quota_kilobytes, |
| 132 scoped_refptr<QuotaManager> qm) { |
134 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 133 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
135 BrowserThread::PostTask( | 134 BrowserThread::PostTask( |
136 BrowserThread::IO, FROM_HERE, | 135 BrowserThread::IO, FROM_HERE, |
137 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); | 136 base::Bind(&IndexedDBBrowserTest::SetTempQuota, |
| 137 per_host_quota_kilobytes, qm)); |
138 return; | 138 return; |
139 } | 139 } |
140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
141 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); | 141 const int KB = 1024; |
142 // Don't return until the quota has been set. | 142 storage::TemporaryStorageConfiguration config; |
143 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 143 config.per_host_quota = per_host_quota_kilobytes * KB; |
144 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB))); | 144 config.pool_size = config.per_host_quota * 5; |
145 ASSERT_TRUE(helper->Run()); | 145 config.must_remain_available = 100 * KB * KB; |
| 146 config.refresh_interval = base::TimeDelta::Max(); |
| 147 qm->SetTemporaryStorageConfiguration(config); |
146 } | 148 } |
147 | 149 |
148 virtual int64_t RequestDiskUsage() { | 150 virtual int64_t RequestDiskUsage() { |
149 PostTaskAndReplyWithResult( | 151 PostTaskAndReplyWithResult( |
150 GetContext()->TaskRunner(), | 152 GetContext()->TaskRunner(), |
151 FROM_HERE, | 153 FROM_HERE, |
152 base::Bind(&IndexedDBContext::GetOriginDiskUsage, | 154 base::Bind(&IndexedDBContext::GetOriginDiskUsage, |
153 GetContext(), | 155 GetContext(), |
154 GURL("file:///")), | 156 GURL("file:///")), |
155 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, | 157 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 command_line->AppendSwitch(switches::kSingleProcess); | 856 command_line->AppendSwitch(switches::kSingleProcess); |
855 } | 857 } |
856 }; | 858 }; |
857 | 859 |
858 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 860 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
859 RenderThreadShutdownTest) { | 861 RenderThreadShutdownTest) { |
860 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 862 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
861 } | 863 } |
862 | 864 |
863 } // namespace content | 865 } // namespace content |
OLD | NEW |