Remove ServerPushDelegate and derived classes.
Server push is unused in HTTP/2 (it has been disabled a long time ago) and in QUIC (Google QUIC has been disabled altogether a long time ago, and IETF QUIC never supported server push), so all removed code is unused. Bug: 1426477 Change-Id: Icc4a97060c661007c2f137fa89c5e30f867b786e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4632342 Commit-Queue: Bence Béky <bnc@chromium.org> Commit-Queue: Ryan Hamilton <rch@chromium.org> Reviewed-by: Ryan Hamilton <rch@chromium.org> Cr-Commit-Position: refs/heads/main@{#1160861}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1d335168d2
commit
c880f90e67
net
BUILD.gn
http
http_cache.cchttp_cache_lookup_manager.cchttp_cache_lookup_manager.hhttp_cache_lookup_manager_unittest.cchttp_network_session.cchttp_network_session.h
quic
bidirectional_stream_quic_impl_unittest.ccquic_chromium_client_session.ccquic_chromium_client_session.hquic_chromium_client_session_test.ccquic_http_stream_test.ccquic_proxy_client_socket_unittest.ccquic_stream_factory.ccquic_stream_factory.h
spdy
server_push_delegate.hspdy_session.ccspdy_session.hspdy_session_pool.ccspdy_session_pool.hspdy_session_unittest.ccspdy_test_util_common.ccspdy_test_util_common.h
websockets
@ -615,8 +615,6 @@ component("net") {
|
||||
"http/http_byte_range.h",
|
||||
"http/http_cache.cc",
|
||||
"http/http_cache.h",
|
||||
"http/http_cache_lookup_manager.cc",
|
||||
"http/http_cache_lookup_manager.h",
|
||||
"http/http_cache_transaction.cc",
|
||||
"http/http_cache_transaction.h",
|
||||
"http/http_cache_writers.cc",
|
||||
@ -957,7 +955,6 @@ component("net") {
|
||||
"spdy/multiplexed_http_stream.h",
|
||||
"spdy/multiplexed_session.cc",
|
||||
"spdy/multiplexed_session.h",
|
||||
"spdy/server_push_delegate.h",
|
||||
"spdy/spdy_buffer.cc",
|
||||
"spdy/spdy_buffer.h",
|
||||
"spdy/spdy_buffer_producer.cc",
|
||||
@ -2657,7 +2654,6 @@ test("net_unittests") {
|
||||
"http/http_auth_unittest.cc",
|
||||
"http/http_basic_state_unittest.cc",
|
||||
"http/http_byte_range_unittest.cc",
|
||||
"http/http_cache_lookup_manager_unittest.cc",
|
||||
"http/http_cache_unittest.cc",
|
||||
"http/http_cache_writers_unittest.cc",
|
||||
"http/http_chunked_decoder_unittest.cc",
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "net/base/network_isolation_key.h"
|
||||
#include "net/base/upload_data_stream.h"
|
||||
#include "net/disk_cache/disk_cache.h"
|
||||
#include "net/http/http_cache_lookup_manager.h"
|
||||
#include "net/http/http_cache_transaction.h"
|
||||
#include "net/http/http_cache_writers.h"
|
||||
#include "net/http/http_network_layer.h"
|
||||
@ -243,9 +242,6 @@ HttpCache::HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer,
|
||||
return;
|
||||
|
||||
net_log_ = session->net_log();
|
||||
|
||||
session->SetServerPushDelegate(
|
||||
std::make_unique<HttpCacheLookupManager>(this));
|
||||
}
|
||||
|
||||
HttpCache::~HttpCache() {
|
||||
|
@ -1,110 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "net/http/http_cache_lookup_manager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/values.h"
|
||||
#include "net/base/load_flags.h"
|
||||
#include "net/base/network_anonymization_key.h"
|
||||
#include "net/http/http_request_info.h"
|
||||
namespace net {
|
||||
|
||||
// Returns parameters associated with the start of a server push lookup
|
||||
// transaction.
|
||||
base::Value::Dict NetLogPushLookupTransactionParams(
|
||||
const NetLogSource& net_log,
|
||||
const ServerPushDelegate::ServerPushHelper* push_helper) {
|
||||
base::Value::Dict dict;
|
||||
net_log.AddToEventParameters(dict);
|
||||
dict.Set("push_url", push_helper->GetURL().possibly_invalid_spec());
|
||||
return dict;
|
||||
}
|
||||
|
||||
HttpCacheLookupManager::LookupTransaction::LookupTransaction(
|
||||
std::unique_ptr<ServerPushHelper> server_push_helper,
|
||||
NetLog* net_log)
|
||||
: push_helper_(std::move(server_push_helper)),
|
||||
request_(std::make_unique<HttpRequestInfo>()),
|
||||
net_log_(NetLogWithSource::Make(
|
||||
net_log,
|
||||
NetLogSourceType::SERVER_PUSH_LOOKUP_TRANSACTION)) {}
|
||||
|
||||
HttpCacheLookupManager::LookupTransaction::~LookupTransaction() = default;
|
||||
|
||||
int HttpCacheLookupManager::LookupTransaction::StartLookup(
|
||||
HttpCache* cache,
|
||||
CompletionOnceCallback callback,
|
||||
const NetLogWithSource& session_net_log) {
|
||||
net_log_.BeginEvent(NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, [&] {
|
||||
return NetLogPushLookupTransactionParams(session_net_log.source(),
|
||||
push_helper_.get());
|
||||
});
|
||||
|
||||
request_->url = push_helper_->GetURL();
|
||||
// Note: since HTTP/2 Server Push has been disabled and this code will likely
|
||||
// be removed, just use empty NIKs and NAKs here. For more info, see
|
||||
// https://crbug.com/1355929.
|
||||
request_->network_isolation_key = NetworkIsolationKey();
|
||||
request_->network_anonymization_key = NetworkAnonymizationKey();
|
||||
request_->method = "GET";
|
||||
request_->load_flags = LOAD_ONLY_FROM_CACHE | LOAD_SKIP_CACHE_VALIDATION;
|
||||
cache->CreateTransaction(DEFAULT_PRIORITY, &transaction_);
|
||||
return transaction_->Start(request_.get(), std::move(callback), net_log_);
|
||||
}
|
||||
|
||||
void HttpCacheLookupManager::LookupTransaction::OnLookupComplete(int result) {
|
||||
if (result == OK) {
|
||||
DCHECK(push_helper_.get());
|
||||
push_helper_->Cancel();
|
||||
}
|
||||
net_log_.EndEventWithNetErrorCode(
|
||||
NetLogEventType::SERVER_PUSH_LOOKUP_TRANSACTION, result);
|
||||
}
|
||||
|
||||
HttpCacheLookupManager::HttpCacheLookupManager(HttpCache* http_cache)
|
||||
: http_cache_(http_cache) {}
|
||||
|
||||
HttpCacheLookupManager::~HttpCacheLookupManager() = default;
|
||||
|
||||
void HttpCacheLookupManager::OnPush(
|
||||
std::unique_ptr<ServerPushHelper> push_helper,
|
||||
const NetLogWithSource& session_net_log) {
|
||||
GURL pushed_url = push_helper->GetURL();
|
||||
|
||||
// There's a pending lookup transaction sent over already.
|
||||
if (base::Contains(lookup_transactions_, pushed_url))
|
||||
return;
|
||||
|
||||
auto lookup = std::make_unique<LookupTransaction>(std::move(push_helper),
|
||||
session_net_log.net_log());
|
||||
// TODO(zhongyi): add events in session net log to log the creation of
|
||||
// LookupTransaction.
|
||||
|
||||
int rv = lookup->StartLookup(
|
||||
http_cache_,
|
||||
base::BindOnce(&HttpCacheLookupManager::OnLookupComplete,
|
||||
weak_factory_.GetWeakPtr(), pushed_url),
|
||||
session_net_log);
|
||||
|
||||
if (rv == ERR_IO_PENDING) {
|
||||
lookup_transactions_[pushed_url] = std::move(lookup);
|
||||
} else {
|
||||
lookup->OnLookupComplete(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void HttpCacheLookupManager::OnLookupComplete(const GURL& url, int rv) {
|
||||
auto it = lookup_transactions_.find(url);
|
||||
DCHECK(it != lookup_transactions_.end());
|
||||
|
||||
it->second->OnLookupComplete(rv);
|
||||
|
||||
lookup_transactions_.erase(it);
|
||||
}
|
||||
|
||||
} // namespace net
|
@ -1,68 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_
|
||||
#define NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/http/http_cache.h"
|
||||
#include "net/http/http_cache_transaction.h"
|
||||
#include "net/spdy/server_push_delegate.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
struct HttpRequestInfo;
|
||||
|
||||
// An implementation of ServerPushDelegate that issues an HttpCache::Transaction
|
||||
// to lookup whether the response to the pushed URL is cached and cancel the
|
||||
// push in that case.
|
||||
class NET_EXPORT_PRIVATE HttpCacheLookupManager : public ServerPushDelegate {
|
||||
public:
|
||||
// |http_cache| MUST outlive the HttpCacheLookupManager.
|
||||
explicit HttpCacheLookupManager(HttpCache* http_cache);
|
||||
~HttpCacheLookupManager() override;
|
||||
|
||||
// ServerPushDelegate implementation.
|
||||
void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
|
||||
const NetLogWithSource& session_net_log) override;
|
||||
|
||||
// Invoked when the HttpCache::Transaction for |url| finishes to cancel the
|
||||
// server push if the response to the server push is found cached.
|
||||
void OnLookupComplete(const GURL& url, int rv);
|
||||
|
||||
private:
|
||||
// A class that takes the ownership of ServerPushHelper, issues and owns an
|
||||
// HttpCache::Transaction which lookups the response in cache for the server
|
||||
// push.
|
||||
class LookupTransaction {
|
||||
public:
|
||||
LookupTransaction(std::unique_ptr<ServerPushHelper> push_helper,
|
||||
NetLog* net_log);
|
||||
~LookupTransaction();
|
||||
|
||||
// Issues an HttpCache::Transaction to lookup whether the response is cached
|
||||
// without header validation.
|
||||
int StartLookup(HttpCache* cache,
|
||||
CompletionOnceCallback callback,
|
||||
const NetLogWithSource& session_net_log);
|
||||
|
||||
void OnLookupComplete(int result);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ServerPushHelper> push_helper_;
|
||||
std::unique_ptr<HttpRequestInfo> request_;
|
||||
std::unique_ptr<HttpTransaction> transaction_;
|
||||
const NetLogWithSource net_log_;
|
||||
};
|
||||
|
||||
// HttpCache must outlive the HttpCacheLookupManager.
|
||||
raw_ptr<HttpCache, DanglingUntriaged> http_cache_;
|
||||
std::map<GURL, std::unique_ptr<LookupTransaction>> lookup_transactions_;
|
||||
base::WeakPtrFactory<HttpCacheLookupManager> weak_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_HTTP_HTTP_CACHE_LOOKUP_MANAGER_H_
|
@ -1,349 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "net/base/features.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/base/schemeful_site.h"
|
||||
#include "net/base/test_completion_callback.h"
|
||||
#include "net/http/http_cache_lookup_manager.h"
|
||||
#include "net/http/http_transaction_test_util.h"
|
||||
#include "net/http/mock_http_cache.h"
|
||||
#include "net/test/gtest_util.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest-param-test.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
using net::test::IsOk;
|
||||
|
||||
namespace net {
|
||||
|
||||
namespace {
|
||||
|
||||
class MockServerPushHelper : public ServerPushDelegate::ServerPushHelper {
|
||||
public:
|
||||
explicit MockServerPushHelper(const GURL& url)
|
||||
: request_url_(url),
|
||||
network_isolation_key_(SchemefulSite(url), SchemefulSite(url)) {}
|
||||
|
||||
const GURL& GetURL() const override { return request_url_; }
|
||||
|
||||
NetworkAnonymizationKey GetNetworkAnonymizationKey() const override {
|
||||
return NetworkAnonymizationKey::CreateFromNetworkIsolationKey(
|
||||
network_isolation_key_);
|
||||
}
|
||||
|
||||
void set_network_isolation_key(
|
||||
const net::NetworkIsolationKey& network_isolation_key) {
|
||||
network_isolation_key_ = network_isolation_key;
|
||||
}
|
||||
|
||||
MOCK_METHOD0(Cancel, void());
|
||||
|
||||
private:
|
||||
const GURL request_url_;
|
||||
NetworkIsolationKey network_isolation_key_;
|
||||
};
|
||||
|
||||
std::unique_ptr<MockTransaction> CreateMockTransaction(const GURL& url) {
|
||||
MockTransaction mock_trans = {
|
||||
url.spec().c_str(),
|
||||
"GET",
|
||||
base::Time(),
|
||||
"",
|
||||
LOAD_NORMAL,
|
||||
DefaultTransportInfo(),
|
||||
"HTTP/1.1 200 OK",
|
||||
"Date: Wed, 28 Nov 2007 09:40:09 GMT\n"
|
||||
"Last-Modified: Wed, 28 Nov 2007 00:40:09 GMT\n",
|
||||
base::Time(),
|
||||
"<html><body>Google Blah Blah</body></html>",
|
||||
{},
|
||||
absl::nullopt,
|
||||
absl::nullopt,
|
||||
TEST_MODE_NORMAL,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
OK,
|
||||
};
|
||||
return std::make_unique<MockTransaction>(mock_trans);
|
||||
}
|
||||
|
||||
void PopulateCacheEntry(HttpCache* cache, const GURL& request_url) {
|
||||
TestCompletionCallback callback;
|
||||
|
||||
std::unique_ptr<MockTransaction> mock_trans =
|
||||
CreateMockTransaction(request_url);
|
||||
AddMockTransaction(mock_trans.get());
|
||||
|
||||
MockHttpRequest request(*(mock_trans.get()));
|
||||
std::unique_ptr<HttpTransaction> trans;
|
||||
int rv = cache->CreateTransaction(DEFAULT_PRIORITY, &trans);
|
||||
EXPECT_THAT(rv, IsOk());
|
||||
ASSERT_TRUE(trans.get());
|
||||
|
||||
rv = trans->Start(&request, callback.callback(), NetLogWithSource());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
if (rv == ERR_IO_PENDING)
|
||||
rv = callback.WaitForResult();
|
||||
|
||||
ASSERT_EQ(mock_trans->start_return_code, rv);
|
||||
if (OK != rv)
|
||||
return;
|
||||
|
||||
const HttpResponseInfo* response = trans->GetResponseInfo();
|
||||
ASSERT_TRUE(response);
|
||||
|
||||
std::string content;
|
||||
rv = ReadTransaction(trans.get(), &content);
|
||||
|
||||
EXPECT_THAT(rv, IsOk());
|
||||
std::string expected(mock_trans->data);
|
||||
EXPECT_EQ(expected, content);
|
||||
RemoveMockTransaction(mock_trans.get());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(HttpCacheLookupManagerTest, ServerPushMissCache) {
|
||||
base::test::TaskEnvironment task_environment;
|
||||
MockHttpCache mock_cache;
|
||||
HttpCacheLookupManager push_delegate(mock_cache.http_cache());
|
||||
GURL request_url("http://www.example.com/pushed.jpg");
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr = push_helper.get();
|
||||
|
||||
// Receive a server push and should not cancel the push.
|
||||
EXPECT_CALL(*push_helper_ptr, Cancel()).Times(0);
|
||||
push_delegate.OnPush(std::move(push_helper), NetLogWithSource());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Make sure no network transaction is created.
|
||||
EXPECT_EQ(0, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->create_count());
|
||||
}
|
||||
|
||||
TEST(HttpCacheLookupManagerTest, ServerPushDoNotCreateCacheEntry) {
|
||||
base::test::TaskEnvironment task_environment;
|
||||
MockHttpCache mock_cache;
|
||||
HttpCacheLookupManager push_delegate(mock_cache.http_cache());
|
||||
GURL request_url("http://www.example.com/pushed.jpg");
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr = push_helper.get();
|
||||
|
||||
// Receive a server push and should not cancel the push.
|
||||
EXPECT_CALL(*push_helper_ptr, Cancel()).Times(0);
|
||||
push_delegate.OnPush(std::move(push_helper), NetLogWithSource());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Receive another server push for the same url.
|
||||
std::unique_ptr<MockServerPushHelper> push_helper2 =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr2 = push_helper2.get();
|
||||
EXPECT_CALL(*push_helper_ptr2, Cancel()).Times(0);
|
||||
push_delegate.OnPush(std::move(push_helper2), NetLogWithSource());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Verify no network transaction is created.
|
||||
EXPECT_EQ(0, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->open_count());
|
||||
// Verify no cache entry is created for server push lookup.
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->create_count());
|
||||
}
|
||||
|
||||
// Parameterized by whether the network isolation key are the same for the
|
||||
// server push and corresponding cache entry.
|
||||
class HttpCacheLookupManagerTest_NetworkIsolationKey
|
||||
: public ::testing::Test,
|
||||
public ::testing::WithParamInterface<
|
||||
bool /* use_same_network_isolation_key */> {};
|
||||
|
||||
TEST_P(HttpCacheLookupManagerTest_NetworkIsolationKey, ServerPushCacheStatus) {
|
||||
bool use_same_network_isolation_key = GetParam();
|
||||
bool split_cache_enabled = base::FeatureList::IsEnabled(
|
||||
net::features::kSplitCacheByNetworkIsolationKey);
|
||||
|
||||
base::test::TaskEnvironment task_environment;
|
||||
MockHttpCache mock_cache;
|
||||
HttpCacheLookupManager push_delegate(mock_cache.http_cache());
|
||||
GURL request_url("http://www.example.com/pushed.jpg");
|
||||
|
||||
// Populate the cache entry so that the cache lookup for server push hits.
|
||||
PopulateCacheEntry(mock_cache.http_cache(), request_url);
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
|
||||
// Add another mock transaction since the OnPush will create a new cache
|
||||
// transaction.
|
||||
std::unique_ptr<MockTransaction> mock_trans =
|
||||
CreateMockTransaction(request_url);
|
||||
AddMockTransaction(mock_trans.get());
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
if (!use_same_network_isolation_key) {
|
||||
SchemefulSite site(GURL("http://www.abc.com"));
|
||||
push_helper->set_network_isolation_key(
|
||||
net::NetworkIsolationKey(site, site));
|
||||
}
|
||||
|
||||
MockServerPushHelper* push_helper_ptr = push_helper.get();
|
||||
|
||||
int expected_cancel_times =
|
||||
use_same_network_isolation_key || !split_cache_enabled ? 1 : 0;
|
||||
EXPECT_CALL(*push_helper_ptr, Cancel()).Times(expected_cancel_times);
|
||||
push_delegate.OnPush(std::move(push_helper), NetLogWithSource());
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Make sure no new net layer transaction is created.
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
|
||||
int expected_open_count =
|
||||
use_same_network_isolation_key || !split_cache_enabled ? 1 : 0;
|
||||
EXPECT_EQ(expected_open_count, mock_cache.disk_cache()->open_count());
|
||||
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
|
||||
RemoveMockTransaction(mock_trans.get());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
All,
|
||||
HttpCacheLookupManagerTest_NetworkIsolationKey,
|
||||
::testing::Bool());
|
||||
|
||||
// Test when a server push is received while the HttpCacheLookupManager has a
|
||||
// pending lookup transaction for the same URL, the new server push will not
|
||||
// send a new lookup transaction and should not be canceled.
|
||||
TEST(HttpCacheLookupManagerTest, ServerPushPendingLookup) {
|
||||
base::test::TaskEnvironment task_environment;
|
||||
MockHttpCache mock_cache;
|
||||
HttpCacheLookupManager push_delegate(mock_cache.http_cache());
|
||||
GURL request_url("http://www.example.com/pushed.jpg");
|
||||
|
||||
// Populate the cache entry so that the cache lookup for server push hits.
|
||||
PopulateCacheEntry(mock_cache.http_cache(), request_url);
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
|
||||
// Add another mock transaction since the OnPush will create a new cache
|
||||
// transaction.
|
||||
std::unique_ptr<MockTransaction> mock_trans =
|
||||
CreateMockTransaction(request_url);
|
||||
AddMockTransaction(mock_trans.get());
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr = push_helper.get();
|
||||
|
||||
// Receive a server push and should cancel the push eventually.
|
||||
EXPECT_CALL(*push_helper_ptr, Cancel()).Times(1);
|
||||
push_delegate.OnPush(std::move(push_helper), NetLogWithSource());
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper2 =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr2 = push_helper2.get();
|
||||
|
||||
// Receive another server push and should not cancel the push.
|
||||
EXPECT_CALL(*push_helper_ptr2, Cancel()).Times(0);
|
||||
push_delegate.OnPush(std::move(push_helper2), NetLogWithSource());
|
||||
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Make sure no new net layer transaction is created.
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
|
||||
RemoveMockTransaction(mock_trans.get());
|
||||
}
|
||||
|
||||
// Test the server push lookup is based on the full url.
|
||||
TEST(HttpCacheLookupManagerTest, ServerPushLookupOnUrl) {
|
||||
base::test::TaskEnvironment task_environment;
|
||||
MockHttpCache mock_cache;
|
||||
HttpCacheLookupManager push_delegate(mock_cache.http_cache());
|
||||
GURL request_url("http://www.example.com/pushed.jpg?u=0");
|
||||
GURL request_url2("http://www.example.com/pushed.jpg?u=1");
|
||||
|
||||
// Populate the cache entry so that the cache lookup for server push hits.
|
||||
PopulateCacheEntry(mock_cache.http_cache(), request_url);
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(0, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
|
||||
// Add another mock transaction since the OnPush will create a new cache
|
||||
// transaction.
|
||||
std::unique_ptr<MockTransaction> mock_trans =
|
||||
CreateMockTransaction(request_url);
|
||||
AddMockTransaction(mock_trans.get());
|
||||
|
||||
std::unique_ptr<MockServerPushHelper> push_helper =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr = push_helper.get();
|
||||
|
||||
// Receive a server push and should cancel the push eventually.
|
||||
EXPECT_CALL(*push_helper_ptr, Cancel()).Times(1);
|
||||
push_delegate.OnPush(std::move(push_helper), NetLogWithSource());
|
||||
// Run until the lookup transaction finishes for the first server push.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
RemoveMockTransaction(mock_trans.get());
|
||||
|
||||
AddMockTransaction(mock_trans.get());
|
||||
// Receive the second server push with same url after the first lookup
|
||||
// finishes, and should cancel the push.
|
||||
std::unique_ptr<MockServerPushHelper> push_helper2 =
|
||||
std::make_unique<MockServerPushHelper>(request_url);
|
||||
MockServerPushHelper* push_helper_ptr2 = push_helper2.get();
|
||||
|
||||
EXPECT_CALL(*push_helper_ptr2, Cancel()).Times(1);
|
||||
push_delegate.OnPush(std::move(push_helper2), NetLogWithSource());
|
||||
// Run until the lookup transaction finishes for the second server push.
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(2, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
RemoveMockTransaction(mock_trans.get());
|
||||
|
||||
std::unique_ptr<MockTransaction> mock_trans3 =
|
||||
CreateMockTransaction(request_url2);
|
||||
AddMockTransaction(mock_trans3.get());
|
||||
// Receive the third server push with a different url after lookup for a
|
||||
// similar server push has been completed, should not cancel the push.
|
||||
std::unique_ptr<MockServerPushHelper> push_helper3 =
|
||||
std::make_unique<MockServerPushHelper>(request_url2);
|
||||
MockServerPushHelper* push_helper_ptr3 = push_helper3.get();
|
||||
|
||||
EXPECT_CALL(*push_helper_ptr3, Cancel()).Times(0);
|
||||
push_delegate.OnPush(std::move(push_helper3), NetLogWithSource());
|
||||
|
||||
base::RunLoop().RunUntilIdle();
|
||||
// Make sure no new net layer transaction is created.
|
||||
EXPECT_EQ(1, mock_cache.network_layer()->transaction_count());
|
||||
EXPECT_EQ(2, mock_cache.disk_cache()->open_count());
|
||||
EXPECT_EQ(1, mock_cache.disk_cache()->create_count());
|
||||
RemoveMockTransaction(mock_trans3.get());
|
||||
}
|
||||
|
||||
} // namespace net
|
@ -349,17 +349,6 @@ void HttpNetworkSession::CloseIdleConnections(const char* net_log_reason_utf8) {
|
||||
spdy_session_pool_.CloseCurrentIdleSessions(net_log_reason_utf8);
|
||||
}
|
||||
|
||||
void HttpNetworkSession::SetServerPushDelegate(
|
||||
std::unique_ptr<ServerPushDelegate> push_delegate) {
|
||||
DCHECK(push_delegate);
|
||||
if (!params_.enable_server_push_cancellation || push_delegate_)
|
||||
return;
|
||||
|
||||
push_delegate_ = std::move(push_delegate);
|
||||
spdy_session_pool_.set_server_push_delegate(push_delegate_.get());
|
||||
quic_stream_factory_.set_server_push_delegate(push_delegate_.get());
|
||||
}
|
||||
|
||||
bool HttpNetworkSession::IsQuicEnabled() const {
|
||||
return params_.enable_quic;
|
||||
}
|
||||
|
@ -292,9 +292,6 @@ class NET_EXPORT HttpNetworkSession {
|
||||
// Returns the original Context used to construct this session.
|
||||
const HttpNetworkSessionContext& context() const { return context_; }
|
||||
|
||||
// TODO(https://crbug.com/1426477): Remove.
|
||||
void SetServerPushDelegate(std::unique_ptr<ServerPushDelegate> push_delegate);
|
||||
|
||||
// Returns protocols to be used with ALPN.
|
||||
const NextProtoVector& GetAlpnProtos() const { return next_protos_; }
|
||||
|
||||
@ -349,8 +346,6 @@ class NET_EXPORT HttpNetworkSession {
|
||||
WebSocketEndpointLockManager websocket_endpoint_lock_manager_;
|
||||
std::unique_ptr<ClientSocketPoolManager> normal_socket_pool_manager_;
|
||||
std::unique_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_;
|
||||
// TODO(https://crbug.com/1426477): Remove.
|
||||
std::unique_ptr<ServerPushDelegate> push_delegate_;
|
||||
QuicStreamFactory quic_stream_factory_;
|
||||
SpdySessionPool spdy_session_pool_;
|
||||
std::unique_ptr<HttpStreamFactory> http_stream_factory_;
|
||||
|
@ -535,7 +535,7 @@ class BidirectionalStreamQuicImplTest
|
||||
/*cert_verify_flags=*/0, quic::test::DefaultQuicConfig(),
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config_),
|
||||
dns_start, dns_end,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), nullptr,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr, HostResolverEndpointResult(),
|
||||
|
@ -363,32 +363,6 @@ void LogProbeResultToHistogram(MigrationCause cause, bool success) {
|
||||
histogram_name, base::HistogramBase::kUmaTargetedHistogramFlag));
|
||||
}
|
||||
|
||||
class QuicServerPushHelper : public ServerPushDelegate::ServerPushHelper {
|
||||
public:
|
||||
explicit QuicServerPushHelper(
|
||||
base::WeakPtr<QuicChromiumClientSession> session,
|
||||
const GURL& url)
|
||||
: session_(session), request_url_(url) {}
|
||||
|
||||
void Cancel() override {
|
||||
if (session_) {
|
||||
session_->CancelPush(request_url_);
|
||||
}
|
||||
}
|
||||
const GURL& GetURL() const override { return request_url_; }
|
||||
|
||||
NetworkAnonymizationKey GetNetworkAnonymizationKey() const override {
|
||||
if (session_) {
|
||||
return session_->quic_session_key().network_anonymization_key();
|
||||
}
|
||||
return NetworkAnonymizationKey();
|
||||
}
|
||||
|
||||
private:
|
||||
base::WeakPtr<QuicChromiumClientSession> session_;
|
||||
const GURL request_url_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
QuicChromiumClientSession::Handle::Handle(
|
||||
@ -1020,7 +994,6 @@ QuicChromiumClientSession::QuicChromiumClientSession(
|
||||
base::TimeTicks dns_resolution_start_time,
|
||||
base::TimeTicks dns_resolution_end_time,
|
||||
std::unique_ptr<quic::QuicClientPushPromiseIndex> push_promise_index,
|
||||
ServerPushDelegate* push_delegate,
|
||||
const base::TickClock* tick_clock,
|
||||
base::SequencedTaskRunner* task_runner,
|
||||
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
|
||||
@ -1064,7 +1037,6 @@ QuicChromiumClientSession::QuicChromiumClientSession(
|
||||
std::move(socket_performance_watcher),
|
||||
net_log_)),
|
||||
http3_logger_(std::make_unique<QuicHttp3Logger>(net_log_)),
|
||||
push_delegate_(push_delegate),
|
||||
push_promise_index_(std::move(push_promise_index)),
|
||||
path_validation_writer_delegate_(this, task_runner_),
|
||||
ech_config_list_(endpoint_result.metadata.ech_config_list) {
|
||||
@ -3893,15 +3865,6 @@ bool QuicChromiumClientSession::HandlePromised(
|
||||
const spdy::Http2HeaderBlock& headers) {
|
||||
bool result =
|
||||
quic::QuicSpdyClientSessionBase::HandlePromised(id, promised_id, headers);
|
||||
if (result && push_delegate_) {
|
||||
// The push promise is accepted, notify the push_delegate that a push
|
||||
// promise has been received.
|
||||
std::string pushed_url =
|
||||
quic::SpdyServerPushUtils::GetPromisedUrlFromHeaders(headers);
|
||||
push_delegate_->OnPush(std::make_unique<QuicServerPushHelper>(
|
||||
weak_factory_.GetWeakPtr(), GURL(pushed_url)),
|
||||
net_log_);
|
||||
}
|
||||
net_log_.AddEvent(NetLogEventType::QUIC_SESSION_PUSH_PROMISE_RECEIVED,
|
||||
[&](NetLogCaptureMode capture_mode) {
|
||||
return NetLogQuicPushPromiseReceivedParams(
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "net/socket/socket_performance_watcher.h"
|
||||
#include "net/spdy/http2_priority_dependencies.h"
|
||||
#include "net/spdy/multiplexed_session.h"
|
||||
#include "net/spdy/server_push_delegate.h"
|
||||
#include "net/third_party/quiche/src/quiche/quic/core/http/quic_client_push_promise_index.h"
|
||||
#include "net/third_party/quiche/src/quiche/quic/core/http/quic_spdy_client_session_base.h"
|
||||
#include "net/third_party/quiche/src/quiche/quic/core/quic_crypto_client_stream.h"
|
||||
@ -623,7 +622,6 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
|
||||
base::TimeTicks dns_resolution_start_time,
|
||||
base::TimeTicks dns_resolution_end_time,
|
||||
std::unique_ptr<quic::QuicClientPushPromiseIndex> push_promise_index,
|
||||
ServerPushDelegate* push_delegate,
|
||||
const base::TickClock* tick_clock,
|
||||
base::SequencedTaskRunner* task_runner,
|
||||
std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
|
||||
@ -1143,9 +1141,6 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
|
||||
bool port_migration_detected_ = false;
|
||||
bool quic_connection_migration_attempted_ = false;
|
||||
bool quic_connection_migration_successful_ = false;
|
||||
// Not owned. |push_delegate_| outlives the session and handles server pushes
|
||||
// received by session.
|
||||
raw_ptr<ServerPushDelegate> push_delegate_;
|
||||
// UMA histogram counters for streams pushed to this session.
|
||||
int streams_pushed_count_ = 0;
|
||||
int streams_pushed_and_claimed_count_ = 0;
|
||||
|
@ -187,7 +187,7 @@ class QuicChromiumClientSessionTest
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config_),
|
||||
base::TimeTicks::Now(), base::TimeTicks::Now(),
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
&test_push_delegate_, base::DefaultTickClock::GetInstance(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr, HostResolverEndpointResult(),
|
||||
NetLog::Get());
|
||||
@ -267,7 +267,6 @@ class QuicChromiumClientSessionTest
|
||||
std::unique_ptr<TestingQuicChromiumClientSession> session_;
|
||||
handles::NetworkHandle default_network_;
|
||||
std::unique_ptr<QuicConnectivityMonitor> connectivity_monitor_;
|
||||
TestServerPushDelegate test_push_delegate_;
|
||||
raw_ptr<quic::QuicConnectionVisitorInterface> visitor_;
|
||||
TestCompletionCallback callback_;
|
||||
QuicTestPacketMaker client_maker_;
|
||||
@ -1233,172 +1232,6 @@ TEST_P(QuicChromiumClientSessionTest, ClosePendingStream) {
|
||||
session_->ResetStream(id, quic::QUIC_STREAM_NO_ERROR);
|
||||
}
|
||||
|
||||
TEST_P(QuicChromiumClientSessionTest, CancelPushWhenPendingValidation) {
|
||||
MockQuicData quic_data(version_);
|
||||
int packet_num = 1;
|
||||
quic_data.AddWrite(ASYNC,
|
||||
client_maker_.MakeInitialSettingsPacket(packet_num++));
|
||||
quic_data.AddWrite(
|
||||
ASYNC, client_maker_.MakeRstPacket(
|
||||
packet_num++, GetNthClientInitiatedBidirectionalStreamId(0),
|
||||
quic::QUIC_RST_ACKNOWLEDGEMENT));
|
||||
quic_data.AddRead(ASYNC, ERR_IO_PENDING);
|
||||
quic_data.AddRead(ASYNC, ERR_CONNECTION_CLOSED);
|
||||
quic_data.AddSocketDataToFactory(&socket_factory_);
|
||||
Initialize();
|
||||
|
||||
ProofVerifyDetailsChromium details;
|
||||
details.cert_verify_result.verified_cert =
|
||||
ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
|
||||
ASSERT_TRUE(details.cert_verify_result.verified_cert.get());
|
||||
|
||||
CompleteCryptoHandshake();
|
||||
session_->OnProofVerifyDetailsAvailable(details);
|
||||
|
||||
QuicChromiumClientStream* stream =
|
||||
QuicChromiumClientSessionPeer::CreateOutgoingStream(session_.get());
|
||||
EXPECT_TRUE(stream);
|
||||
|
||||
spdy::Http2HeaderBlock promise_headers;
|
||||
promise_headers[":method"] = "GET";
|
||||
promise_headers[":authority"] = "www.example.org";
|
||||
promise_headers[":scheme"] = "https";
|
||||
promise_headers[":path"] = "/pushed.jpg";
|
||||
|
||||
// Receive a PUSH PROMISE from the server.
|
||||
EXPECT_TRUE(session_->HandlePromised(
|
||||
stream->id(), GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
promise_headers));
|
||||
|
||||
quic::QuicClientPromisedInfo* promised =
|
||||
session_->GetPromisedById(GetNthServerInitiatedUnidirectionalStreamId(0));
|
||||
EXPECT_TRUE(promised);
|
||||
|
||||
// Initiate rendezvous.
|
||||
spdy::Http2HeaderBlock client_request = promise_headers.Clone();
|
||||
quic::test::TestPushPromiseDelegate delegate(/*match=*/true);
|
||||
promised->HandleClientRequest(client_request, &delegate);
|
||||
|
||||
// Cancel the push before receiving the response to the pushed request.
|
||||
GURL pushed_url("https://www.example.org/pushed.jpg");
|
||||
test_push_delegate_.CancelPush(pushed_url);
|
||||
EXPECT_TRUE(session_->GetPromisedByUrl(pushed_url.spec()));
|
||||
|
||||
// Reset the stream now before tear down.
|
||||
session_->ResetStream(GetNthClientInitiatedBidirectionalStreamId(0),
|
||||
quic::QUIC_RST_ACKNOWLEDGEMENT);
|
||||
}
|
||||
|
||||
TEST_P(QuicChromiumClientSessionTest, CancelPushBeforeReceivingResponse) {
|
||||
MockQuicData quic_data(version_);
|
||||
int packet_num = 1;
|
||||
quic_data.AddWrite(ASYNC,
|
||||
client_maker_.MakeInitialSettingsPacket(packet_num++));
|
||||
quic_data.AddWrite(
|
||||
ASYNC, client_maker_.MakeRstPacket(
|
||||
packet_num++, GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
quic::QUIC_STREAM_CANCELLED));
|
||||
quic_data.AddRead(ASYNC, ERR_IO_PENDING);
|
||||
quic_data.AddRead(ASYNC, ERR_CONNECTION_CLOSED);
|
||||
quic_data.AddSocketDataToFactory(&socket_factory_);
|
||||
Initialize();
|
||||
|
||||
ProofVerifyDetailsChromium details;
|
||||
details.cert_verify_result.verified_cert =
|
||||
ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
|
||||
ASSERT_TRUE(details.cert_verify_result.verified_cert.get());
|
||||
|
||||
CompleteCryptoHandshake();
|
||||
session_->OnProofVerifyDetailsAvailable(details);
|
||||
|
||||
QuicChromiumClientStream* stream =
|
||||
QuicChromiumClientSessionPeer::CreateOutgoingStream(session_.get());
|
||||
EXPECT_TRUE(stream);
|
||||
|
||||
spdy::Http2HeaderBlock promise_headers;
|
||||
promise_headers[":method"] = "GET";
|
||||
promise_headers[":authority"] = "www.example.org";
|
||||
promise_headers[":scheme"] = "https";
|
||||
promise_headers[":path"] = "/pushed.jpg";
|
||||
|
||||
// Receive a PUSH PROMISE from the server.
|
||||
EXPECT_TRUE(session_->HandlePromised(
|
||||
stream->id(), GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
promise_headers));
|
||||
|
||||
quic::QuicClientPromisedInfo* promised =
|
||||
session_->GetPromisedById(GetNthServerInitiatedUnidirectionalStreamId(0));
|
||||
EXPECT_TRUE(promised);
|
||||
// Cancel the push before receiving the response to the pushed request.
|
||||
GURL pushed_url("https://www.example.org/pushed.jpg");
|
||||
test_push_delegate_.CancelPush(pushed_url);
|
||||
|
||||
EXPECT_FALSE(session_->GetPromisedByUrl(pushed_url.spec()));
|
||||
EXPECT_EQ(0u,
|
||||
QuicChromiumClientSessionPeer::GetPushedBytesCount(session_.get()));
|
||||
EXPECT_EQ(0u, QuicChromiumClientSessionPeer::GetPushedAndUnclaimedBytesCount(
|
||||
session_.get()));
|
||||
}
|
||||
|
||||
TEST_P(QuicChromiumClientSessionTest, CancelPushAfterReceivingResponse) {
|
||||
MockQuicData quic_data(version_);
|
||||
int packet_num = 1;
|
||||
quic_data.AddWrite(ASYNC,
|
||||
client_maker_.MakeInitialSettingsPacket(packet_num++));
|
||||
quic_data.AddWrite(
|
||||
ASYNC, client_maker_.MakeRstPacket(
|
||||
packet_num++, GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
quic::QUIC_STREAM_CANCELLED));
|
||||
quic_data.AddRead(ASYNC, ERR_IO_PENDING);
|
||||
quic_data.AddRead(ASYNC, ERR_CONNECTION_CLOSED);
|
||||
quic_data.AddSocketDataToFactory(&socket_factory_);
|
||||
|
||||
Initialize();
|
||||
|
||||
ProofVerifyDetailsChromium details;
|
||||
details.cert_verify_result.verified_cert =
|
||||
ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem");
|
||||
ASSERT_TRUE(details.cert_verify_result.verified_cert.get());
|
||||
|
||||
CompleteCryptoHandshake();
|
||||
session_->OnProofVerifyDetailsAvailable(details);
|
||||
|
||||
QuicChromiumClientStream* stream =
|
||||
QuicChromiumClientSessionPeer::CreateOutgoingStream(session_.get());
|
||||
EXPECT_TRUE(stream);
|
||||
|
||||
spdy::Http2HeaderBlock promise_headers;
|
||||
promise_headers[":method"] = "GET";
|
||||
promise_headers[":authority"] = "www.example.org";
|
||||
promise_headers[":scheme"] = "https";
|
||||
promise_headers[":path"] = "/pushed.jpg";
|
||||
|
||||
session_->GetOrCreateStream(GetNthServerInitiatedUnidirectionalStreamId(0));
|
||||
// Receive a PUSH PROMISE from the server.
|
||||
EXPECT_TRUE(session_->HandlePromised(
|
||||
stream->id(), GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
promise_headers));
|
||||
session_->OnInitialHeadersComplete(
|
||||
GetNthServerInitiatedUnidirectionalStreamId(0), spdy::Http2HeaderBlock());
|
||||
// Read data on the pushed stream.
|
||||
quic::QuicStreamFrame data(GetNthServerInitiatedUnidirectionalStreamId(0),
|
||||
false, 0, absl::string_view("SP"));
|
||||
session_->OnStreamFrame(data);
|
||||
|
||||
quic::QuicClientPromisedInfo* promised =
|
||||
session_->GetPromisedById(GetNthServerInitiatedUnidirectionalStreamId(0));
|
||||
EXPECT_TRUE(promised);
|
||||
// Cancel the push after receiving data on the push stream.
|
||||
GURL pushed_url("https://www.example.org/pushed.jpg");
|
||||
test_push_delegate_.CancelPush(pushed_url);
|
||||
|
||||
EXPECT_FALSE(session_->GetPromisedByUrl(pushed_url.spec()));
|
||||
EXPECT_EQ(2u,
|
||||
QuicChromiumClientSessionPeer::GetPushedBytesCount(session_.get()));
|
||||
EXPECT_EQ(2u, QuicChromiumClientSessionPeer::GetPushedAndUnclaimedBytesCount(
|
||||
session_.get()));
|
||||
}
|
||||
|
||||
TEST_P(QuicChromiumClientSessionTest, MaxNumStreamsViaRequest) {
|
||||
MockQuicData quic_data(version_);
|
||||
quic_data.AddWrite(SYNCHRONOUS, client_maker_.MakeInitialSettingsPacket(1));
|
||||
|
@ -420,7 +420,7 @@ class QuicHttpStreamTest : public ::testing::TestWithParam<TestParams>,
|
||||
/*cert_verify_flags=*/0, quic::test::DefaultQuicConfig(),
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config_),
|
||||
dns_start, dns_end,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), nullptr,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr, HostResolverEndpointResult(),
|
||||
|
@ -257,7 +257,7 @@ class QuicProxyClientSocketTest
|
||||
/*cert_verify_flags=*/0, quic::test::DefaultQuicConfig(),
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config_),
|
||||
dns_start, dns_end,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), nullptr,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr, HostResolverEndpointResult(),
|
||||
|
@ -2039,9 +2039,9 @@ bool QuicStreamFactory::CreateSessionHelper(
|
||||
yield_after_packets_, yield_after_duration_, cert_verify_flags, config,
|
||||
std::move(crypto_config_handle), dns_resolution_start_time,
|
||||
dns_resolution_end_time,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), push_delegate_,
|
||||
tick_clock_, task_runner_, std::move(socket_performance_watcher),
|
||||
endpoint_result, net_log.net_log());
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), tick_clock_,
|
||||
task_runner_, std::move(socket_performance_watcher), endpoint_result,
|
||||
net_log.net_log());
|
||||
|
||||
all_sessions_[*session] = key; // owning pointer
|
||||
writer->set_delegate(*session);
|
||||
|
@ -444,10 +444,6 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
|
||||
|
||||
quic::QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); }
|
||||
|
||||
void set_server_push_delegate(ServerPushDelegate* push_delegate) {
|
||||
push_delegate_ = push_delegate;
|
||||
}
|
||||
|
||||
handles::NetworkHandle default_network() const { return default_network_; }
|
||||
|
||||
// Returns the stored DNS aliases for the session key.
|
||||
@ -633,7 +629,6 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
|
||||
raw_ptr<HostResolver> host_resolver_;
|
||||
raw_ptr<ClientSocketFactory> client_socket_factory_;
|
||||
raw_ptr<HttpServerProperties> http_server_properties_;
|
||||
raw_ptr<ServerPushDelegate> push_delegate_ = nullptr;
|
||||
const raw_ptr<CertVerifier> cert_verifier_;
|
||||
const raw_ptr<CTPolicyEnforcer> ct_policy_enforcer_;
|
||||
const raw_ptr<TransportSecurityState> transport_security_state_;
|
||||
|
@ -1,45 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef NET_SPDY_SERVER_PUSH_DELEGATE_H_
|
||||
#define NET_SPDY_SERVER_PUSH_DELEGATE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "net/base/net_export.h"
|
||||
#include "net/log/net_log_with_source.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace net {
|
||||
|
||||
// An interface to a class that should be notified when session receives server
|
||||
// push.
|
||||
// TODO(https://crbug.com/1426477): Remove.
|
||||
class NET_EXPORT_PRIVATE ServerPushDelegate {
|
||||
public:
|
||||
// An interface to a class that reflects information on the pushed request.
|
||||
class NET_EXPORT ServerPushHelper {
|
||||
public:
|
||||
virtual ~ServerPushHelper() = default;
|
||||
|
||||
// Cancels the push if it is not claimed yet.
|
||||
virtual void Cancel() = 0;
|
||||
|
||||
// Gets the URL of the pushed request.
|
||||
virtual const GURL& GetURL() const = 0;
|
||||
|
||||
// Gets the network anonymization key for the pushed request.
|
||||
virtual NetworkAnonymizationKey GetNetworkAnonymizationKey() const = 0;
|
||||
};
|
||||
|
||||
virtual ~ServerPushDelegate() = default;
|
||||
|
||||
// Invoked by session when a push promise has been received.
|
||||
virtual void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
|
||||
const NetLogWithSource& session_net_log) = 0;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
||||
#endif // NET_SPDY_SERVER_PUSH_DELEGATE_H_
|
@ -409,29 +409,6 @@ size_t GetTotalSize(const T (&arr)[N]) {
|
||||
// the server permits more, we will never exceed this limit.
|
||||
const size_t kMaxConcurrentStreamLimit = 256;
|
||||
|
||||
// TODO(https://crbug.com/1426477): Remove.
|
||||
class SpdyServerPushHelper : public ServerPushDelegate::ServerPushHelper {
|
||||
public:
|
||||
explicit SpdyServerPushHelper(base::WeakPtr<SpdySession> session,
|
||||
const GURL& url)
|
||||
: session_(session), request_url_(url) {}
|
||||
|
||||
void Cancel() override {}
|
||||
|
||||
const GURL& GetURL() const override { return request_url_; }
|
||||
|
||||
NetworkAnonymizationKey GetNetworkAnonymizationKey() const override {
|
||||
if (session_) {
|
||||
return session_->spdy_session_key().network_anonymization_key();
|
||||
}
|
||||
return NetworkAnonymizationKey();
|
||||
}
|
||||
|
||||
private:
|
||||
base::WeakPtr<SpdySession> session_;
|
||||
const GURL request_url_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
SpdyProtocolErrorDetails MapFramerErrorToProtocolError(
|
||||
@ -844,7 +821,6 @@ SpdySession::SpdySession(
|
||||
bool http2_end_stream_with_data_frame,
|
||||
bool enable_priority_update,
|
||||
TimeFunc time_func,
|
||||
ServerPushDelegate* /*push_delegate*/,
|
||||
NetworkQualityEstimator* network_quality_estimator,
|
||||
NetLog* net_log)
|
||||
: spdy_session_key_(spdy_session_key),
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "net/spdy/buffered_spdy_framer.h"
|
||||
#include "net/spdy/http2_priority_dependencies.h"
|
||||
#include "net/spdy/multiplexed_session.h"
|
||||
#include "net/spdy/server_push_delegate.h"
|
||||
#include "net/spdy/spdy_buffer.h"
|
||||
#include "net/spdy/spdy_session_pool.h"
|
||||
#include "net/spdy/spdy_stream.h"
|
||||
@ -340,7 +339,6 @@ class NET_EXPORT SpdySession
|
||||
bool http2_end_stream_with_data_frame,
|
||||
bool enable_priority_update,
|
||||
TimeFunc time_func,
|
||||
ServerPushDelegate* push_delegate,
|
||||
NetworkQualityEstimator* network_quality_estimator,
|
||||
NetLog* net_log);
|
||||
|
||||
@ -667,7 +665,6 @@ class NET_EXPORT SpdySession
|
||||
// |request->OnRequestComplete{Success,Failure}()| will be called
|
||||
// when the stream is created (unless it is cancelled). Otherwise,
|
||||
// no stream is created and the error is returned.
|
||||
// TODO(https://crbug.com/1426477): Remove.
|
||||
int TryCreateStream(const base::WeakPtr<SpdyStreamRequest>& request,
|
||||
base::WeakPtr<SpdyStream>* stream);
|
||||
|
||||
|
@ -699,7 +699,7 @@ std::unique_ptr<SpdySession> SpdySessionPool::CreateSession(
|
||||
session_max_queued_capped_frames_, initial_settings_,
|
||||
enable_http2_settings_grease_, greased_http2_frame_,
|
||||
http2_end_stream_with_data_frame_, enable_priority_update_, time_func_,
|
||||
push_delegate_, network_quality_estimator_, net_log);
|
||||
network_quality_estimator_, net_log);
|
||||
}
|
||||
|
||||
base::WeakPtr<SpdySession> SpdySessionPool::InsertSession(
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "net/proxy_resolution/proxy_config.h"
|
||||
#include "net/socket/connect_job.h"
|
||||
#include "net/socket/ssl_client_socket.h"
|
||||
#include "net/spdy/server_push_delegate.h"
|
||||
#include "net/spdy/spdy_session_key.h"
|
||||
#include "net/ssl/ssl_config_service.h"
|
||||
#include "net/third_party/quiche/src/quiche/quic/core/quic_versions.h"
|
||||
@ -290,10 +289,6 @@ class NET_EXPORT SpdySessionPool
|
||||
return http_server_properties_;
|
||||
}
|
||||
|
||||
void set_server_push_delegate(ServerPushDelegate* push_delegate) {
|
||||
push_delegate_ = push_delegate;
|
||||
}
|
||||
|
||||
// NetworkChangeNotifier::IPAddressObserver methods:
|
||||
|
||||
// We flush all idle sessions and release references to the active ones so
|
||||
@ -493,7 +488,6 @@ class NET_EXPORT SpdySessionPool
|
||||
SpdySessionRequestMap spdy_session_request_map_;
|
||||
|
||||
TimeFunc time_func_;
|
||||
raw_ptr<ServerPushDelegate> push_delegate_ = nullptr;
|
||||
|
||||
raw_ptr<NetworkQualityEstimator> network_quality_estimator_;
|
||||
|
||||
|
@ -72,7 +72,6 @@
|
||||
|
||||
using net::test::IsError;
|
||||
using net::test::IsOk;
|
||||
using net::test::TestServerPushDelegate;
|
||||
using testing::_;
|
||||
|
||||
namespace net {
|
||||
@ -204,11 +203,7 @@ class SpdySessionTest : public PlatformTest, public WithTaskEnvironment {
|
||||
void CreateNetworkSession() {
|
||||
DCHECK(!http_session_);
|
||||
DCHECK(!spdy_session_pool_);
|
||||
http_session_ =
|
||||
SpdySessionDependencies::SpdyCreateSession(&session_deps_);
|
||||
auto test_push_delegate = std::make_unique<TestServerPushDelegate>();
|
||||
test_push_delegate_ = test_push_delegate.get();
|
||||
http_session_->SetServerPushDelegate(std::move(test_push_delegate));
|
||||
http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
|
||||
spdy_session_pool_ = http_session_->spdy_session_pool();
|
||||
}
|
||||
|
||||
@ -373,7 +368,6 @@ class SpdySessionTest : public PlatformTest, public WithTaskEnvironment {
|
||||
SpdySessionDependencies session_deps_;
|
||||
std::unique_ptr<HttpNetworkSession> http_session_;
|
||||
base::WeakPtr<SpdySession> session_;
|
||||
raw_ptr<TestServerPushDelegate> test_push_delegate_ = nullptr;
|
||||
raw_ptr<SpdySessionPool> spdy_session_pool_ = nullptr;
|
||||
const GURL test_url_;
|
||||
const url::SchemeHostPort test_server_;
|
||||
|
@ -1022,23 +1022,5 @@ HashValue GetTestHashValue(uint8_t label) {
|
||||
return hash_value;
|
||||
}
|
||||
|
||||
TestServerPushDelegate::TestServerPushDelegate() = default;
|
||||
|
||||
TestServerPushDelegate::~TestServerPushDelegate() = default;
|
||||
|
||||
void TestServerPushDelegate::OnPush(
|
||||
std::unique_ptr<ServerPushHelper> push_helper,
|
||||
const NetLogWithSource& session_net_log) {
|
||||
push_helpers[push_helper->GetURL()] = std::move(push_helper);
|
||||
}
|
||||
|
||||
bool TestServerPushDelegate::CancelPush(GURL url) {
|
||||
auto itr = push_helpers.find(url);
|
||||
DCHECK(itr != push_helpers.end());
|
||||
itr->second->Cancel();
|
||||
push_helpers.erase(itr);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace net
|
||||
|
@ -500,22 +500,6 @@ namespace test {
|
||||
// Returns a SHA1 HashValue in which each byte has the value |label|.
|
||||
HashValue GetTestHashValue(uint8_t label);
|
||||
|
||||
// A test implementation of ServerPushDelegate that caches all the pushed
|
||||
// request and provides a interface to cancel the push given url.
|
||||
class TestServerPushDelegate : public ServerPushDelegate {
|
||||
public:
|
||||
TestServerPushDelegate();
|
||||
~TestServerPushDelegate() override;
|
||||
|
||||
void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
|
||||
const NetLogWithSource& session_net_log) override;
|
||||
|
||||
bool CancelPush(GURL url);
|
||||
|
||||
private:
|
||||
std::map<GURL, std::unique_ptr<ServerPushHelper>> push_helpers;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace net
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ class WebSocketQuicStreamAdapterTest
|
||||
/*cert_verify_flags=*/0, quic::test::DefaultQuicConfig(),
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config_),
|
||||
dns_start, dns_end,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), nullptr,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr, HostResolverEndpointResult(),
|
||||
|
@ -444,7 +444,7 @@ class WebSocketHandshakeStreamCreateHelperTest
|
||||
/*cert_verify_flags=*/0, quic::test::DefaultQuicConfig(),
|
||||
std::make_unique<TestQuicCryptoClientConfigHandle>(&crypto_config),
|
||||
dns_start, dns_end,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(), nullptr,
|
||||
std::make_unique<quic::QuicClientPushPromiseIndex>(),
|
||||
base::DefaultTickClock::GetInstance(),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault().get(),
|
||||
/*socket_performance_watcher=*/nullptr,
|
||||
|
Reference in New Issue
Block a user