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

Unified Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 2690333003: service worker: Optimize response header creation. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_url_request_job_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_url_request_job.cc
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index d794db26b767e799f4ebcd2b165027076dd99575..0a5226672db3eb5d791384ad16611d29765e2d8e 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -679,20 +679,17 @@ void ServiceWorkerURLRequestJob::CreateResponseHeader(
const ServiceWorkerHeaderMap& headers) {
// TODO(kinuko): If the response has an identifier to on-disk cache entry,
// pull response header from the disk.
- std::string status_line(
- base::StringPrintf("HTTP/1.1 %d %s", status_code, status_text.c_str()));
- status_line.push_back('\0');
- http_response_headers_ = new net::HttpResponseHeaders(status_line);
- for (ServiceWorkerHeaderMap::const_iterator it = headers.begin();
- it != headers.end();
- ++it) {
- std::string header;
- header.reserve(it->first.size() + 2 + it->second.size());
- header.append(it->first);
- header.append(": ");
- header.append(it->second);
- http_response_headers_->AddHeader(header);
+ std::string buf(base::StringPrintf("HTTP/1.1 %d %s\r\n", status_code,
+ status_text.c_str()));
+ for (auto it = headers.begin(); it != headers.end(); ++it) {
xunjieli 2017/02/14 17:09:58 nit: for (const auto& item : headers) {
falken 2017/02/15 00:39:39 Done.
+ buf.append(it->first);
+ buf.append(": ");
+ buf.append(it->second);
+ buf.append("\r\n");
}
+ buf.append("\r\n");
+ http_response_headers_ = new net::HttpResponseHeaders(
+ net::HttpUtil::AssembleRawHeaders(buf.c_str(), buf.size()));
}
void ServiceWorkerURLRequestJob::CommitResponseHeader() {
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698