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

Unified Diff: content/browser/webui/url_data_manager_backend.cc

Issue 2149323003: Change the way that gzipped resources are loaded from resources.pak (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename Created 4 years, 4 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
« no previous file with comments | « content/browser/webrtc/webrtc_internals_ui.cc ('k') | content/browser/webui/web_ui_data_source_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webui/url_data_manager_backend.cc
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc
index 404e834ca0d7542a3723e37baa9e0370a4958f98..4274eeb8fadc0a0684c9b980a23f337ab2655e55 100644
--- a/content/browser/webui/url_data_manager_backend.cc
+++ b/content/browser/webui/url_data_manager_backend.cc
@@ -38,6 +38,7 @@
#include "content/public/common/url_constants.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/filter/filter.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/log/net_log_util.h"
@@ -125,6 +126,7 @@ class URLRequestChromeJob : public net::URLRequestJob {
bool GetMimeType(std::string* mime_type) const override;
int GetResponseCode() const override;
void GetResponseInfo(net::HttpResponseInfo* info) override;
+ std::unique_ptr<net::Filter> SetupFilter() const override;
// Used to notify that the requested data's |mime_type| is ready.
void MimeTypeAvailable(const std::string& mime_type);
@@ -185,6 +187,10 @@ class URLRequestChromeJob : public net::URLRequestJob {
access_control_allow_origin_ = value;
}
+ void set_is_gzipped(bool is_gzipped) {
+ is_gzipped_ = is_gzipped;
+ }
+
// Returns true when job was generated from an incognito profile.
bool is_incognito() const {
return is_incognito_;
@@ -247,6 +253,10 @@ class URLRequestChromeJob : public net::URLRequestJob {
// True when job is generated from an incognito profile.
const bool is_incognito_;
+ // True when gzip encoding should be used. NOTE: this requires the original
+ // resources in resources.pak use compress="gzip".
+ bool is_gzipped_;
+
// The backend is owned by net::URLRequestContext and always outlives us.
URLDataManagerBackend* backend_;
@@ -355,6 +365,13 @@ void URLRequestChromeJob::GetResponseInfo(net::HttpResponseInfo* info) {
access_control_allow_origin_);
info->headers->AddHeader("Vary: Origin");
}
+
+ if (is_gzipped_)
+ info->headers->AddHeader("Content-Encoding: gzip");
+}
+
+std::unique_ptr<net::Filter> URLRequestChromeJob::SetupFilter() const {
+ return is_gzipped_ ? net::Filter::GZipFactory() : nullptr;
}
void URLRequestChromeJob::MimeTypeAvailable(const std::string& mime_type) {
@@ -635,6 +652,7 @@ bool URLDataManagerBackend::StartRequest(const net::URLRequest* request,
source->source()->ShouldDenyXFrameOptions());
job->set_send_content_type_header(
source->source()->ShouldServeMimeTypeAsContentTypeHeader());
+ job->set_is_gzipped(source->source()->IsGzipped(path));
std::string origin = GetOriginHeaderValue(request);
if (!origin.empty()) {
« no previous file with comments | « content/browser/webrtc/webrtc_internals_ui.cc ('k') | content/browser/webui/web_ui_data_source_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698