Skip to content

Commit

Permalink
Remove an unused HttpCache constructor
Browse files Browse the repository at this point in the history
Also remove `is_main_cache` flag as it doesn't seem to be used other
than tests. Tests don't care about the flag actually.

Bug: N/A
Change-Id: Ic438cc886c58710bf64b3470a54dbfa058e09e4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3589874
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#994036}
  • Loading branch information
bashi authored and Chromium LUCI CQ committed Apr 20, 2022
1 parent ec55e31 commit 98265f2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 53 deletions.
14 changes: 1 addition & 13 deletions net/http/http_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,8 @@ class HttpCache::WorkItem {

//-----------------------------------------------------------------------------

HttpCache::HttpCache(HttpNetworkSession* session,
std::unique_ptr<BackendFactory> backend_factory,
bool is_main_cache)
: HttpCache(std::make_unique<HttpNetworkLayer>(session),
std::move(backend_factory),
is_main_cache) {
g_init_cache = true;
}

HttpCache::HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer,
std::unique_ptr<BackendFactory> backend_factory,
bool is_main_cache)
std::unique_ptr<BackendFactory> backend_factory)
: net_log_(nullptr),
backend_factory_(std::move(backend_factory)),
building_backend_(false),
Expand All @@ -262,8 +252,6 @@ HttpCache::HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer,
return;

net_log_ = session->net_log();
if (!is_main_cache)
return;

session->SetServerPushDelegate(
std::make_unique<HttpCacheLookupManager>(this));
Expand Down
18 changes: 1 addition & 17 deletions net/http/http_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,10 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory {
// again without validation.
static const int kPrefetchReuseMins = 5;

// The disk cache is initialized lazily (by CreateTransaction) in this case.
// Provide an existing HttpNetworkSession, the cache can construct a
// network layer with a shared HttpNetworkSession in order for multiple
// network layers to share information (e.g. authentication data). The
// HttpCache takes ownership of the |backend_factory|.
//
// The HttpCache must be destroyed before the HttpNetworkSession.
//
// If |is_main_cache| is true, configures the cache to track
// information about servers supporting QUIC.
// TODO(zhongyi): remove |is_main_cache| when we get rid of cache split.
HttpCache(HttpNetworkSession* session,
std::unique_ptr<BackendFactory> backend_factory,
bool is_main_cache);

// Initialize the cache from its component parts. |network_layer| and
// |backend_factory| will be destroyed when the HttpCache is.
HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer,
std::unique_ptr<BackendFactory> backend_factory,
bool is_main_cache);
std::unique_ptr<BackendFactory> backend_factory);

HttpCache(const HttpCache&) = delete;
HttpCache& operator=(const HttpCache&) = delete;
Expand Down
3 changes: 1 addition & 2 deletions net/http/http_cache_writers_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class TestHttpCache : public HttpCache {
public:
TestHttpCache(std::unique_ptr<HttpTransactionFactory> network_layer,
std::unique_ptr<BackendFactory> backend_factory)
: HttpCache(std::move(network_layer), std::move(backend_factory), false) {
}
: HttpCache(std::move(network_layer), std::move(backend_factory)) {}

void WritersDoneWritingToEntry(ActiveEntry* entry,
bool success,
Expand Down
14 changes: 3 additions & 11 deletions net/http/mock_http_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,21 +682,13 @@ int MockBackendFactory::CreateBackend(

//-----------------------------------------------------------------------------

MockHttpCache::MockHttpCache() : MockHttpCache(false) {}
MockHttpCache::MockHttpCache()
: MockHttpCache(std::make_unique<MockBackendFactory>()) {}

MockHttpCache::MockHttpCache(
std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory)
: MockHttpCache(std::move(disk_cache_factory), false) {}

MockHttpCache::MockHttpCache(bool is_main_cache)
: MockHttpCache(std::make_unique<MockBackendFactory>(), is_main_cache) {}

MockHttpCache::MockHttpCache(
std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory,
bool is_main_cache)
: http_cache_(std::make_unique<MockNetworkLayer>(),
std::move(disk_cache_factory),
is_main_cache) {}
std::move(disk_cache_factory)) {}

disk_cache::Backend* MockHttpCache::backend() {
TestCompletionCallback cb;
Expand Down
5 changes: 0 additions & 5 deletions net/http/mock_http_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ class MockHttpCache {
MockHttpCache();
explicit MockHttpCache(
std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory);
// |is_main_cache| if set, will set a quic server info factory.
explicit MockHttpCache(bool is_main_cache);

MockHttpCache(std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory,
bool is_main_cache);

HttpCache* http_cache() { return &http_cache_; }

Expand Down
5 changes: 2 additions & 3 deletions net/url_request/url_request_context_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,8 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
http_cache_params_.app_status_listener);
#endif

http_transaction_factory =
std::make_unique<HttpCache>(std::move(http_transaction_factory),
std::move(http_cache_backend), true);
http_transaction_factory = std::make_unique<HttpCache>(
std::move(http_transaction_factory), std::move(http_cache_backend));
}
storage->set_http_transaction_factory(std::move(http_transaction_factory));

Expand Down
3 changes: 1 addition & 2 deletions net/url_request/url_request_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9056,8 +9056,7 @@ TEST_F(URLRequestTestHTTP, NetworkSuspendTest) {
network_layer->OnSuspend();
std::unique_ptr<HttpTransactionFactory> factory =
std::make_unique<HttpCache>(std::move(network_layer),
HttpCache::DefaultBackend::InMemory(0),
/*is_main_cache=*/false);
HttpCache::DefaultBackend::InMemory(0));
return factory;
}));
auto context = context_builder->Build();
Expand Down

0 comments on commit 98265f2

Please sign in to comment.