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

Side by Side Diff: content/browser/file_system/file_system_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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
8 #include "base/test/thread_test_helper.h" 9 #include "base/test/thread_test_helper.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
14 #include "content/common/content_switches.h" 15 #include "content/common/content_switches.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { 57 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest {
57 public: 58 public:
58 virtual void SetUpOnMainThread() { 59 virtual void SetUpOnMainThread() {
59 const int kInitialQuotaKilobytes = 5000; 60 const int kInitialQuotaKilobytes = 5000;
60 const int kTemporaryStorageQuotaMaxSize = 61 const int kTemporaryStorageQuotaMaxSize =
61 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; 62 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion;
62 SetTempQuota( 63 SetTempQuota(
63 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager()); 64 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager());
64 } 65 }
65 66
66 class SetTempQuotaCallback : public quota::QuotaCallback { 67 static void DidSetTempQuota(quota::QuotaStatusCode status,
67 public: 68 quota::StorageType type,
68 void Run(quota::QuotaStatusCode, quota::StorageType, int64) { 69 int64 quota) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
70 } 71 }
71
72 void RunWithParams(const Tuple3<quota::QuotaStatusCode,
73 quota::StorageType,
74 int64>& params) {
75 Run(params.a, params.b, params.c);
76 }
77 };
78 72
79 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { 73 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) {
80 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 74 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
81 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 75 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
82 NewRunnableFunction(&FileSystemBrowserTestWithLowQuota::SetTempQuota, 76 NewRunnableFunction(&FileSystemBrowserTestWithLowQuota::SetTempQuota,
83 bytes, qm)); 77 bytes, qm));
84 return; 78 return;
85 } 79 }
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
87 qm->SetTemporaryGlobalQuota(bytes, new SetTempQuotaCallback); 81 qm->SetTemporaryGlobalQuota(
82 bytes,
83 base::Bind(&FileSystemBrowserTestWithLowQuota::DidSetTempQuota));
88 // Don't return until the quota has been set. 84 // Don't return until the quota has been set.
89 scoped_refptr<base::ThreadTestHelper> helper( 85 scoped_refptr<base::ThreadTestHelper> helper(
90 new base::ThreadTestHelper( 86 new base::ThreadTestHelper(
91 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); 87 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
92 ASSERT_TRUE(helper->Run()); 88 ASSERT_TRUE(helper->Run());
93 } 89 }
94 }; 90 };
95 91
96 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { 92 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) {
97 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("request_test.html")))); 93 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("request_test.html"))));
98 } 94 }
99 95
100 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { 96 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) {
101 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("create_test.html")))); 97 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("create_test.html"))));
102 } 98 }
103 99
104 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { 100 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) {
105 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html")))); 101 SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("quota_test.html"))));
106 } 102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698