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

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

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "content/browser/fileapi/chrome_blob_storage_context.h" 21 #include "content/browser/fileapi/chrome_blob_storage_context.h"
22 #include "content/browser/fileapi/mock_url_request_delegate.h" 22 #include "content/browser/fileapi/mock_url_request_delegate.h"
23 #include "content/browser/quota/mock_quota_manager_proxy.h" 23 #include "content/browser/quota/mock_quota_manager_proxy.h"
24 #include "content/common/cache_storage/cache_storage_types.h" 24 #include "content/common/cache_storage/cache_storage_types.h"
25 #include "content/common/service_worker/service_worker_types.h" 25 #include "content/common/service_worker/service_worker_types.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/storage_partition.h"
27 #include "content/public/common/referrer.h" 28 #include "content/public/common/referrer.h"
28 #include "content/public/test/mock_special_storage_policy.h" 29 #include "content/public/test/mock_special_storage_policy.h"
29 #include "content/public/test/test_browser_context.h" 30 #include "content/public/test/test_browser_context.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "net/base/test_completion_callback.h" 32 #include "net/base/test_completion_callback.h"
32 #include "net/url_request/url_request_context.h" 33 #include "net/url_request/url_request_context.h"
33 #include "net/url_request/url_request_context_getter.h" 34 #include "net/url_request/url_request_context_getter.h"
34 #include "net/url_request/url_request_job_factory_impl.h" 35 #include "net/url_request/url_request_job_factory_impl.h"
35 #include "storage/browser/blob/blob_data_builder.h" 36 #include "storage/browser/blob/blob_data_builder.h"
36 #include "storage/browser/blob/blob_data_handle.h" 37 #include "storage/browser/blob/blob_data_handle.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 1024 * 1024 * 100); 299 1024 * 1024 * 100);
299 300
300 quota_manager_proxy_ = new MockQuotaManagerProxy( 301 quota_manager_proxy_ = new MockQuotaManagerProxy(
301 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); 302 mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get());
302 303
303 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); 304 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl);
304 url_request_job_factory_->SetProtocolHandler( 305 url_request_job_factory_->SetProtocolHandler(
305 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context())); 306 "blob", CreateMockBlobProtocolHandler(blob_storage_context->context()));
306 307
307 net::URLRequestContext* url_request_context = 308 net::URLRequestContext* url_request_context =
308 browser_context_.GetRequestContext()->GetURLRequestContext(); 309 BrowserContext::GetDefaultStoragePartition(&browser_context_)->
310 GetURLRequestContext()->GetURLRequestContext();
309 311
310 url_request_context->set_job_factory(url_request_job_factory_.get()); 312 url_request_context->set_job_factory(url_request_job_factory_.get());
311 313
312 CreateRequests(blob_storage_context); 314 CreateRequests(blob_storage_context);
313 315
314 cache_ = make_scoped_refptr(new TestCacheStorageCache( 316 cache_ = make_scoped_refptr(new TestCacheStorageCache(
315 GURL(kOrigin), kCacheName, temp_dir_.path(), 317 GURL(kOrigin), kCacheName, temp_dir_.path(),
316 browser_context_.GetRequestContext(), quota_manager_proxy_, 318 BrowserContext::GetDefaultStoragePartition(&browser_context_)->
317 blob_storage_context->context()->AsWeakPtr())); 319 GetURLRequestContext(),
320 quota_manager_proxy_, blob_storage_context->context()->AsWeakPtr()));
318 } 321 }
319 322
320 void TearDown() override { 323 void TearDown() override {
321 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); 324 quota_manager_proxy_->SimulateQuotaManagerDestroyed();
322 base::RunLoop().RunUntilIdle(); 325 base::RunLoop().RunUntilIdle();
323 } 326 }
324 327
325 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { 328 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) {
326 ServiceWorkerHeaderMap headers; 329 ServiceWorkerHeaderMap headers;
327 headers.insert(std::make_pair("a", "a")); 330 headers.insert(std::make_pair("a", "a"));
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 EXPECT_FALSE(Put(no_body_request_, no_body_response_)); 607 EXPECT_FALSE(Put(no_body_request_, no_body_response_));
605 EXPECT_FALSE(Match(no_body_request_)); 608 EXPECT_FALSE(Match(no_body_request_));
606 EXPECT_FALSE(Delete(body_request_)); 609 EXPECT_FALSE(Delete(body_request_));
607 EXPECT_FALSE(Keys()); 610 EXPECT_FALSE(Keys());
608 } 611 }
609 612
610 virtual bool MemoryOnly() { return false; } 613 virtual bool MemoryOnly() { return false; }
611 614
612 protected: 615 protected:
613 base::ScopedTempDir temp_dir_; 616 base::ScopedTempDir temp_dir_;
617 TestBrowserThreadBundle browser_thread_bundle_;
614 TestBrowserContext browser_context_; 618 TestBrowserContext browser_context_;
615 TestBrowserThreadBundle browser_thread_bundle_;
616 std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; 619 std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_;
617 scoped_refptr<MockSpecialStoragePolicy> quota_policy_; 620 scoped_refptr<MockSpecialStoragePolicy> quota_policy_;
618 scoped_refptr<MockQuotaManager> mock_quota_manager_; 621 scoped_refptr<MockQuotaManager> mock_quota_manager_;
619 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; 622 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
620 storage::BlobStorageContext* blob_storage_context_; 623 storage::BlobStorageContext* blob_storage_context_;
621 624
622 scoped_refptr<TestCacheStorageCache> cache_; 625 scoped_refptr<TestCacheStorageCache> cache_;
623 626
624 ServiceWorkerFetchRequest body_request_; 627 ServiceWorkerFetchRequest body_request_;
625 ServiceWorkerResponse body_response_; 628 ServiceWorkerResponse body_response_;
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 EXPECT_EQ(1, sequence_out); 1307 EXPECT_EQ(1, sequence_out);
1305 close_loop2->Run(); 1308 close_loop2->Run();
1306 EXPECT_EQ(2, sequence_out); 1309 EXPECT_EQ(2, sequence_out);
1307 } 1310 }
1308 1311
1309 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, 1312 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest,
1310 CacheStorageCacheTestP, 1313 CacheStorageCacheTestP,
1311 ::testing::Values(false, true)); 1314 ::testing::Values(false, true));
1312 1315
1313 } // namespace content 1316 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698