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

Unified Diff: examples/geturl/geturl_handler.h

Issue 8603014: Add some suggested performance improvements to geturl. (Closed) Base URL: http://nativeclient-sdk.googlecode.com/svn/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « no previous file | examples/geturl/geturl_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/geturl/geturl_handler.h
===================================================================
--- examples/geturl/geturl_handler.h (revision 1387)
+++ examples/geturl/geturl_handler.h (working copy)
@@ -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 @@
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_;
« no previous file with comments | « no previous file | examples/geturl/geturl_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698