| Index: ppapi/cpp/url_loader.h
|
| ===================================================================
|
| --- ppapi/cpp/url_loader.h (revision 91867)
|
| +++ ppapi/cpp/url_loader.h (working copy)
|
| @@ -17,64 +17,7 @@
|
|
|
| // URLLoader provides an API to download URLs.
|
| //
|
| -// EXAMPLE USAGE:
|
| -//
|
| -// class MyHandler {
|
| -// public:
|
| -// MyHandler(Instance* instance)
|
| -// : factory_(this),
|
| -// loader_(instance),
|
| -// did_open_(false) {
|
| -// }
|
| -// void ProcessURL(const char* url) {
|
| -// CompletionCallback* cc = NewCallback();
|
| -// int32_t rv = loader_.Open(MakeRequest(url), cc);
|
| -// if (rv != PP_Error_WouldBlock)
|
| -// cc->Run(rv);
|
| -// }
|
| -// private:
|
| -// CompletionCallback* NewCallback() {
|
| -// return factory_.NewOptionalCallback(&MyHandler::DidCompleteIO);
|
| -// }
|
| -// URLRequestInfo MakeRequest(const char* url) {
|
| -// URLRequestInfo request;
|
| -// request.SetURL(url);
|
| -// request.SetMethod("GET");
|
| -// request.SetFollowRedirects(true);
|
| -// return request;
|
| -// }
|
| -// void DidCompleteIO(int32_t result) {
|
| -// if (result > 0) {
|
| -// // buf_ now contains 'result' number of bytes from the URL.
|
| -// ProcessBytes(buf_, result);
|
| -// ReadMore();
|
| -// } else if (result == PP_OK && !did_open_) {
|
| -// // Headers are available, and we can start reading the body.
|
| -// did_open_ = true;
|
| -// ProcessResponseInfo(loader_.GetResponseInfo());
|
| -// ReadMore();
|
| -// } else {
|
| -// // Done reading (possibly with an error given by 'result').
|
| -// }
|
| -// }
|
| -// void ReadMore() {
|
| -// CompletionCallback* cc = NewCallback();
|
| -// int32_t rv = fio_.Read(offset_, buf_, sizeof(buf_), cc);
|
| -// if (rv != PP_Error_WouldBlock)
|
| -// cc->Run(rv);
|
| -// }
|
| -// void ProcessResponseInfo(const URLResponseInfo& response_info) {
|
| -// // Read response headers, etc.
|
| -// }
|
| -// void ProcessBytes(const char* bytes, int32_t length) {
|
| -// // Do work ...
|
| -// }
|
| -// pp::CompletionCallbackFactory<MyHandler> factory_;
|
| -// pp::URLLoader loader_;
|
| -// char buf_[4096];
|
| -// bool did_open_;
|
| -// };
|
| -//
|
| +// Please see the example in ppapi/examples/url_loader/url_loader.cc.
|
| class URLLoader : public Resource {
|
| public:
|
| // Creates an is_null() URLLoader object.
|
|
|