Index: native_client_sdk/src/examples/geturl/geturl_handler.h |
diff --git a/native_client_sdk/src/examples/geturl/geturl_handler.h b/native_client_sdk/src/examples/geturl/geturl_handler.h |
index 928f22c76c1d589faef428a9b4eac3fefc1955db..0214c392cb270a1d7ed354d4a48362c3252a4341 100644 |
--- a/native_client_sdk/src/examples/geturl/geturl_handler.h |
+++ b/native_client_sdk/src/examples/geturl/geturl_handler.h |
@@ -11,12 +11,20 @@ |
#include "ppapi/cpp/url_request_info.h" |
#include "ppapi/cpp/instance.h" |
-#define READ_BUFFER_SIZE 4096 |
+#define READ_BUFFER_SIZE 32768 |
// GetURLHandler is used to download data from |url|. When download is |
// finished or when an error occurs, it posts a message back to the browser |
// with the results encoded in the message as a string and self-destroys. |
// |
+// pp::URLLoader.GetDownloadProgress() is used to to allocate the memory |
+// required for url_response_body_ before the download starts. (This is not so |
+// much of a performance improvement, but it saves some memory since |
+// std::string.insert() typically grows the string's capacity by somewhere |
+// between 50% to 100% when it needs more memory, depending on the |
+// implementation.) Other performance improvements made as outlined in this |
+// bug: http://code.google.com/p/chromium/issues/detail?id=103947 |
+// |
// EXAMPLE USAGE: |
// GetURLHandler* handler* = GetURLHandler::Create(instance,url); |
// handler->Start(); |
@@ -69,7 +77,7 @@ class GetURLHandler { |
std::string url_; // URL to be downloaded. |
pp::URLRequestInfo url_request_; |
pp::URLLoader url_loader_; // URLLoader provides an API to download URLs. |
- char buffer_[READ_BUFFER_SIZE]; // Temporary buffer for reads. |
+ char* buffer_; // Temporary buffer for reads. |
std::string url_response_body_; // Contains accumulated downloaded data. |
pp::CompletionCallbackFactory<GetURLHandler> cc_factory_; |