| OLD | NEW |
| 1 .. _devguide-coding-url-loading: | 1 .. _devguide-coding-url-loading: |
| 2 | 2 |
| 3 ########### | 3 ########### |
| 4 URL Loading | 4 URL Loading |
| 5 ########### | 5 ########### |
| 6 | 6 |
| 7 .. contents:: | 7 .. contents:: |
| 8 :local: | 8 :local: |
| 9 :backlinks: none | 9 :backlinks: none |
| 10 :depth: 2 | 10 :depth: 2 |
| 11 | 11 |
| 12 Introduction | 12 Introduction |
| 13 ============ | 13 ============ |
| 14 | 14 |
| 15 This chapter describes how to use the `URLLoader API | 15 This chapter describes how to use the `URLLoader API |
| 16 <https://developers.google.com/native-client/peppercpp/classpp_1_1_u_r_l_loader>
`_ | 16 </native-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader>`_ to load resources |
| 17 to load resources such as images and sound files from a server into your | 17 such as images and sound files from a server into your application. |
| 18 application. | |
| 19 | 18 |
| 20 The example discussed in this chapter is included in the SDK in the directory | 19 The example discussed in this chapter is included in the SDK in the directory |
| 21 ``examples/api/url_loader``. | 20 ``examples/api/url_loader``. |
| 22 | 21 |
| 23 Reference information | 22 Reference information |
| 24 ===================== | 23 ===================== |
| 25 | 24 |
| 26 For reference information related to loading data from URLs, see the | 25 For reference information related to loading data from URLs, see the |
| 27 following documentation: | 26 following documentation: |
| 28 | 27 |
| 29 * `url_loader.h | 28 * `url_loader.h </native-client/pepper_stable/cpp/url__loader_8h>`_ - Contains |
| 30 <https://developers.google.com/native-client/peppercpp/url__loader_8h>`_ - | 29 ``URLLoader`` class for loading data from URLs |
| 31 Contains ``URLLoader`` class for loading data from URLs | |
| 32 * `url_request_info.h | 30 * `url_request_info.h |
| 33 <https://developers.google.com/native-client/peppercpp/url__request__info_8h>`
_ | 31 </native-client/pepper_stable/cpp/url__request__info_8h>`_ - Contains |
| 34 - Contains ``URLRequest`` class for creating and manipulating URL requests | 32 ``URLRequest`` class for creating and manipulating URL requests |
| 35 * `url_response_info.h | 33 * `url_response_info.h |
| 36 <https://developers.google.com/native-client/peppercpp/url__response__info_8h>
`_ | 34 </native-client/pepper_stable/cpp/url__response__info_8h>`_ - Contains |
| 37 - Contains ``URLResponse`` class for examaning URL responses | 35 ``URLResponse`` class for examaning URL responses |
| 38 | 36 |
| 39 Background | 37 Background |
| 40 ========== | 38 ========== |
| 41 | 39 |
| 42 When a user launches your Native Client web application, Chrome downloads and | 40 When a user launches your Native Client web application, Chrome downloads and |
| 43 caches your application's HTML file, manifest file (.nmf), and Native Client | 41 caches your application's HTML file, manifest file (.nmf), and Native Client |
| 44 module (.pexe or .nexe). If your application needs additional assets, such as | 42 module (.pexe or .nexe). If your application needs additional assets, such as |
| 45 images and sound files, it must explicitly load those assets. You can use the | 43 images and sound files, it must explicitly load those assets. You can use the |
| 46 Pepper APIs described in this chapter to load assets from a URL into your | 44 Pepper APIs described in this chapter to load assets from a URL into your |
| 47 application. | 45 application. |
| 48 | 46 |
| 49 After you've loaded assets into your application, Chrome will cache those | 47 After you've loaded assets into your application, Chrome will cache those |
| 50 assets. To avoid being at the whim of the Chrome cache, however, you may want | 48 assets. To avoid being at the whim of the Chrome cache, however, you may want |
| 51 to use the `Pepper FileIO API | 49 to use the `Pepper FileIO API |
| 52 <https://developers.google.com/native-client/peppercpp/classpp_1_1_file_i_o>`_ | 50 </native-client/pepper_stable/cpp/classpp_1_1_file_i_o>`_ to write those assets |
| 53 to write those assets to a persistent, sandboxed location on the user's file | 51 to a persistent, sandboxed location on the user's file system. |
| 54 system. | |
| 55 | 52 |
| 56 The ``url_loader`` example | 53 The ``url_loader`` example |
| 57 ========================== | 54 ========================== |
| 58 | 55 |
| 59 The SDK includes an example called ``url_loader`` demonstrating downloading | 56 The SDK includes an example called ``url_loader`` demonstrating downloading |
| 60 files from a server. This example has these primary files: | 57 files from a server. This example has these primary files: |
| 61 | 58 |
| 62 * ``index.html`` - The HTML code that launches the Native Client module. | 59 * ``index.html`` - The HTML code that launches the Native Client module. |
| 63 * ``example.js`` - The JavaScript file for index.html. It has code that sends | 60 * ``example.js`` - The JavaScript file for index.html. It has code that sends |
| 64 a PostMessage request to the Native Client module when the "Get URL" button | 61 a PostMessage request to the Native Client module when the "Get URL" button |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 or there is an error (less than -1). ``OnRead`` is called in the event of an | 241 or there is an error (less than -1). ``OnRead`` is called in the event of an |
| 245 error or ``PP_OK``. | 242 error or ``PP_OK``. |
| 246 | 243 |
| 247 Displaying a result | 244 Displaying a result |
| 248 ------------------- | 245 ------------------- |
| 249 | 246 |
| 250 OnRead calls ``ReportResultAndDie`` when either an error or ``PP_OK`` is | 247 OnRead calls ``ReportResultAndDie`` when either an error or ``PP_OK`` is |
| 251 returned to indicate streaming of file is complete. ``ReportResultAndDie`` then | 248 returned to indicate streaming of file is complete. ``ReportResultAndDie`` then |
| 252 calls ``ReportResult,`` which calls ``PostMessage`` to send the result back to | 249 calls ``ReportResult,`` which calls ``PostMessage`` to send the result back to |
| 253 the HTML page. | 250 the HTML page. |
| OLD | NEW |