| 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_;
|
|
|
|
|