Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: net/url_request/url_request_job.cc

Issue 40138: Use FilterContext to allow filters to access URLRequestJob data... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_job.cc
===================================================================
--- net/url_request/url_request_job.cc (revision 11030)
+++ net/url_request/url_request_job.cc (working copy)
@@ -18,7 +18,8 @@
using base::TimeTicks;
// Buffer size allocated when de-compressing data.
-static const int kFilterBufSize = 32 * 1024;
+// static
+const int URLRequestJob::kFilterBufSize = 32 * 1024;
URLRequestJob::URLRequestJob(URLRequest* request)
: request_(request),
@@ -54,18 +55,7 @@
void URLRequestJob::SetupFilter() {
std::vector<Filter::FilterType> encoding_types;
if (GetContentEncodings(&encoding_types)) {
- filter_.reset(Filter::Factory(encoding_types, kFilterBufSize));
- if (filter_.get()) {
- std::string mime_type;
- GetMimeType(&mime_type);
- filter_->SetURL(request_->url());
- filter_->SetMimeType(mime_type);
- // Approximate connect time with request_time. If it is not cached, then
- // this is a good approximation for when the first bytes went on the
- // wire.
- filter_->SetConnectTime(request_->response_info_.request_time,
- request_->response_info_.was_cached);
- }
+ filter_.reset(Filter::Factory(encoding_types, *this));
}
}
@@ -96,6 +86,25 @@
NOTREACHED();
}
+bool URLRequestJob::GetURL(GURL* gurl) const {
+ if (!request_)
+ return false;
+ *gurl = request_->url();
+ return true;
+}
+
+base::Time URLRequestJob::GetRequestTime() const {
+ if (!request_)
+ return base::Time();
+ return request_->request_time();
+};
+
+bool URLRequestJob::IsCachedContent() const {
+ if (!request_)
+ return false;
+ return request_->was_cached();
+};
+
// This function calls ReadData to get stream data. If a filter exists, passes
// the data to the attached filter. Then returns the output from filter back to
// the caller.

Powered by Google App Engine
This is Rietveld 408576698