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 |
11 // URLLoader.FinishSthreamingToFile once the "Open" callback is complete, and | 11 // URLLoader.FinishSthreamingToFile once the "Open" callback is complete, and |
12 // then call URLResponseInfo.GetBodyAsFileRef once the file stream is complete. | 12 // then call URLResponseInfo.GetBodyAsFileRef once the file stream is complete. |
13 | 13 |
14 #include "ppapi/cpp/completion_callback.h" | |
15 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
16 #include "ppapi/cpp/module.h" | 15 #include "ppapi/cpp/module.h" |
17 #include "ppapi/cpp/url_loader.h" | 16 #include "ppapi/cpp/url_loader.h" |
18 #include "ppapi/cpp/url_request_info.h" | 17 #include "ppapi/cpp/url_request_info.h" |
19 #include "ppapi/cpp/url_response_info.h" | 18 #include "ppapi/cpp/url_response_info.h" |
| 19 #include "ppapi/utility/completion_callback_factory.h" |
20 | 20 |
21 // Buffer size for reading network data. | 21 // Buffer size for reading network data. |
22 const int kBufSize = 1024; | 22 const int kBufSize = 1024; |
23 | 23 |
24 class MyInstance : public pp::Instance { | 24 class MyInstance : public pp::Instance { |
25 public: | 25 public: |
26 explicit MyInstance(PP_Instance instance) | 26 explicit MyInstance(PP_Instance instance) |
27 : pp::Instance(instance) { | 27 : pp::Instance(instance) { |
28 factory_.Initialize(this); | 28 factory_.Initialize(this); |
29 } | 29 } |
(...skipping 133 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 |