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; | 127 BrowserContext::GetDefaultStoragePartition( |
128 SetTempQuota(kTemporaryStorageQuotaSize, | 128 shell()->web_contents()->GetBrowserContext()) |
129 BrowserContext::GetDefaultStoragePartition( | 129 ->GetQuotaManager()); |
130 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); | |
131 } | 130 } |
132 | 131 |
133 static void SetTempQuota(int64_t bytes, scoped_refptr<QuotaManager> qm) { | 132 static void SetTempQuota(int per_host_quota_kilobytes, |
| 133 scoped_refptr<QuotaManager> qm) { |
134 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 134 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
135 BrowserThread::PostTask( | 135 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
136 BrowserThread::IO, FROM_HERE, | 136 base::Bind(&IndexedDBBrowserTest::SetTempQuota, |
137 base::Bind(&IndexedDBBrowserTest::SetTempQuota, bytes, qm)); | 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 qm->SetQuotaSettings( |
143 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 143 storage::GetHardCodedSettings(per_host_quota_kilobytes * KB)); |
144 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB))); | |
145 ASSERT_TRUE(helper->Run()); | |
146 } | 144 } |
147 | 145 |
148 virtual int64_t RequestDiskUsage() { | 146 virtual int64_t RequestDiskUsage() { |
149 PostTaskAndReplyWithResult( | 147 PostTaskAndReplyWithResult( |
150 GetContext()->TaskRunner(), | 148 GetContext()->TaskRunner(), |
151 FROM_HERE, | 149 FROM_HERE, |
152 base::Bind(&IndexedDBContext::GetOriginDiskUsage, | 150 base::Bind(&IndexedDBContext::GetOriginDiskUsage, |
153 GetContext(), | 151 GetContext(), |
154 GURL("file:///")), | 152 GURL("file:///")), |
155 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, | 153 base::Bind(&IndexedDBBrowserTest::DidGetDiskUsage, |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 command_line->AppendSwitch(switches::kSingleProcess); | 853 command_line->AppendSwitch(switches::kSingleProcess); |
856 } | 854 } |
857 }; | 855 }; |
858 | 856 |
859 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 857 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
860 RenderThreadShutdownTest) { | 858 RenderThreadShutdownTest) { |
861 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 859 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
862 } | 860 } |
863 | 861 |
864 } // namespace content | 862 } // namespace content |
OLD | NEW |