OLD | NEW |
1 {{+bindTo:partials.standard_nacl_article}} | 1 {{+bindTo:partials.standard_nacl_article}} |
2 | 2 |
3 <section id="url-loading"> | 3 <section id="url-loading"> |
4 <span id="devguide-coding-url-loading"></span><h1 id="url-loading"><span id="dev
guide-coding-url-loading"></span>URL Loading</h1> | 4 <span id="devguide-coding-url-loading"></span><h1 id="url-loading"><span id="dev
guide-coding-url-loading"></span>URL Loading</h1> |
5 <div class="contents local" id="contents" style="display: none"> | 5 <div class="contents local" id="contents" style="display: none"> |
6 <ul class="small-gap"> | 6 <ul class="small-gap"> |
7 <li><a class="reference internal" href="#introduction" id="id1">Introduction</a>
</li> | 7 <li><a class="reference internal" href="#introduction" id="id1">Introduction</a>
</li> |
8 <li><a class="reference internal" href="#reference-information" id="id2">Referen
ce information</a></li> | 8 <li><a class="reference internal" href="#reference-information" id="id2">Referen
ce information</a></li> |
9 <li><a class="reference internal" href="#background" id="id3">Background</a></li
> | 9 <li><a class="reference internal" href="#background" id="id3">Background</a></li
> |
10 <li><p class="first"><a class="reference internal" href="#the-url-loader-example
" id="id4">The <code>url_loader</code> example</a></p> | 10 <li><p class="first"><a class="reference internal" href="#the-url-loader-example
" id="id4">The <code>url_loader</code> example</a></p> |
11 <ul class="small-gap"> | 11 <ul class="small-gap"> |
12 <li><a class="reference internal" href="#url-loading-overview" id="id5">URL load
ing overview</a></li> | 12 <li><a class="reference internal" href="#url-loading-overview" id="id5">URL load
ing overview</a></li> |
13 </ul> | 13 </ul> |
14 </li> | 14 </li> |
15 <li><p class="first"><a class="reference internal" href="#url-loader-deep-dive"
id="id6"><code>url_loader</code> deep dive</a></p> | 15 <li><p class="first"><a class="reference internal" href="#url-loader-deep-dive"
id="id6"><code>url_loader</code> deep dive</a></p> |
16 <ul class="small-gap"> | 16 <ul class="small-gap"> |
17 <li><a class="reference internal" href="#setting-up-the-request" id="id7">Settin
g up the request</a></li> | 17 <li><a class="reference internal" href="#setting-up-the-request" id="id7">Settin
g up the request</a></li> |
18 <li><a class="reference internal" href="#downloading-the-data" id="id8">Download
ing the data</a></li> | 18 <li><a class="reference internal" href="#downloading-the-data" id="id8">Download
ing the data</a></li> |
19 <li><a class="reference internal" href="#displaying-a-result" id="id9">Displayin
g a result</a></li> | 19 <li><a class="reference internal" href="#displaying-a-result" id="id9">Displayin
g a result</a></li> |
20 </ul> | 20 </ul> |
21 </li> | 21 </li> |
22 </ul> | 22 </ul> |
23 | 23 |
24 </div><section id="introduction"> | 24 </div><section id="introduction"> |
25 <h2 id="introduction">Introduction</h2> | 25 <h2 id="introduction">Introduction</h2> |
26 <p>This chapter describes how to use the <a class="reference external" href="/na
tive-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader">URLLoader API</a> to loa
d resources | 26 <p>This section describes how to use the <a class="reference external" href="/na
tive-client/pepper_stable/cpp/classpp_1_1_u_r_l_loader">URLLoader API</a> to loa
d resources |
27 such as images and sound files from a server into your application.</p> | 27 such as images and sound files from a server into your application.</p> |
28 <p>The example discussed in this chapter is included in the SDK in the directory | 28 <p>The example discussed in this section is included in the SDK in the directory |
29 <code>examples/api/url_loader</code>.</p> | 29 <code>examples/api/url_loader</code>.</p> |
30 </section><section id="reference-information"> | 30 </section><section id="reference-information"> |
31 <h2 id="reference-information">Reference information</h2> | 31 <h2 id="reference-information">Reference information</h2> |
32 <p>For reference information related to loading data from URLs, see the | 32 <p>For reference information related to loading data from URLs, see the |
33 following documentation:</p> | 33 following documentation:</p> |
34 <ul class="small-gap"> | 34 <ul class="small-gap"> |
35 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__lo
ader_8h">url_loader.h</a> - Contains | 35 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__lo
ader_8h">url_loader.h</a> - Contains |
36 <code>URLLoader</code> class for loading data from URLs</li> | 36 <code>URLLoader</code> class for loading data from URLs</li> |
37 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
quest__info_8h">url_request_info.h</a> - Contains | 37 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
quest__info_8h">url_request_info.h</a> - Contains |
38 <code>URLRequest</code> class for creating and manipulating URL requests</li> | 38 <code>URLRequest</code> class for creating and manipulating URL requests</li> |
39 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
sponse__info_8h">url_response_info.h</a> - Contains | 39 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
sponse__info_8h">url_response_info.h</a> - Contains |
40 <code>URLResponse</code> class for examaning URL responses</li> | 40 <code>URLResponse</code> class for examaning URL responses</li> |
41 </ul> | 41 </ul> |
42 </section><section id="background"> | 42 </section><section id="background"> |
43 <h2 id="background">Background</h2> | 43 <h2 id="background">Background</h2> |
44 <p>When a user launches your Native Client web application, Chrome downloads and | 44 <p>When a user launches your Native Client web application, Chrome downloads and |
45 caches your application’s HTML file, manifest file (.nmf), and Native Clie
nt | 45 caches your application’s HTML file, manifest file (.nmf), and Native Clie
nt |
46 module (.pexe or .nexe). If your application needs additional assets, such as | 46 module (.pexe or .nexe). If your application needs additional assets, such as |
47 images and sound files, it must explicitly load those assets. You can use the | 47 images and sound files, it must explicitly load those assets. You can use the |
48 Pepper APIs described in this chapter to load assets from a URL into your | 48 Pepper APIs described in this section to load assets from a URL into your |
49 application.</p> | 49 application.</p> |
50 <p>After you’ve loaded assets into your application, Chrome will cache tho
se | 50 <p>After you’ve loaded assets into your application, Chrome will cache tho
se |
51 assets. To avoid being at the whim of the Chrome cache, however, you may want | 51 assets. To avoid being at the whim of the Chrome cache, however, you may want |
52 to use the <a class="reference external" href="/native-client/pepper_stable/cpp/
classpp_1_1_file_i_o">Pepper FileIO API</a> to write those assets | 52 to use the <a class="reference external" href="/native-client/pepper_stable/cpp/
classpp_1_1_file_i_o">Pepper FileIO API</a> to write those assets |
53 to a persistent, sandboxed location on the user’s file system.</p> | 53 to a persistent, sandboxed location on the user’s file system.</p> |
54 </section><section id="the-url-loader-example"> | 54 </section><section id="the-url-loader-example"> |
55 <h2 id="the-url-loader-example">The <code>url_loader</code> example</h2> | 55 <h2 id="the-url-loader-example">The <code>url_loader</code> example</h2> |
56 <p>The SDK includes an example called <code>url_loader</code> demonstrating down
loading | 56 <p>The SDK includes an example called <code>url_loader</code> demonstrating down
loading |
57 files from a server. This example has these primary files:</p> | 57 files from a server. This example has these primary files:</p> |
58 <ul class="small-gap"> | 58 <ul class="small-gap"> |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 error or <code>PP_OK</code>.</p> | 221 error or <code>PP_OK</code>.</p> |
222 </section><section id="displaying-a-result"> | 222 </section><section id="displaying-a-result"> |
223 <h3 id="displaying-a-result">Displaying a result</h3> | 223 <h3 id="displaying-a-result">Displaying a result</h3> |
224 <p>OnRead calls <code>ReportResultAndDie</code> when either an error or <code>PP
_OK</code> is | 224 <p>OnRead calls <code>ReportResultAndDie</code> when either an error or <code>PP
_OK</code> is |
225 returned to indicate streaming of file is complete. <code>ReportResultAndDie</co
de> then | 225 returned to indicate streaming of file is complete. <code>ReportResultAndDie</co
de> then |
226 calls <code>ReportResult,</code> which calls <code>PostMessage</code> to send th
e result back to | 226 calls <code>ReportResult,</code> which calls <code>PostMessage</code> to send th
e result back to |
227 the HTML page.</p> | 227 the HTML page.</p> |
228 </section></section></section> | 228 </section></section></section> |
229 | 229 |
230 {{/partials.standard_nacl_article}} | 230 {{/partials.standard_nacl_article}} |
OLD | NEW |