Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: content/browser/cache_storage/cache_storage_cache_unittest.cc

Issue 1174943004: [CacheStorage] Use URLRequestContextGetter instead of URLRequestContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/ref_counted.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
11 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
12 #include "content/browser/fileapi/chrome_blob_storage_context.h" 13 #include "content/browser/fileapi/chrome_blob_storage_context.h"
13 #include "content/browser/fileapi/mock_url_request_delegate.h" 14 #include "content/browser/fileapi/mock_url_request_delegate.h"
14 #include "content/browser/quota/mock_quota_manager_proxy.h" 15 #include "content/browser/quota/mock_quota_manager_proxy.h"
15 #include "content/common/cache_storage/cache_storage_types.h" 16 #include "content/common/cache_storage/cache_storage_types.h"
16 #include "content/common/service_worker/service_worker_types.h" 17 #include "content/common/service_worker/service_worker_types.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/referrer.h" 19 #include "content/public/common/referrer.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 }; 122 };
122 123
123 } // namespace 124 } // namespace
124 125
125 // A CacheStorageCache that can optionally delay during backend creation. 126 // A CacheStorageCache that can optionally delay during backend creation.
126 class TestCacheStorageCache : public CacheStorageCache { 127 class TestCacheStorageCache : public CacheStorageCache {
127 public: 128 public:
128 TestCacheStorageCache( 129 TestCacheStorageCache(
129 const GURL& origin, 130 const GURL& origin,
130 const base::FilePath& path, 131 const base::FilePath& path,
131 net::URLRequestContext* request_context, 132 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
132 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, 133 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy,
133 base::WeakPtr<storage::BlobStorageContext> blob_context) 134 base::WeakPtr<storage::BlobStorageContext> blob_context)
134 : CacheStorageCache(origin, 135 : CacheStorageCache(origin,
135 path, 136 path,
136 request_context, 137 request_context_getter,
137 quota_manager_proxy, 138 quota_manager_proxy,
138 blob_context), 139 blob_context),
139 delay_backend_creation_(false) {} 140 delay_backend_creation_(false) {}
140 141
141 void CreateBackend(const ErrorCallback& callback) override { 142 void CreateBackend(const ErrorCallback& callback) override {
142 backend_creation_callback_ = callback; 143 backend_creation_callback_ = callback;
143 if (delay_backend_creation_) 144 if (delay_backend_creation_)
144 return; 145 return;
145 ContinueCreateBackend(); 146 ContinueCreateBackend();
146 } 147 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 198
198 url_request_context->set_job_factory(url_request_job_factory_.get()); 199 url_request_context->set_job_factory(url_request_job_factory_.get());
199 200
200 CreateRequests(blob_storage_context); 201 CreateRequests(blob_storage_context);
201 202
202 if (!MemoryOnly()) 203 if (!MemoryOnly())
203 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 204 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
204 base::FilePath path = MemoryOnly() ? base::FilePath() : temp_dir_.path(); 205 base::FilePath path = MemoryOnly() ? base::FilePath() : temp_dir_.path();
205 206
206 cache_ = make_scoped_refptr(new TestCacheStorageCache( 207 cache_ = make_scoped_refptr(new TestCacheStorageCache(
207 GURL("http://example.com"), path, url_request_context, 208 GURL("http://example.com"), path, browser_context_.GetRequestContext(),
208 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr())); 209 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr()));
209 } 210 }
210 211
211 void TearDown() override { 212 void TearDown() override {
212 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); 213 quota_manager_proxy_->SimulateQuotaManagerDestroyed();
213 base::RunLoop().RunUntilIdle(); 214 base::RunLoop().RunUntilIdle();
214 } 215 }
215 216
216 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { 217 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) {
217 ServiceWorkerHeaderMap headers; 218 ServiceWorkerHeaderMap headers;
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 EXPECT_EQ(1, sequence_out); 862 EXPECT_EQ(1, sequence_out);
862 close_loop2->Run(); 863 close_loop2->Run();
863 EXPECT_EQ(2, sequence_out); 864 EXPECT_EQ(2, sequence_out);
864 } 865 }
865 866
866 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, 867 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest,
867 CacheStorageCacheTestP, 868 CacheStorageCacheTestP,
868 ::testing::Values(false, true)); 869 ::testing::Values(false, true));
869 870
870 } // namespace content 871 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | content/browser/cache_storage/cache_storage_context_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698