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

Unified Diff: net/url_request/url_request_simple_job.h

Issue 725443003: Avoid a string copy in URLRequestResourceBundleJob::GetData(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Switch to RefCountedMemory. 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.h
diff --git a/net/url_request/url_request_simple_job.h b/net/url_request/url_request_simple_job.h
index 85d8f7e39edfa29edbdf26e7be96cccb11e157cc..07715b79b4ae4452b4e2f2a84bedb374d7426d98 100644
--- a/net/url_request/url_request_simple_job.h
+++ b/net/url_request/url_request_simple_job.h
@@ -7,11 +7,17 @@
#include <string>
+#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/strings/string_piece.h"
#include "net/base/completion_callback.h"
#include "net/base/net_export.h"
#include "net/url_request/url_range_request_job.h"
+namespace base {
+class RefCountedMemory;
+}
+
namespace net {
class URLRequest;
@@ -41,7 +47,13 @@ class NET_EXPORT URLRequestSimpleJob : public URLRangeRequestJob {
virtual int GetData(std::string* mime_type,
std::string* charset,
std::string* data,
- const CompletionCallback& callback) const = 0;
+ const CompletionCallback& callback) const;
+ // Similar to GetData(), except *data can share ownership of the bytes instead
mmenke 2014/11/17 15:54:10 nit: |*data| or *|data|.
Jeffrey Yasskin 2014/11/17 17:16:23 Done.
+ // of copying them into a std::string.
+ virtual int GetRefCountedData(std::string* mime_type,
+ std::string* charset,
+ scoped_refptr<base::RefCountedMemory>* data,
+ const CompletionCallback& callback) const;
protected:
void StartAsync();
@@ -52,7 +64,7 @@ class NET_EXPORT URLRequestSimpleJob : public URLRangeRequestJob {
HttpByteRange byte_range_;
std::string mime_type_;
std::string charset_;
- std::string data_;
+ scoped_refptr<base::RefCountedMemory> data_;
int data_offset_;
base::WeakPtrFactory<URLRequestSimpleJob> weak_factory_;
};

Powered by Google App Engine
This is Rietveld 408576698