Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: content/browser/in_process_webkit/indexed_db_browsertest.cc

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pass as cref, and fix style. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 6 #include "base/command_line.h"
6 #include "base/file_path.h" 7 #include "base/file_path.h"
7 #include "base/file_util.h" 8 #include "base/file_util.h"
8 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
9 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
10 #include "base/test/thread_test_helper.h" 11 #include "base/test/thread_test_helper.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { 219 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest {
219 public: 220 public:
220 virtual void SetUpOnMainThread() { 221 virtual void SetUpOnMainThread() {
221 const int kInitialQuotaKilobytes = 5000; 222 const int kInitialQuotaKilobytes = 5000;
222 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes 223 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes
223 * 1024 * QuotaManager::kPerHostTemporaryPortion; 224 * 1024 * QuotaManager::kPerHostTemporaryPortion;
224 SetTempQuota( 225 SetTempQuota(
225 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager()); 226 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager());
226 } 227 }
227 228
228 class SetTempQuotaCallback : public quota::QuotaCallback { 229 static void DidSetTempQuota(quota::QuotaStatusCode status,
229 public: 230 quota::StorageType type,
230 void Run(quota::QuotaStatusCode, quota::StorageType, int64) { 231 int64 quota) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
232 } 233 }
233
234 void RunWithParams(const Tuple3<quota::QuotaStatusCode,
235 quota::StorageType, int64>& params) {
236 Run(params.a, params.b, params.c);
237 }
238 };
239 234
240 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { 235 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) {
241 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 236 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
242 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 237 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
243 NewRunnableFunction(&IndexedDBBrowserTestWithLowQuota::SetTempQuota, 238 NewRunnableFunction(&IndexedDBBrowserTestWithLowQuota::SetTempQuota,
244 bytes, qm)); 239 bytes, qm));
245 return; 240 return;
246 } 241 }
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
248 qm->SetTemporaryGlobalQuota(bytes, new SetTempQuotaCallback); 243 qm->SetTemporaryGlobalQuota(
244 bytes,
245 base::Bind(&IndexedDBBrowserTestWithLowQuota::DidSetTempQuota));
249 // Don't return until the quota has been set. 246 // Don't return until the quota has been set.
250 scoped_refptr<base::ThreadTestHelper> helper( 247 scoped_refptr<base::ThreadTestHelper> helper(
251 new base::ThreadTestHelper( 248 new base::ThreadTestHelper(
252 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); 249 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
253 ASSERT_TRUE(helper->Run()); 250 ASSERT_TRUE(helper->Run());
254 } 251 }
255 252
256 }; 253 };
257 254
258 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithLowQuota, QuotaTest) { 255 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithLowQuota, QuotaTest) {
259 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html")))); 256 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html"))));
260 } 257 }
261 258
262 class IndexedDBBrowserTestWithGCExposed : public IndexedDBBrowserTest { 259 class IndexedDBBrowserTestWithGCExposed : public IndexedDBBrowserTest {
263 public: 260 public:
264 virtual void SetUpCommandLine(CommandLine* command_line) { 261 virtual void SetUpCommandLine(CommandLine* command_line) {
265 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); 262 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
266 } 263 }
267 }; 264 };
268 265
269 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, 266 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed,
270 DatabaseCallbacksTest) { 267 DatabaseCallbacksTest) {
271 SimpleTest( 268 SimpleTest(
272 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); 269 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html"))));
273 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698