summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 21:37:04 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 21:37:04 +0000
commit7234e6cc82609038c3dbb5bd175e73d7ea93fd76 (patch)
treef9ec71ceb5f9a26d33799df74db6fb0988a20d42 /net
parent568a0bebd0c3c296e473b2e434c679634e7c68bf (diff)
downloadchromium_src-7234e6cc82609038c3dbb5bd175e73d7ea93fd76.zip
chromium_src-7234e6cc82609038c3dbb5bd175e73d7ea93fd76.tar.gz
chromium_src-7234e6cc82609038c3dbb5bd175e73d7ea93fd76.tar.bz2
Fetch SDCH dictionary as soon as current URL fetch completes
Rather than just waiting for 15 seconds, this patch fetches the "suggested dicitionary" as soon as the current download completes. This avoids stealing bandwidth from the original download, but works as quickly as possible to get the dictionary, so that the user can receive compression results asap. r=wtc Review URL: http://codereview.chromium.org/20254 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9597 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/sdch_manager.cc10
-rw-r--r--net/base/sdch_manager.h8
-rw-r--r--net/url_request/url_request_http_job.cc8
-rw-r--r--net/url_request/url_request_http_job.h4
4 files changed, 20 insertions, 10 deletions
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index be8ae13..9097f88 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -172,10 +172,7 @@ bool SdchManager::CanFetchDictionary(const GURL& referring_url,
return true;
}
-void SdchManager::FetchDictionary(const GURL& referring_url,
- const GURL& dictionary_url) {
- if (!CanFetchDictionary(referring_url, dictionary_url))
- return;
+void SdchManager::FetchDictionary(const GURL& dictionary_url) {
if (fetcher_.get())
fetcher_->Schedule(dictionary_url);
}
@@ -379,6 +376,11 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain,
5. If the dictionary has a Port attribute and the referer URL's port was not
in the list.
*/
+
+ // TODO(jar): Redirects in dictionary fetches might plausibly be problematic,
+ // and hence the conservative approach is to not allow any redirects (if there
+ // were any... then don't allow the dictionary to be set).
+
if (domain.empty()) {
SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER);
return false; // Domain is required.
diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h
index 0f7cdeb..2a4e5b5 100644
--- a/net/base/sdch_manager.h
+++ b/net/base/sdch_manager.h
@@ -243,13 +243,13 @@ class SdchManager {
// by 1 the number of times it will be reported as blacklisted.
const bool IsInSupportedDomain(const GURL& url);
- // Schedule the URL fetching to load a dictionary. This will generally return
- // long before the dictionary is actually loaded and added.
+ // Schedule the URL fetching to load a dictionary. This will always return
+ // before the dictionary is actually loaded and added.
// After the implied task does completes, the dictionary will have been
// cached in memory.
- void FetchDictionary(const GURL& referring_url, const GURL& dictionary_url);
+ void FetchDictionary(const GURL& dictionary_url);
- // Security test function used before initiating a fetch.
+ // Security test function used before initiating a FetchDictionary.
// Return true if fetch is legal.
bool CanFetchDictionary(const GURL& referring_url,
const GURL& dictionary_url) const;
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index d29b31e..c7fc435 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -64,6 +64,9 @@ URLRequestHttpJob::URLRequestHttpJob(URLRequest* request)
}
URLRequestHttpJob::~URLRequestHttpJob() {
+ if (sdch_dictionary_url_.is_valid()) {
+ SdchManager::Global()->FetchDictionary(sdch_dictionary_url_);
+ }
}
void URLRequestHttpJob::SetUpload(net::UploadData* upload) {
@@ -445,7 +448,6 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
}
}
- // Get list of SDCH dictionary requests, and schedule them to be loaded.
if (SdchManager::Global() &&
SdchManager::Global()->IsInSupportedDomain(request_->url())) {
static const std::string name = "Get-Dictionary";
@@ -459,7 +461,9 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
// before we even download it (so that we don't waste memory or bandwidth).
if (response_info_->headers->EnumerateHeader(&iter, name, &url_text)) {
GURL dictionary_url = request_->url().Resolve(url_text);
- SdchManager::Global()->FetchDictionary(request_->url(), dictionary_url);
+ if (SdchManager::Global()->CanFetchDictionary(request_->url(),
+ dictionary_url))
+ sdch_dictionary_url_ = dictionary_url;
}
}
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index e53db48..a77d462 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/scoped_ptr.h"
#include "net/base/completion_callback.h"
#include "net/http/http_request_info.h"
#include "net/url_request/url_request_job.h"
@@ -80,6 +81,9 @@ class 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_;
+
// Keep a reference to the url request context to be sure it's not deleted
// before us.
scoped_refptr<URLRequestContext> context_;