Chromium Code Reviews| 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 "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 } // namespace | 123 } // namespace |
| 124 | 124 |
| 125 // A CacheStorageCache that can optionally delay during backend creation. | 125 // A CacheStorageCache that can optionally delay during backend creation. |
| 126 class TestCacheStorageCache : public CacheStorageCache { | 126 class TestCacheStorageCache : public CacheStorageCache { |
| 127 public: | 127 public: |
| 128 TestCacheStorageCache( | 128 TestCacheStorageCache( |
| 129 const GURL& origin, | 129 const GURL& origin, |
| 130 const base::FilePath& path, | 130 const base::FilePath& path, |
| 131 net::URLRequestContext* request_context, | 131 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
|
mmenke
2015/06/10 17:00:31
include ref_counted.h
jkarlin
2015/06/10 18:26:03
Done.
| |
| 132 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, | 132 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, |
| 133 base::WeakPtr<storage::BlobStorageContext> blob_context) | 133 base::WeakPtr<storage::BlobStorageContext> blob_context) |
| 134 : CacheStorageCache(origin, | 134 : CacheStorageCache(origin, |
| 135 path, | 135 path, |
| 136 request_context, | 136 request_context, |
| 137 quota_manager_proxy, | 137 quota_manager_proxy, |
| 138 blob_context), | 138 blob_context), |
| 139 delay_backend_creation_(false) {} | 139 delay_backend_creation_(false) {} |
| 140 | 140 |
| 141 void CreateBackend(const ErrorCallback& callback) override { | 141 void CreateBackend(const ErrorCallback& callback) override { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 197 |
| 198 url_request_context->set_job_factory(url_request_job_factory_.get()); | 198 url_request_context->set_job_factory(url_request_job_factory_.get()); |
| 199 | 199 |
| 200 CreateRequests(blob_storage_context); | 200 CreateRequests(blob_storage_context); |
| 201 | 201 |
| 202 if (!MemoryOnly()) | 202 if (!MemoryOnly()) |
| 203 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 203 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 204 base::FilePath path = MemoryOnly() ? base::FilePath() : temp_dir_.path(); | 204 base::FilePath path = MemoryOnly() ? base::FilePath() : temp_dir_.path(); |
| 205 | 205 |
| 206 cache_ = make_scoped_refptr(new TestCacheStorageCache( | 206 cache_ = make_scoped_refptr(new TestCacheStorageCache( |
| 207 GURL("http://example.com"), path, url_request_context, | 207 GURL("http://example.com"), path, browser_context_.GetRequestContext(), |
| 208 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr())); | 208 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr())); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void TearDown() override { | 211 void TearDown() override { |
| 212 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 212 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
| 213 base::RunLoop().RunUntilIdle(); | 213 base::RunLoop().RunUntilIdle(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { | 216 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { |
| 217 ServiceWorkerHeaderMap headers; | 217 ServiceWorkerHeaderMap headers; |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 EXPECT_EQ(1, sequence_out); | 861 EXPECT_EQ(1, sequence_out); |
| 862 close_loop2->Run(); | 862 close_loop2->Run(); |
| 863 EXPECT_EQ(2, sequence_out); | 863 EXPECT_EQ(2, sequence_out); |
| 864 } | 864 } |
| 865 | 865 |
| 866 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, | 866 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, |
| 867 CacheStorageCacheTestP, | 867 CacheStorageCacheTestP, |
| 868 ::testing::Values(false, true)); | 868 ::testing::Values(false, true)); |
| 869 | 869 |
| 870 } // namespace content | 870 } // namespace content |
| OLD | NEW |