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

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: comments Created 4 years, 1 month 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 ;
kinuko 2016/11/11 17:14:56 nit: extra semicolon
michaeln 2016/11/11 22:41:33 Done.
78 settings.refresh_interval = base::TimeDelta::Max();
79 qm->SetQuotaSettings(settings);
81 } 80 }
82 }; 81 };
83 82
84 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { 83 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) {
85 SimpleTest(GetTestUrl("fileapi", "request_test.html")); 84 SimpleTest(GetTestUrl("fileapi", "request_test.html"));
86 } 85 }
87 86
88 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { 87 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) {
89 SimpleTest(GetTestUrl("fileapi", "create_test.html")); 88 SimpleTest(GetTestUrl("fileapi", "create_test.html"));
90 } 89 }
91 90
92 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { 91 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) {
93 SimpleTest(GetTestUrl("fileapi", "quota_test.html")); 92 SimpleTest(GetTestUrl("fileapi", "quota_test.html"));
94 } 93 }
95 94
96 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698