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

Unified Diff: net/url_request/url_request_simple_job.cc

Issue 725443003: Avoid a string copy in URLRequestResourceBundleJob::GetData(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Fix streaming_utf8_validator_perftest.cc for IsStringUTF8(StringPiece). Created 6 years, 1 month 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_simple_job.cc
diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc
index b855932d577824997d390d3c32dd0661415f6737..3acc220f2242350d5db92e2ce38bd3fb9caec6fc 100644
--- a/net/url_request/url_request_simple_job.cc
+++ b/net/url_request/url_request_simple_job.cc
@@ -56,6 +56,24 @@ bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size,
return true;
}
+int URLRequestSimpleJob::GetData(std::string* mime_type,
+ std::string* charset,
+ std::string* data,
+ const CompletionCallback& callback) const {
+ NOTREACHED();
+ return ERR_UNEXPECTED;
+}
+
+int URLRequestSimpleJob::GetStringPieceData(
+ std::string* mime_type,
+ std::string* charset,
+ base::StringPiece* data,
+ const CompletionCallback& callback) {
+ int result = GetData(mime_type, charset, &data_storage_, callback);
+ *data = data_storage_;
+ return result;
+}
+
void URLRequestSimpleJob::StartAsync() {
if (!request_)
return;
@@ -82,11 +100,10 @@ void URLRequestSimpleJob::StartAsync() {
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"422489 URLRequestSimpleJob::StartAsync 2"));
- result = GetData(&mime_type_,
- &charset_,
- &data_,
- base::Bind(&URLRequestSimpleJob::OnGetDataCompleted,
- weak_factory_.GetWeakPtr()));
+ result =
+ GetStringPieceData(&mime_type_, &charset_, &data_,
+ base::Bind(&URLRequestSimpleJob::OnGetDataCompleted,
+ weak_factory_.GetWeakPtr()));
}
if (result != ERR_IO_PENDING) {
« net/url_request/url_request_simple_job.h ('K') | « net/url_request/url_request_simple_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698