| 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> |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/location.h" | 10 #include "base/location.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 11 #include "base/test/thread_test_helper.h" | 13 #include "base/test/thread_test_helper.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 void SetUpOnMainThread() override { | 58 void SetUpOnMainThread() override { |
| 57 const int kInitialQuotaKilobytes = 5000; | 59 const int kInitialQuotaKilobytes = 5000; |
| 58 const int kTemporaryStorageQuotaMaxSize = | 60 const int kTemporaryStorageQuotaMaxSize = |
| 59 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; | 61 kInitialQuotaKilobytes * 1024 * QuotaManager::kPerHostTemporaryPortion; |
| 60 SetTempQuota( | 62 SetTempQuota( |
| 61 kTemporaryStorageQuotaMaxSize, | 63 kTemporaryStorageQuotaMaxSize, |
| 62 BrowserContext::GetDefaultStoragePartition( | 64 BrowserContext::GetDefaultStoragePartition( |
| 63 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); | 65 shell()->web_contents()->GetBrowserContext())->GetQuotaManager()); |
| 64 } | 66 } |
| 65 | 67 |
| 66 static void SetTempQuota(int64 bytes, scoped_refptr<QuotaManager> qm) { | 68 static void SetTempQuota(int64_t bytes, scoped_refptr<QuotaManager> qm) { |
| 67 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 69 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 68 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
| 69 BrowserThread::IO, FROM_HERE, | 71 BrowserThread::IO, FROM_HERE, |
| 70 base::Bind(&FileSystemBrowserTestWithLowQuota::SetTempQuota, bytes, | 72 base::Bind(&FileSystemBrowserTestWithLowQuota::SetTempQuota, bytes, |
| 71 qm)); | 73 qm)); |
| 72 return; | 74 return; |
| 73 } | 75 } |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); | 77 qm->SetTemporaryGlobalOverrideQuota(bytes, storage::QuotaCallback()); |
| 76 // Don't return until the quota has been set. | 78 // Don't return until the quota has been set. |
| 77 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( | 79 scoped_refptr<base::ThreadTestHelper> helper(new base::ThreadTestHelper( |
| 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get())); | 80 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get())); |
| 79 ASSERT_TRUE(helper->Run()); | 81 ASSERT_TRUE(helper->Run()); |
| 80 } | 82 } |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { | 85 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, RequestTest) { |
| 84 SimpleTest(GetTestUrl("fileapi", "request_test.html")); | 86 SimpleTest(GetTestUrl("fileapi", "request_test.html")); |
| 85 } | 87 } |
| 86 | 88 |
| 87 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { | 89 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTest, CreateTest) { |
| 88 SimpleTest(GetTestUrl("fileapi", "create_test.html")); | 90 SimpleTest(GetTestUrl("fileapi", "create_test.html")); |
| 89 } | 91 } |
| 90 | 92 |
| 91 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { | 93 IN_PROC_BROWSER_TEST_F(FileSystemBrowserTestWithLowQuota, QuotaTest) { |
| 92 SimpleTest(GetTestUrl("fileapi", "quota_test.html")); | 94 SimpleTest(GetTestUrl("fileapi", "quota_test.html")); |
| 93 } | 95 } |
| 94 | 96 |
| 95 } // namespace content | 97 } // namespace content |
| OLD | NEW |