summaryrefslogtreecommitdiffstats
path: root/chrome/common/net
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 16:58:06 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-09 16:58:06 +0000
commit2e4633c5b2a040357659646b951b632bff3055f5 (patch)
treef4a4ab7e636963a940118157cbec5dd4cc7b4ad4 /chrome/common/net
parentdba526fa150d26deae1a10f54bc3b72ed36e5520 (diff)
downloadchromium_src-2e4633c5b2a040357659646b951b632bff3055f5.zip
chromium_src-2e4633c5b2a040357659646b951b632bff3055f5.tar.gz
chromium_src-2e4633c5b2a040357659646b951b632bff3055f5.tar.bz2
A prototype of resource loading through automation
In a test scenario where we need to load resources over automation, we intercept the URL reqeusts and serve them using automation IPCs. This resource loading can be enabled per tab created by automation. BUG=none TEST=none Review URL: http://codereview.chromium.org/145024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net')
-rw-r--r--chrome/common/net/url_request_intercept_job.cc23
-rw-r--r--chrome/common/net/url_request_intercept_job.h8
2 files changed, 25 insertions, 6 deletions
diff --git a/chrome/common/net/url_request_intercept_job.cc b/chrome/common/net/url_request_intercept_job.cc
index bb5dd8c..af1c8c7 100644
--- a/chrome/common/net/url_request_intercept_job.cc
+++ b/chrome/common/net/url_request_intercept_job.cc
@@ -101,10 +101,25 @@ bool URLRequestInterceptJob::GetCharset(std::string* charset) {
return request_->response_headers()->GetCharset(charset);
}
-bool URLRequestInterceptJob::GetContentEncoding(std::string* encoding_type) {
- // TODO(darin): what if there are multiple content encodings?
- return request_->response_headers()->EnumerateHeader(NULL, "Content-Encoding",
- encoding_type);
+bool URLRequestInterceptJob::GetContentEncodings(
+ std::vector<Filter::FilterType>* encoding_types) {
+ DCHECK(encoding_types->empty());
+ if (!request_->response_headers())
+ return false;
+
+ std::string encoding_type;
+ void* iter = NULL;
+ while (request_->response_headers()->EnumerateHeader(
+ &iter, "Content-Encoding", &encoding_type)) {
+ encoding_types->push_back(Filter::ConvertEncodingToType(encoding_type));
+ }
+
+ // Even if encoding types are empty, there is a chance that we need to add
+ // some decoding, as some proxies strip encoding completely. In such cases,
+ // we may need to add (for example) SDCH filtering (when the context suggests
+ // it is appropriate).
+ Filter::FixupEncodingTypes(*this, encoding_types);
+ return !encoding_types->empty();
}
void URLRequestInterceptJob::GetResponseInfo(net::HttpResponseInfo* info) {
diff --git a/chrome/common/net/url_request_intercept_job.h b/chrome/common/net/url_request_intercept_job.h
index 73f354d..07db154 100644
--- a/chrome/common/net/url_request_intercept_job.h
+++ b/chrome/common/net/url_request_intercept_job.h
@@ -35,18 +35,22 @@ class URLRequestInterceptJob
// URLRequestJob
virtual void Start();
virtual void Kill();
- virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read);
virtual bool GetMimeType(std::string* mime_type) const;
virtual bool GetCharset(std::string* charset);
virtual void GetResponseInfo(net::HttpResponseInfo* info);
virtual int GetResponseCode() const;
- virtual bool GetContentEncoding(std::string* encoding_type);
+ virtual bool GetContentEncodings(
+ std::vector<Filter::FilterType>* encoding_types);
virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
// NotificationObserver
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
+
+ protected:
+ virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read);
+
private:
void StartAsync();
void DetachPlugin();