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 <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 Loading... |
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( |
59 const int kTemporaryStorageQuotaMaxSize = | |
60 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; | |
61 SetTempQuota( | |
62 kTemporaryStorageQuotaMaxSize, | |
63 BrowserContext::GetDefaultStoragePartition( | 59 BrowserContext::GetDefaultStoragePartition( |
64 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); | 60 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, |
72 qm)); | 68 qm)); |
73 return; | 69 return; |
74 } | 70 } |
75 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 71 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
76 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); | 72 // These sizes must correspond with expectations in html and js. |
77 // Don't return until the quota has been set. | 73 const int kMeg = 1000 * 1024; |
78 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 74 storage::TemporaryStorageConfiguration config; |
79 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB).get())); | 75 config.pool_size = 25 * kMeg; |
80 ASSERT_TRUE(helper->Run()); | 76 config.per_host_quota = 5 * kMeg; |
| 77 config.must_remain_available = 100 * kMeg;; |
| 78 config.refresh_interval = base::TimeDelta::Max(); |
| 79 qm->SetTemporaryStorageConfiguration(config); |
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 |
OLD | NEW |