OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/cache_storage/cache_storage_manager.h" | 5 #include "content/browser/cache_storage/cache_storage_manager.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop/message_loop_proxy.h" | |
11 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/thread_task_runner_handle.h" |
13 #include "content/browser/cache_storage/cache_storage_quota_client.h" | 13 #include "content/browser/cache_storage/cache_storage_quota_client.h" |
14 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 14 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
15 #include "content/browser/quota/mock_quota_manager_proxy.h" | 15 #include "content/browser/quota/mock_quota_manager_proxy.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/test/test_browser_context.h" | 17 #include "content/public/test/test_browser_context.h" |
18 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
20 #include "storage/browser/blob/blob_storage_context.h" | 20 #include "storage/browser/blob/blob_storage_context.h" |
21 #include "storage/browser/quota/quota_manager_proxy.h" | 21 #include "storage/browser/quota/quota_manager_proxy.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 class CacheStorageManagerTest : public testing::Test { | 26 class CacheStorageManagerTest : public testing::Test { |
27 public: | 27 public: |
28 CacheStorageManagerTest() | 28 CacheStorageManagerTest() |
29 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), | 29 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), |
30 callback_bool_(false), | 30 callback_bool_(false), |
31 callback_error_(CACHE_STORAGE_OK), | 31 callback_error_(CACHE_STORAGE_OK), |
32 origin1_("http://example1.com"), | 32 origin1_("http://example1.com"), |
33 origin2_("http://example2.com") {} | 33 origin2_("http://example2.com") {} |
34 | 34 |
35 void SetUp() override { | 35 void SetUp() override { |
36 ChromeBlobStorageContext* blob_storage_context( | 36 ChromeBlobStorageContext* blob_storage_context( |
37 ChromeBlobStorageContext::GetFor(&browser_context_)); | 37 ChromeBlobStorageContext::GetFor(&browser_context_)); |
38 // Wait for ChromeBlobStorageContext to finish initializing. | 38 // Wait for ChromeBlobStorageContext to finish initializing. |
39 base::RunLoop().RunUntilIdle(); | 39 base::RunLoop().RunUntilIdle(); |
40 | 40 |
41 quota_manager_proxy_ = new MockQuotaManagerProxy( | 41 quota_manager_proxy_ = new MockQuotaManagerProxy( |
42 nullptr, base::MessageLoopProxy::current().get()); | 42 nullptr, base::ThreadTaskRunnerHandle::Get().get()); |
43 | 43 |
44 net::URLRequestContext* url_request_context = | 44 net::URLRequestContext* url_request_context = |
45 browser_context_.GetRequestContext()->GetURLRequestContext(); | 45 browser_context_.GetRequestContext()->GetURLRequestContext(); |
46 if (MemoryOnly()) { | 46 if (MemoryOnly()) { |
47 cache_manager_ = CacheStorageManager::Create( | 47 cache_manager_ = CacheStorageManager::Create( |
48 base::FilePath(), base::MessageLoopProxy::current(), | 48 base::FilePath(), base::ThreadTaskRunnerHandle::Get(), |
49 quota_manager_proxy_); | 49 quota_manager_proxy_); |
50 } else { | 50 } else { |
51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
52 cache_manager_ = CacheStorageManager::Create( | 52 cache_manager_ = CacheStorageManager::Create( |
53 temp_dir_.path(), base::MessageLoopProxy::current(), | 53 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), |
54 quota_manager_proxy_); | 54 quota_manager_proxy_); |
55 } | 55 } |
56 | 56 |
57 cache_manager_->SetBlobParametersForCache( | 57 cache_manager_->SetBlobParametersForCache( |
58 url_request_context, blob_storage_context->context()->AsWeakPtr()); | 58 url_request_context, blob_storage_context->context()->AsWeakPtr()); |
59 } | 59 } |
60 | 60 |
61 void TearDown() override { | 61 void TearDown() override { |
62 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 62 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
63 base::RunLoop().RunUntilIdle(); | 63 base::RunLoop().RunUntilIdle(); |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 | 791 |
792 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, | 792 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, |
793 CacheStorageManagerTestP, | 793 CacheStorageManagerTestP, |
794 ::testing::Values(false, true)); | 794 ::testing::Values(false, true)); |
795 | 795 |
796 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, | 796 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, |
797 CacheStorageQuotaClientTestP, | 797 CacheStorageQuotaClientTestP, |
798 ::testing::Values(false, true)); | 798 ::testing::Values(false, true)); |
799 | 799 |
800 } // namespace content | 800 } // namespace content |
OLD | NEW |