| 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_cache.h" | 5 #include "content/browser/cache_storage/cache_storage_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 CacheStorageCacheTest() | 324 CacheStorageCacheTest() |
| 325 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} | 325 : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {} |
| 326 | 326 |
| 327 void SetUp() override { | 327 void SetUp() override { |
| 328 ChromeBlobStorageContext* blob_storage_context = | 328 ChromeBlobStorageContext* blob_storage_context = |
| 329 ChromeBlobStorageContext::GetFor(&browser_context_); | 329 ChromeBlobStorageContext::GetFor(&browser_context_); |
| 330 // Wait for chrome_blob_storage_context to finish initializing. | 330 // Wait for chrome_blob_storage_context to finish initializing. |
| 331 base::RunLoop().RunUntilIdle(); | 331 base::RunLoop().RunUntilIdle(); |
| 332 blob_storage_context_ = blob_storage_context->context(); | 332 blob_storage_context_ = blob_storage_context->context(); |
| 333 | 333 |
| 334 if (!MemoryOnly()) | 334 const bool is_incognito = MemoryOnly(); |
| 335 base::FilePath temp_dir_path; |
| 336 if (!is_incognito) { |
| 335 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 337 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 338 temp_dir_path = temp_dir_.GetPath(); |
| 339 } |
| 336 | 340 |
| 337 quota_policy_ = new MockSpecialStoragePolicy; | 341 quota_policy_ = new MockSpecialStoragePolicy; |
| 338 mock_quota_manager_ = new MockQuotaManager( | 342 mock_quota_manager_ = new MockQuotaManager( |
| 339 MemoryOnly() /* is incognito */, temp_dir_.path(), | 343 is_incognito, temp_dir_path, base::ThreadTaskRunnerHandle::Get().get(), |
| 340 base::ThreadTaskRunnerHandle::Get().get(), | |
| 341 base::ThreadTaskRunnerHandle::Get().get(), quota_policy_.get()); | 344 base::ThreadTaskRunnerHandle::Get().get(), quota_policy_.get()); |
| 342 mock_quota_manager_->SetQuota(GURL(kOrigin), storage::kStorageTypeTemporary, | 345 mock_quota_manager_->SetQuota(GURL(kOrigin), storage::kStorageTypeTemporary, |
| 343 1024 * 1024 * 100); | 346 1024 * 1024 * 100); |
| 344 | 347 |
| 345 quota_manager_proxy_ = new MockQuotaManagerProxy( | 348 quota_manager_proxy_ = new MockQuotaManagerProxy( |
| 346 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); | 349 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); |
| 347 | 350 |
| 348 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); | 351 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); |
| 349 url_request_job_factory_->SetProtocolHandler( | 352 url_request_job_factory_->SetProtocolHandler( |
| 350 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context())); | 353 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context())); |
| 351 | 354 |
| 352 net::URLRequestContext* url_request_context = | 355 net::URLRequestContext* url_request_context = |
| 353 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> | 356 BrowserContext::GetDefaultStoragePartition(&browser_context_)-> |
| 354 GetURLRequestContext()->GetURLRequestContext(); | 357 GetURLRequestContext()->GetURLRequestContext(); |
| 355 | 358 |
| 356 url_request_context->set_job_factory(url_request_job_factory_.get()); | 359 url_request_context->set_job_factory(url_request_job_factory_.get()); |
| 357 | 360 |
| 358 CreateRequests(blob_storage_context); | 361 CreateRequests(blob_storage_context); |
| 359 | 362 |
| 360 cache_ = base::MakeUnique<TestCacheStorageCache>( | 363 cache_ = base::MakeUnique<TestCacheStorageCache>( |
| 361 GURL(kOrigin), kCacheName, temp_dir_.path(), nullptr /* CacheStorage */, | 364 GURL(kOrigin), kCacheName, temp_dir_path, nullptr /* CacheStorage */, |
| 362 BrowserContext::GetDefaultStoragePartition(&browser_context_) | 365 BrowserContext::GetDefaultStoragePartition(&browser_context_) |
| 363 ->GetURLRequestContext(), | 366 ->GetURLRequestContext(), |
| 364 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr()); | 367 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr()); |
| 365 cache_->Init(); | 368 cache_->Init(); |
| 366 } | 369 } |
| 367 | 370 |
| 368 void TearDown() override { | 371 void TearDown() override { |
| 369 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 372 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
| 370 base::RunLoop().RunUntilIdle(); | 373 base::RunLoop().RunUntilIdle(); |
| 371 } | 374 } |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 EXPECT_EQ(1, sequence_out); | 1623 EXPECT_EQ(1, sequence_out); |
| 1621 close_loop2->Run(); | 1624 close_loop2->Run(); |
| 1622 EXPECT_EQ(2, sequence_out); | 1625 EXPECT_EQ(2, sequence_out); |
| 1623 } | 1626 } |
| 1624 | 1627 |
| 1625 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, | 1628 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, |
| 1626 CacheStorageCacheTestP, | 1629 CacheStorageCacheTestP, |
| 1627 ::testing::Values(false, true)); | 1630 ::testing::Values(false, true)); |
| 1628 | 1631 |
| 1629 } // namespace content | 1632 } // namespace content |
| OLD | NEW |