summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-14 07:19:43 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-14 07:19:43 +0000
commit13e4f3427f8b0f458cfedd9512785d8e44e5b16c (patch)
treeeca2dd78e5129a9054e19fbdb9c4a1eef94df50e /net/url_request
parentb63c88b97706f02247e25d0db00fca79c810e8ac (diff)
downloadchromium_src-13e4f3427f8b0f458cfedd9512785d8e44e5b16c.zip
chromium_src-13e4f3427f8b0f458cfedd9512785d8e44e5b16c.tar.gz
chromium_src-13e4f3427f8b0f458cfedd9512785d8e44e5b16c.tar.bz2
Revert 277160 "Make SdchManager per-profile."
On LSan, SdchManagerTest.CanUseMultipleDictionaries fails (leaks): http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/3073/steps/net_unittests/logs/stdio E.g.: Indirect leak of 34 byte(s) in 1 object(s) allocated from: #0 0x512b7b in operator new(unsigned long) /usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:55 #1 0x7f4730122739 in __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:92 #2 0x7f4730121d2c in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:609 #3 0x7f4730121f04 in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:631 #4 0x7f473011ec48 in std::string::reserve(unsigned long) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:512 #5 0x7f473011f391 in std::string::append(unsigned long, char) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:290 #6 0x7f473011eaeb in std::string::resize(unsigned long, char) /build/buildd/gcc-4.6-4.6.3/build/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:647 #7 0x31d6642 in resize /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/basic_string.h:749 #8 0x31d6642 in base::Base64Encode(base::BasicStringPiece<std::string> const&, std::string*) base/base64.cc:13 #9 0x34a1d05 in net::SdchManager::UrlSafeBase64Encode(std::string const&, std::string*) net/base/sdch_manager.cc:541 #10 0x34a1124 in net::SdchManager::GenerateHash(std::string const&, std::string*, std::string*) net/base/sdch_manager.cc:508 #11 0x349facb in net::SdchManager::AddSdchDictionary(std::string const&, GURL const&) net/base/sdch_manager.cc:363 #12 0x803e06 in net::SdchManagerTest_CanUseMultipleDictionaries_Test::TestBody() net/base/sdch_manager_unittest.cc:403 [...] > Make SdchManager per-profile. > > This will both allow SDCH dictionaries to be cached (as they can use the > cache associated with the profile) and will provide privacy protection > between different profiles (the existing of a dictionary in one profile > will not be leaked to another profile). > > BUG=374914 > R=jar@chromium.org > > Review URL: https://codereview.chromium.org/298063006 TBR=rdsmith@chromium.org Review URL: https://codereview.chromium.org/331023002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_request_context.cc2
-rw-r--r--net/url_request/url_request_context.h10
-rw-r--r--net/url_request/url_request_http_job.cc44
-rw-r--r--net/url_request/url_request_http_job.h3
4 files changed, 28 insertions, 31 deletions
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index 3a9f69d..d6a4d2f 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -31,7 +31,6 @@ URLRequestContext::URLRequestContext()
http_transaction_factory_(NULL),
job_factory_(NULL),
throttler_manager_(NULL),
- sdch_manager_(NULL),
url_requests_(new std::set<const URLRequest*>) {
}
@@ -57,7 +56,6 @@ void URLRequestContext::CopyFrom(const URLRequestContext* other) {
set_http_transaction_factory(other->http_transaction_factory_);
set_job_factory(other->job_factory_);
set_throttler_manager(other->throttler_manager_);
- set_sdch_manager(other->sdch_manager_);
set_http_user_agent_settings(other->http_user_agent_settings_);
}
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 4242d72..a05c9ae 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -36,7 +36,6 @@ class HttpAuthHandlerFactory;
class HttpTransactionFactory;
class HttpUserAgentSettings;
class NetworkDelegate;
-class SdchManager;
class ServerBoundCertService;
class ProxyService;
class URLRequest;
@@ -185,14 +184,6 @@ class NET_EXPORT URLRequestContext
throttler_manager_ = throttler_manager;
}
- // May be NULL.
- SdchManager* sdch_manager() const {
- return sdch_manager_;
- }
- void set_sdch_manager(SdchManager* sdch_manager) {
- sdch_manager_ = sdch_manager;
- }
-
// Gets the URLRequest objects that hold a reference to this
// URLRequestContext.
std::set<const URLRequest*>* url_requests() const {
@@ -236,7 +227,6 @@ class NET_EXPORT URLRequestContext
HttpTransactionFactory* http_transaction_factory_;
const URLRequestJobFactory* job_factory_;
URLRequestThrottlerManager* throttler_manager_;
- SdchManager* sdch_manager_;
// ---------------------------------------------------------------------------
// Important: When adding any new members below, consider whether they need to
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 4b7d4e0..776c5b1 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -66,7 +66,6 @@ class URLRequestHttpJob::HttpFilterContext : public FilterContext {
virtual bool IsSdchResponse() const OVERRIDE;
virtual int64 GetByteReadCount() const OVERRIDE;
virtual int GetResponseCode() const OVERRIDE;
- virtual const URLRequestContext* GetURLRequestContext() const OVERRIDE;
virtual void RecordPacketStats(StatisticSelector statistic) const OVERRIDE;
// Method to allow us to reset filter context for a response that should have
@@ -135,11 +134,6 @@ int URLRequestHttpJob::HttpFilterContext::GetResponseCode() const {
return job_->GetResponseCode();
}
-const URLRequestContext*
-URLRequestHttpJob::HttpFilterContext::GetURLRequestContext() const {
- return job_->request() ? job_->request()->context() : NULL;
-}
-
void URLRequestHttpJob::HttpFilterContext::RecordPacketStats(
StatisticSelector statistic) const {
job_->RecordPacketStats(statistic);
@@ -226,6 +220,20 @@ URLRequestHttpJob::~URLRequestHttpJob() {
// filter_context_ is still alive.
DestroyFilters();
+ if (sdch_dictionary_url_.is_valid()) {
+ // Prior to reaching the destructor, request_ has been set to a NULL
+ // pointer, so request_->url() is no longer valid in the destructor, and we
+ // use an alternate copy |request_info_.url|.
+ SdchManager* manager = SdchManager::Global();
+ // To be extra safe, since this is a "different time" from when we decided
+ // to get the dictionary, we'll validate that an SdchManager is available.
+ // At shutdown time, care is taken to be sure that we don't delete this
+ // globally useful instance "too soon," so this check is just defensive
+ // coding to assure that IF the system is shutting down, we don't have any
+ // problem if the manager was deleted ahead of time.
+ if (manager) // Defensive programming.
+ manager->FetchDictionary(request_info_.url, sdch_dictionary_url_);
+ }
DoneWithRequest(ABORTED);
}
@@ -305,8 +313,8 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
ProcessStrictTransportSecurityHeader();
ProcessPublicKeyPinsHeader();
- SdchManager* sdch_manager(request()->context()->sdch_manager());
- if (sdch_manager && sdch_manager->IsInSupportedDomain(request_->url())) {
+ if (SdchManager::Global() &&
+ SdchManager::Global()->IsInSupportedDomain(request_->url())) {
const std::string name = "Get-Dictionary";
std::string url_text;
void* iter = NULL;
@@ -317,11 +325,11 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
// Eventually we should wait until a dictionary is requested several times
// before we even download it (so that we don't waste memory or bandwidth).
if (GetResponseHeaders()->EnumerateHeader(&iter, name, &url_text)) {
+ // request_->url() won't be valid in the destructor, so we use an
+ // alternate copy.
+ DCHECK_EQ(request_->url(), request_info_.url);
// Resolve suggested URL relative to request url.
- GURL sdch_dictionary_url = request_->url().Resolve(url_text);
- if (sdch_dictionary_url.is_valid()) {
- sdch_manager->FetchDictionary(request_->url(), sdch_dictionary_url);
- }
+ sdch_dictionary_url_ = request_info_.url.Resolve(url_text);
}
}
@@ -455,8 +463,6 @@ void URLRequestHttpJob::StartTransactionInternal() {
}
void URLRequestHttpJob::AddExtraHeaders() {
- SdchManager* sdch_manager = request()->context()->sdch_manager();
-
// Supply Accept-Encoding field only if it is not already provided.
// It should be provided IF the content is known to have restrictions on
// potential encoding, such as streaming multi-media.
@@ -466,24 +472,24 @@ void URLRequestHttpJob::AddExtraHeaders() {
// simple_data_source.
if (!request_info_.extra_headers.HasHeader(
HttpRequestHeaders::kAcceptEncoding)) {
- bool advertise_sdch = sdch_manager &&
+ bool advertise_sdch = SdchManager::Global() &&
// We don't support SDCH responses to POST as there is a possibility
// of having SDCH encoded responses returned (e.g. by the cache)
// which we cannot decode, and in those situations, we will need
// to retransmit the request without SDCH, which is illegal for a POST.
request()->method() != "POST" &&
- sdch_manager->IsInSupportedDomain(request_->url());
+ SdchManager::Global()->IsInSupportedDomain(request_->url());
std::string avail_dictionaries;
if (advertise_sdch) {
- sdch_manager->GetAvailDictionaryList(request_->url(),
- &avail_dictionaries);
+ SdchManager::Global()->GetAvailDictionaryList(request_->url(),
+ &avail_dictionaries);
// The AllowLatencyExperiment() is only true if we've successfully done a
// full SDCH compression recently in this browser session for this host.
// Note that for this path, there might be no applicable dictionaries,
// and hence we can't participate in the experiment.
if (!avail_dictionaries.empty() &&
- sdch_manager->AllowLatencyExperiment(request_->url())) {
+ SdchManager::Global()->AllowLatencyExperiment(request_->url())) {
// We are participating in the test (or control), and hence we'll
// eventually record statistics via either SDCH_EXPERIMENT_DECODE or
// SDCH_EXPERIMENT_HOLDBACK, and we'll need some packet timing data.
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index d38b462..b7ac50c 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -190,6 +190,9 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob {
bool read_in_progress_;
+ // An URL for an SDCH dictionary as suggested in a Get-Dictionary HTTP header.
+ GURL sdch_dictionary_url_;
+
scoped_ptr<HttpTransaction> transaction_;
// This is used to supervise traffic and enforce exponential