Commit 7dd80832 authored by Helen Li's avatar Helen Li Committed by Commit Bot

Remove SDCH code from net/url_request/

SDCH has been disabled in Chrome since M59. For more details please see
Issue 690070 and blink-dev@ thread linked below.

This CL is to remove sdch code from net/url_request.
This is the first CL in the series.

Bug: 762686
Change-Id: If467b19a2b963c3790bf372ab278bbf847052ddf
Reviewed-on: https://chromium-review.googlesource.com/660999Reviewed-by: default avatarRandy Smith <rdsmith@chromium.org>
Commit-Queue: Helen Li <xunjieli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501339}
parent d7ac011a
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_request_args.h" #include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/process_memory_dump.h" #include "base/trace_event/process_memory_dump.h"
#include "net/base/sdch_manager.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "net/dns/host_resolver.h" #include "net/dns/host_resolver.h"
#include "net/http/http_cache.h" #include "net/http/http_cache.h"
...@@ -46,7 +45,6 @@ URLRequestContext::URLRequestContext() ...@@ -46,7 +45,6 @@ URLRequestContext::URLRequestContext()
job_factory_(nullptr), job_factory_(nullptr),
throttler_manager_(nullptr), throttler_manager_(nullptr),
backoff_manager_(nullptr), backoff_manager_(nullptr),
sdch_manager_(nullptr),
network_quality_estimator_(nullptr), network_quality_estimator_(nullptr),
reporting_service_(nullptr), reporting_service_(nullptr),
network_error_logging_delegate_(nullptr), network_error_logging_delegate_(nullptr),
...@@ -84,7 +82,6 @@ void URLRequestContext::CopyFrom(const URLRequestContext* other) { ...@@ -84,7 +82,6 @@ void URLRequestContext::CopyFrom(const URLRequestContext* other) {
set_job_factory(other->job_factory_); set_job_factory(other->job_factory_);
set_throttler_manager(other->throttler_manager_); set_throttler_manager(other->throttler_manager_);
set_backoff_manager(other->backoff_manager_); set_backoff_manager(other->backoff_manager_);
set_sdch_manager(other->sdch_manager_);
set_http_user_agent_settings(other->http_user_agent_settings_); set_http_user_agent_settings(other->http_user_agent_settings_);
set_network_quality_estimator(other->network_quality_estimator_); set_network_quality_estimator(other->network_quality_estimator_);
set_reporting_service(other->reporting_service_); set_reporting_service(other->reporting_service_);
...@@ -194,8 +191,6 @@ bool URLRequestContext::OnMemoryDump( ...@@ -194,8 +191,6 @@ bool URLRequestContext::OnMemoryDump(
if (http_cache) if (http_cache)
http_cache->DumpMemoryStats(pmd, dump->absolute_name()); http_cache->DumpMemoryStats(pmd, dump->absolute_name());
} }
if (sdch_manager_)
sdch_manager_->DumpMemoryStats(pmd, dump_name);
return true; return true;
} }
......
...@@ -218,10 +218,9 @@ class NET_EXPORT URLRequestContext ...@@ -218,10 +218,9 @@ class NET_EXPORT URLRequestContext
} }
// May return nullptr. // May return nullptr.
SdchManager* sdch_manager() const { return sdch_manager_; } // TODO(xunjieli): Remove this when SdchManager is removed. crbug.com/762686
void set_sdch_manager(SdchManager* sdch_manager) { SdchManager* sdch_manager() const { return nullptr; }
sdch_manager_ = sdch_manager; void set_sdch_manager(SdchManager* sdch_manager) { NOTREACHED(); }
}
// Gets the URLRequest objects that hold a reference to this // Gets the URLRequest objects that hold a reference to this
// URLRequestContext. // URLRequestContext.
...@@ -325,7 +324,6 @@ class NET_EXPORT URLRequestContext ...@@ -325,7 +324,6 @@ class NET_EXPORT URLRequestContext
const URLRequestJobFactory* job_factory_; const URLRequestJobFactory* job_factory_;
URLRequestThrottlerManager* throttler_manager_; URLRequestThrottlerManager* throttler_manager_;
URLRequestBackoffManager* backoff_manager_; URLRequestBackoffManager* backoff_manager_;
SdchManager* sdch_manager_;
NetworkQualityEstimator* network_quality_estimator_; NetworkQualityEstimator* network_quality_estimator_;
ReportingService* reporting_service_; ReportingService* reporting_service_;
NetworkErrorLoggingDelegate* network_error_logging_delegate_; NetworkErrorLoggingDelegate* network_error_logging_delegate_;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "net/base/cache_type.h" #include "net/base/cache_type.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/network_delegate_impl.h" #include "net/base/network_delegate_impl.h"
#include "net/base/sdch_manager.h"
#include "net/cert/cert_verifier.h" #include "net/cert/cert_verifier.h"
#include "net/cert/ct_known_logs.h" #include "net/cert/ct_known_logs.h"
#include "net/cert/ct_log_verifier.h" #include "net/cert/ct_log_verifier.h"
...@@ -202,7 +201,6 @@ URLRequestContextBuilder::URLRequestContextBuilder() ...@@ -202,7 +201,6 @@ URLRequestContextBuilder::URLRequestContextBuilder()
#endif #endif
http_cache_enabled_(true), http_cache_enabled_(true),
throttling_enabled_(false), throttling_enabled_(false),
sdch_enabled_(false),
cookie_store_set_by_client_(false), cookie_store_set_by_client_(false),
transport_security_persister_readonly_(false), transport_security_persister_readonly_(false),
net_log_(nullptr), net_log_(nullptr),
...@@ -455,11 +453,6 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() { ...@@ -455,11 +453,6 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
storage->set_channel_id_service(std::move(channel_id_service)); storage->set_channel_id_service(std::move(channel_id_service));
} }
if (sdch_enabled_) {
storage->set_sdch_manager(
std::unique_ptr<net::SdchManager>(new SdchManager()));
}
storage->set_transport_security_state( storage->set_transport_security_state(
std::make_unique<TransportSecurityState>()); std::make_unique<TransportSecurityState>());
if (!transport_security_persister_path_.empty()) { if (!transport_security_persister_path_.empty()) {
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "net/base/network_delegate.h" #include "net/base/network_delegate.h"
#include "net/base/proxy_delegate.h" #include "net/base/proxy_delegate.h"
#include "net/base/sdch_manager.h"
#include "net/cert/cert_verifier.h" #include "net/cert/cert_verifier.h"
#include "net/cert/ct_policy_enforcer.h" #include "net/cert/ct_policy_enforcer.h"
#include "net/cert/ct_verifier.h" #include "net/cert/ct_verifier.h"
...@@ -151,12 +150,6 @@ void URLRequestContextStorage::set_http_user_agent_settings( ...@@ -151,12 +150,6 @@ void URLRequestContextStorage::set_http_user_agent_settings(
http_user_agent_settings_ = std::move(http_user_agent_settings); http_user_agent_settings_ = std::move(http_user_agent_settings);
} }
void URLRequestContextStorage::set_sdch_manager(
std::unique_ptr<SdchManager> sdch_manager) {
context_->set_sdch_manager(sdch_manager.get());
sdch_manager_ = std::move(sdch_manager);
}
#if BUILDFLAG(ENABLE_REPORTING) #if BUILDFLAG(ENABLE_REPORTING)
void URLRequestContextStorage::set_reporting_service( void URLRequestContextStorage::set_reporting_service(
std::unique_ptr<ReportingService> reporting_service) { std::unique_ptr<ReportingService> reporting_service) {
......
...@@ -32,7 +32,6 @@ class NetworkErrorLoggingDelegate; ...@@ -32,7 +32,6 @@ class NetworkErrorLoggingDelegate;
class ProxyDelegate; class ProxyDelegate;
class ProxyService; class ProxyService;
class ReportingService; class ReportingService;
class SdchManager;
class SSLConfigService; class SSLConfigService;
class TransportSecurityState; class TransportSecurityState;
class URLRequestContext; class URLRequestContext;
...@@ -81,7 +80,6 @@ class NET_EXPORT URLRequestContextStorage { ...@@ -81,7 +80,6 @@ class NET_EXPORT URLRequestContextStorage {
std::unique_ptr<URLRequestThrottlerManager> throttler_manager); std::unique_ptr<URLRequestThrottlerManager> throttler_manager);
void set_http_user_agent_settings( void set_http_user_agent_settings(
std::unique_ptr<HttpUserAgentSettings> http_user_agent_settings); std::unique_ptr<HttpUserAgentSettings> http_user_agent_settings);
void set_sdch_manager(std::unique_ptr<SdchManager> sdch_manager);
#if BUILDFLAG(ENABLE_REPORTING) #if BUILDFLAG(ENABLE_REPORTING)
void set_reporting_service( void set_reporting_service(
...@@ -128,7 +126,6 @@ class NET_EXPORT URLRequestContextStorage { ...@@ -128,7 +126,6 @@ class NET_EXPORT URLRequestContextStorage {
std::unique_ptr<HttpTransactionFactory> http_transaction_factory_; std::unique_ptr<HttpTransactionFactory> http_transaction_factory_;
std::unique_ptr<URLRequestJobFactory> job_factory_; std::unique_ptr<URLRequestJobFactory> job_factory_;
std::unique_ptr<URLRequestThrottlerManager> throttler_manager_; std::unique_ptr<URLRequestThrottlerManager> throttler_manager_;
std::unique_ptr<SdchManager> sdch_manager_;
#if BUILDFLAG(ENABLE_REPORTING) #if BUILDFLAG(ENABLE_REPORTING)
std::unique_ptr<ReportingService> reporting_service_; std::unique_ptr<ReportingService> reporting_service_;
#endif // BUILDFLAG(ENABLE_REPORTING) #endif // BUILDFLAG(ENABLE_REPORTING)
......
This diff is collapsed.
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/net_error_details.h" #include "net/base/net_error_details.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/base/sdch_manager.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "net/filter/sdch_policy_delegate.h" #include "net/filter/sdch_policy_delegate.h"
#include "net/http/http_request_info.h" #include "net/http/http_request_info.h"
...@@ -78,8 +77,6 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob { ...@@ -78,8 +77,6 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob {
typedef base::RefCountedData<bool> SharedBoolean; typedef base::RefCountedData<bool> SharedBoolean;
class SdchContext;
// Shadows URLRequestJob's version of this method so we can grab cookies. // Shadows URLRequestJob's version of this method so we can grab cookies.
void NotifyHeadersComplete(); void NotifyHeadersComplete();
...@@ -199,16 +196,6 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob { ...@@ -199,16 +196,6 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob {
// back-off. May be NULL. // back-off. May be NULL.
scoped_refptr<URLRequestThrottlerEntryInterface> throttling_entry_; scoped_refptr<URLRequestThrottlerEntryInterface> throttling_entry_;
// A handle to the SDCH dictionaries that were advertised in this request.
// May be null.
std::unique_ptr<SdchManager::DictionarySet> dictionaries_advertised_;
// For SDCH latency experiments, when we are able to do SDCH, we may enable
// either an SDCH latency test xor a pass through test. The following bools
// indicate what we decided on for this instance.
bool sdch_test_activated_; // Advertising a dictionary for sdch.
bool sdch_test_control_; // Not even accepting-content sdch.
// For recording of stats, we need to remember if this is cached content. // For recording of stats, we need to remember if this is cached content.
bool is_cached_content_; bool is_cached_content_;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "base/test/histogram_tester.h" #include "base/test/histogram_tester.h"
#include "net/base/auth.h" #include "net/base/auth.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/base/sdch_observer.h"
#include "net/cookies/cookie_store_test_helpers.h" #include "net/cookies/cookie_store_test_helpers.h"
#include "net/http/http_transaction_factory.h" #include "net/http/http_transaction_factory.h"
#include "net/http/http_transaction_test_util.h" #include "net/http/http_transaction_test_util.h"
...@@ -179,7 +178,7 @@ TEST_F(URLRequestHttpJobSetUpSourceTest, UnknownEncoding) { ...@@ -179,7 +178,7 @@ TEST_F(URLRequestHttpJobSetUpSourceTest, UnknownEncoding) {
EXPECT_EQ("Test Content", delegate_.data_received()); EXPECT_EQ("Test Content", delegate_.data_received());
} }
// Received a malformed SDCH encoded response when there is no SdchManager. // Received a SDCH encoded response when Sdch is not advertised.
TEST_F(URLRequestHttpJobSetUpSourceTest, SdchNotAdvertisedGotSdchResponse) { TEST_F(URLRequestHttpJobSetUpSourceTest, SdchNotAdvertisedGotSdchResponse) {
MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)};
MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n"
...@@ -223,37 +222,6 @@ class URLRequestHttpJobTest : public ::testing::Test { ...@@ -223,37 +222,6 @@ class URLRequestHttpJobTest : public ::testing::Test {
&delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS);
} }
bool TransactionAcceptsSdchEncoding() {
base::WeakPtr<MockNetworkTransaction> transaction(
network_layer_.last_transaction());
EXPECT_TRUE(transaction);
if (!transaction) return false;
const HttpRequestInfo* request_info = transaction->request();
EXPECT_TRUE(request_info);
if (!request_info) return false;
std::string encoding_headers;
bool get_success = request_info->extra_headers.GetHeader(
"Accept-Encoding", &encoding_headers);
EXPECT_TRUE(get_success);
if (!get_success) return false;
// This check isn't wrapped with EXPECT* macros because different
// results from this function may be expected in different tests.
for (const std::string& token :
base::SplitString(encoding_headers, ", ", base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY)) {
if (base::EqualsCaseInsensitiveASCII(token, "sdch"))
return true;
}
return false;
}
void EnableSdch() {
context_.SetSdchManager(std::make_unique<SdchManager>());
}
MockNetworkLayer network_layer_; MockNetworkLayer network_layer_;
// |test_job_interceptor_| is owned by |test_job_factory_|. // |test_job_interceptor_| is owned by |test_job_factory_|.
...@@ -912,26 +880,6 @@ TEST_F(URLRequestHttpJobTest, SetTransactionPriority) { ...@@ -912,26 +880,6 @@ TEST_F(URLRequestHttpJobTest, SetTransactionPriority) {
EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority());
} }
// Confirm we do advertise SDCH encoding in the case of a GET.
TEST_F(URLRequestHttpJobTest, SdchAdvertisementGet) {
EnableSdch();
req_->set_method("GET"); // Redundant with default.
test_job_interceptor_->set_main_intercept_job(
std::make_unique<TestURLRequestHttpJob>(req_.get()));
req_->Start();
EXPECT_TRUE(TransactionAcceptsSdchEncoding());
}
// Confirm we don't advertise SDCH encoding in the case of a POST.
TEST_F(URLRequestHttpJobTest, SdchAdvertisementPost) {
EnableSdch();
req_->set_method("POST");
test_job_interceptor_->set_main_intercept_job(
std::make_unique<TestURLRequestHttpJob>(req_.get()));
req_->Start();
EXPECT_FALSE(TransactionAcceptsSdchEncoding());
}
TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) { TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) {
// Setup HSTS state. // Setup HSTS state.
context_.transport_security_state()->AddHSTS( context_.transport_security_state()->AddHSTS(
...@@ -993,119 +941,6 @@ TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) { ...@@ -993,119 +941,6 @@ TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) {
} }
} }
class MockSdchObserver : public SdchObserver {
public:
MockSdchObserver() {}
MOCK_METHOD2(OnDictionaryAdded,
void(const GURL& request_url, const std::string& server_hash));
MOCK_METHOD1(OnDictionaryRemoved, void(const std::string& server_hash));
MOCK_METHOD1(OnDictionaryUsed, void(const std::string& server_hash));
MOCK_METHOD2(OnGetDictionary,
void(const GURL& request_url, const GURL& dictionary_url));
MOCK_METHOD0(OnClearDictionaries, void());
};
class URLRequestHttpJobWithSdchSupportTest : public ::testing::Test {
protected:
URLRequestHttpJobWithSdchSupportTest() : context_(true) {
auto params = std::make_unique<HttpNetworkSession::Params>();
context_.set_http_network_session_params(std::move(params));
context_.set_client_socket_factory(&socket_factory_);
context_.Init();
}
MockClientSocketFactory socket_factory_;
TestURLRequestContext context_;
};
// Received a malformed SDCH encoded response that has no valid dictionary id.
TEST_F(URLRequestHttpJobWithSdchSupportTest,
SdchAdvertisedGotMalformedSdchResponse) {
MockWrite writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
"Host: www.example.com\r\n"
"Connection: keep-alive\r\n"
"User-Agent:\r\n"
"Accept-Encoding: gzip, deflate, sdch\r\n"
"Accept-Language: en-us,fr\r\n\r\n")};
MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n"
"Content-Encoding: sdch\r\n"
"Content-Length: 12\r\n\r\n"),
MockRead("Test Content")};
StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
arraysize(writes));
socket_factory_.AddSocketDataProvider(&socket_data);
MockSdchObserver sdch_observer;
SdchManager sdch_manager;
sdch_manager.AddObserver(&sdch_observer);
context_.set_sdch_manager(&sdch_manager);
TestDelegate delegate;
std::unique_ptr<URLRequest> request =
context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY,
&delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
request->Start();
base::RunLoop().Run();
// SdchPolicyDelegate::OnDictionaryIdError() detects that the response is
// malformed (missing dictionary), and will issue a pass-through of the raw
// response.
EXPECT_EQ(OK, delegate.request_status());
EXPECT_EQ("Test Content", delegate.data_received());
// Cleanup manager.
sdch_manager.RemoveObserver(&sdch_observer);
}
TEST_F(URLRequestHttpJobWithSdchSupportTest, GetDictionary) {
MockWrite writes[] = {
MockWrite("GET / HTTP/1.1\r\n"
"Host: example.com\r\n"
"Connection: keep-alive\r\n"
"User-Agent:\r\n"
"Accept-Encoding: gzip, deflate, sdch\r\n"
"Accept-Language: en-us,fr\r\n\r\n")};
MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n"
"Get-Dictionary: /sdch.dict\r\n"
"Cache-Control: max-age=120\r\n"
"Content-Length: 12\r\n\r\n"),
MockRead("Test Content")};
StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
arraysize(writes));
socket_factory_.AddSocketDataProvider(&socket_data);
MockSdchObserver sdch_observer;
SdchManager sdch_manager;
sdch_manager.AddObserver(&sdch_observer);
context_.set_sdch_manager(&sdch_manager);
// First response will be "from network" and we should have OnGetDictionary
// invoked.
GURL url("http://example.com");
EXPECT_CALL(sdch_observer,
OnGetDictionary(url, GURL("http://example.com/sdch.dict")));
TestDelegate delegate;
std::unique_ptr<URLRequest> request = context_.CreateRequest(
url, DEFAULT_PRIORITY, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
request->Start();
base::RunLoop().RunUntilIdle();
EXPECT_THAT(delegate.request_status(), IsOk());
// Second response should be from cache without notification of SdchObserver
TestDelegate delegate2;
std::unique_ptr<URLRequest> request2 = context_.CreateRequest(
url, DEFAULT_PRIORITY, &delegate2, TRAFFIC_ANNOTATION_FOR_TESTS);
request2->Start();
base::RunLoop().RunUntilIdle();
EXPECT_THAT(delegate2.request_status(), IsOk());
// Cleanup manager.
sdch_manager.RemoveObserver(&sdch_observer);
}
class URLRequestHttpJobWithBrotliSupportTest : public ::testing::Test { class URLRequestHttpJobWithBrotliSupportTest : public ::testing::Test {
protected: protected:
URLRequestHttpJobWithBrotliSupportTest() URLRequestHttpJobWithBrotliSupportTest()
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/base/network_delegate_impl.h" #include "net/base/network_delegate_impl.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/base/sdch_manager.h"
#include "net/cert/cert_verifier.h" #include "net/cert/cert_verifier.h"
#include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_monster.h"
#include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache.h"
...@@ -86,10 +85,6 @@ class TestURLRequestContext : public URLRequestContext { ...@@ -86,10 +85,6 @@ class TestURLRequestContext : public URLRequestContext {
http_network_session_context_ = std::move(session_context); http_network_session_context_ = std::move(session_context);
} }
void SetSdchManager(std::unique_ptr<SdchManager> sdch_manager) {
context_storage_.set_sdch_manager(std::move(sdch_manager));
}
void SetCTPolicyEnforcer( void SetCTPolicyEnforcer(
std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer) { std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer) {
context_storage_.set_ct_policy_enforcer(std::move(ct_policy_enforcer)); context_storage_.set_ct_policy_enforcer(std::move(ct_policy_enforcer));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment