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 section describes how to use the `URLLoader API |
16 </native-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader>`_ to load resources | 16 </native-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader>`_ to load resources |
17 such as images and sound files from a server into your application. | 17 such as images and sound files from a server into your application. |
18 | 18 |
19 The example discussed in this chapter is included in the SDK in the directory | 19 The example discussed in this section is included in the SDK in the directory |
20 ``examples/api/url_loader``. | 20 ``examples/api/url_loader``. |
21 | 21 |
22 Reference information | 22 Reference information |
23 ===================== | 23 ===================== |
24 | 24 |
25 For reference information related to loading data from URLs, see the | 25 For reference information related to loading data from URLs, see the |
26 following documentation: | 26 following documentation: |
27 | 27 |
28 * `url_loader.h </native-client/pepper_stable/cpp/url__loader_8h>`_ - Contains | 28 * `url_loader.h </native-client/pepper_stable/cpp/url__loader_8h>`_ - Contains |
29 ``URLLoader`` class for loading data from URLs | 29 ``URLLoader`` class for loading data from URLs |
30 * `url_request_info.h | 30 * `url_request_info.h |
31 </native-client/pepper_stable/cpp/url__request__info_8h>`_ - Contains | 31 </native-client/pepper_stable/cpp/url__request__info_8h>`_ - Contains |
32 ``URLRequest`` class for creating and manipulating URL requests | 32 ``URLRequest`` class for creating and manipulating URL requests |
33 * `url_response_info.h | 33 * `url_response_info.h |
34 </native-client/pepper_stable/cpp/url__response__info_8h>`_ - Contains | 34 </native-client/pepper_stable/cpp/url__response__info_8h>`_ - Contains |
35 ``URLResponse`` class for examaning URL responses | 35 ``URLResponse`` class for examaning URL responses |
36 | 36 |
37 Background | 37 Background |
38 ========== | 38 ========== |
39 | 39 |
40 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 |
41 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 |
42 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 |
43 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 |
44 Pepper APIs described in this chapter to load assets from a URL into your | 44 Pepper APIs described in this section to load assets from a URL into your |
45 application. | 45 application. |
46 | 46 |
47 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 |
48 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 |
49 to use the `Pepper FileIO API | 49 to use the `Pepper FileIO API |
50 </native-client/pepper_stable/cpp/classpp_1_1_file_i_o>`_ to write those assets | 50 </native-client/pepper_stable/cpp/classpp_1_1_file_i_o>`_ to write those assets |
51 to a persistent, sandboxed location on the user's file system. | 51 to a persistent, sandboxed location on the user's file system. |
52 | 52 |
53 The ``url_loader`` example | 53 The ``url_loader`` example |
54 ========================== | 54 ========================== |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 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 |
242 error or ``PP_OK``. | 242 error or ``PP_OK``. |
243 | 243 |
244 Displaying a result | 244 Displaying a result |
245 ------------------- | 245 ------------------- |
246 | 246 |
247 OnRead calls ``ReportResultAndDie`` when either an error or ``PP_OK`` is | 247 OnRead calls ``ReportResultAndDie`` when either an error or ``PP_OK`` is |
248 returned to indicate streaming of file is complete. ``ReportResultAndDie`` then | 248 returned to indicate streaming of file is complete. ``ReportResultAndDie`` then |
249 calls ``ReportResult,`` which calls ``PostMessage`` to send the result back to | 249 calls ``ReportResult,`` which calls ``PostMessage`` to send the result back to |
250 the HTML page. | 250 the HTML page. |
OLD | NEW |