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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); | 74 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); |
75 url_request_job_factory_->SetProtocolHandler( | 75 url_request_job_factory_->SetProtocolHandler( |
76 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context())); | 76 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context())); |
77 | 77 |
78 net::URLRequestContext* url_request_context = | 78 net::URLRequestContext* url_request_context = |
79 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> | 79 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> |
80 GetURLRequestContext()->GetURLRequestContext(); | 80 GetURLRequestContext()->GetURLRequestContext(); |
81 | 81 |
82 url_request_context->set_job_factory(url_request_job_factory_.get()); | 82 url_request_context->set_job_factory(url_request_job_factory_.get()); |
83 | 83 |
84 if (!MemoryOnly()) | 84 const bool is_incognito = MemoryOnly(); |
| 85 base::FilePath temp_dir_path; |
| 86 if (!is_incognito) { |
85 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 87 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 88 temp_dir_path = temp_dir_.GetPath(); |
| 89 } |
86 | 90 |
87 quota_policy_ = new MockSpecialStoragePolicy; | 91 quota_policy_ = new MockSpecialStoragePolicy; |
88 mock_quota_manager_ = new MockQuotaManager( | 92 mock_quota_manager_ = new MockQuotaManager( |
89 MemoryOnly() /* is incognito */, temp_dir_.path(), | 93 is_incognito, temp_dir_path, base::ThreadTaskRunnerHandle::Get().get(), |
90 base::ThreadTaskRunnerHandle::Get().get(), | |
91 base::ThreadTaskRunnerHandle::Get().get(), quota_policy_.get()); | 94 base::ThreadTaskRunnerHandle::Get().get(), quota_policy_.get()); |
92 mock_quota_manager_->SetQuota( | 95 mock_quota_manager_->SetQuota( |
93 GURL(origin1_), storage::kStorageTypeTemporary, 1024 * 1024 * 100); | 96 GURL(origin1_), storage::kStorageTypeTemporary, 1024 * 1024 * 100); |
94 mock_quota_manager_->SetQuota( | 97 mock_quota_manager_->SetQuota( |
95 GURL(origin2_), storage::kStorageTypeTemporary, 1024 * 1024 * 100); | 98 GURL(origin2_), storage::kStorageTypeTemporary, 1024 * 1024 * 100); |
96 | 99 |
97 quota_manager_proxy_ = new MockQuotaManagerProxy( | 100 quota_manager_proxy_ = new MockQuotaManagerProxy( |
98 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); | 101 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); |
99 | 102 |
100 cache_manager_ = CacheStorageManager::Create( | 103 cache_manager_ = CacheStorageManager::Create( |
101 temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(), | 104 temp_dir_path, base::ThreadTaskRunnerHandle::Get(), |
102 quota_manager_proxy_); | 105 quota_manager_proxy_); |
103 | 106 |
104 cache_manager_->SetBlobParametersForCache( | 107 cache_manager_->SetBlobParametersForCache( |
105 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> | 108 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> |
106 GetURLRequestContext(), | 109 GetURLRequestContext(), |
107 blob_storage_context->context()->AsWeakPtr()); | 110 blob_storage_context->context()->AsWeakPtr()); |
108 } | 111 } |
109 | 112 |
110 void TearDown() override { | 113 void TearDown() override { |
111 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 114 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 | 1442 |
1440 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, | 1443 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, |
1441 CacheStorageManagerTestP, | 1444 CacheStorageManagerTestP, |
1442 ::testing::Values(false, true)); | 1445 ::testing::Values(false, true)); |
1443 | 1446 |
1444 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, | 1447 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, |
1445 CacheStorageQuotaClientTestP, | 1448 CacheStorageQuotaClientTestP, |
1446 ::testing::Values(false, true)); | 1449 ::testing::Values(false, true)); |
1447 | 1450 |
1448 } // namespace content | 1451 } // namespace content |
OLD | NEW |