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

Side by Side Diff: content/browser/fileapi/file_system_browsertest.cc

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 10 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
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 the_browser, "window.domAutomationController.send(getLog())", 48 the_browser, "window.domAutomationController.send(getLog())",
49 &js_result)); 49 &js_result));
50 FAIL() << "Failed: " << js_result; 50 FAIL() << "Failed: " << js_result;
51 } 51 }
52 } 52 }
53 }; 53 };
54 54
55 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest { 55 class FileSystemBrowserTestWithLowQuota : public FileSystemBrowserTest {
56 public: 56 public:
57 void SetUpOnMainThread() override { 57 void SetUpOnMainThread() override {
58 const int kInitialQuotaKilobytes = 5000; 58 SetLowQuota(BrowserContext::GetDefaultStoragePartition(
59 const int kTemporaryStorageQuotaMaxSize = 59 shell()->web_contents()->GetBrowserContext())
60 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; 60 ->GetQuotaManager());
61 SetTempQuota(
62 kTemporaryStorageQuotaMaxSize,
63 BrowserContext::GetDefaultStoragePartition(
64 shell()->web_contents()->GetBrowserContext())->GetQuotaManager());
65 } 61 }
66 62
67 static void SetTempQuota(int64_t bytes, scoped_refptr<QuotaManager> qm) { 63 static void SetLowQuota(scoped_refptr<QuotaManager> qm) {
68 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 64 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
69 BrowserThread::PostTask( 65 BrowserThread::PostTask(
70 BrowserThread::IO, FROM_HERE, 66 BrowserThread::IO, FROM_HERE,
71 base::Bind(&FileSystemBrowserTestWithLowQuota::SetTempQuota, bytes, 67 base::Bind(&FileSystemBrowserTestWithLowQuota::SetLowQuota, qm));
72 qm));
73 return; 68 return;
74 } 69 }
75 DCHECK_CURRENTLY_ON(BrowserThread::IO); 70 DCHECK_CURRENTLY_ON(BrowserThread::IO);
76 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); 71 // These sizes must correspond with expectations in html and js.
77 // Don't return until the quota has been set. 72 const int kMeg = 1000 * 1024;
78 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( 73 storage::QuotaSettings settings;
79 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB).get())); 74 settings.pool_size = 25 * kMeg;
80 ASSERT_TRUE(helper->Run()); 75 settings.per_host_quota = 5 * kMeg;
76 settings.must_remain_available = 100 * kMeg;
77 settings.refresh_interval = base::TimeDelta::Max();
78 qm->SetQuotaSettings(settings);
81 } 79 }
82 }; 80 };
83 81
84 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { 82 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) {
85 SimpleTest(GetTestUrl("fileapi", "request_test.html")); 83 SimpleTest(GetTestUrl("fileapi", "request_test.html"));
86 } 84 }
87 85
88 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { 86 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) {
89 SimpleTest(GetTestUrl("fileapi", "create_test.html")); 87 SimpleTest(GetTestUrl("fileapi", "create_test.html"));
90 } 88 }
91 89
92 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { 90 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) {
93 SimpleTest(GetTestUrl("fileapi", "quota_test.html")); 91 SimpleTest(GetTestUrl("fileapi", "quota_test.html"));
94 } 92 }
95 93
96 } // namespace content 94 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/database_tracker_unittest.cc ('k') | content/browser/fileapi/obfuscated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698