| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This example shows how to use the URLLoader in streaming mode (reading to | 5 // This example shows how to use the URLLoader in streaming mode (reading to |
| 6 // memory as data comes over the network). This example uses PostMessage between | 6 // memory as data comes over the network). This example uses PostMessage between |
| 7 // the plugin and the url_loader.html page in this directory to start the load | 7 // the plugin and the url_loader.html page in this directory to start the load |
| 8 // and to communicate the result. | 8 // and to communicate the result. |
| 9 // | 9 // |
| 10 // The other mode is to stream to a file instead. For that mode, call | 10 // The other mode is to stream to a file instead. For that mode, call |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 void MyInstance::StartRequest(const std::string& url) { | 76 void MyInstance::StartRequest(const std::string& url) { |
| 77 content_.clear(); | 77 content_.clear(); |
| 78 | 78 |
| 79 pp::URLRequestInfo request(this); | 79 pp::URLRequestInfo request(this); |
| 80 request.SetURL(url); | 80 request.SetURL(url); |
| 81 request.SetMethod("GET"); | 81 request.SetMethod("GET"); |
| 82 | 82 |
| 83 loader_ = pp::URLLoader(this); | 83 loader_ = pp::URLLoader(this); |
| 84 loader_.Open(request, | 84 loader_.Open(request, |
| 85 factory_.NewRequiredCallback(&MyInstance::OnOpenComplete)); | 85 factory_.NewCallback(&MyInstance::OnOpenComplete)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void MyInstance::OnOpenComplete(int32_t result) { | 88 void MyInstance::OnOpenComplete(int32_t result) { |
| 89 if (result != PP_OK) { | 89 if (result != PP_OK) { |
| 90 ReportResponse("URL could not be requested"); | 90 ReportResponse("URL could not be requested"); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 response_ = loader_.GetResponseInfo(); | 94 response_ = loader_.GetResponseInfo(); |
| 95 | 95 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 namespace pp { | 165 namespace pp { |
| 166 | 166 |
| 167 // Factory function for your specialization of the Module object. | 167 // Factory function for your specialization of the Module object. |
| 168 Module* CreateModule() { | 168 Module* CreateModule() { |
| 169 return new MyModule(); | 169 return new MyModule(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace pp | 172 } // namespace pp |
| OLD | NEW |