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><h2 id="introduction">Introduction</h2> | 24 </div><h2 id="introduction">Introduction</h2> |
25 <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 | 25 <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 |
26 such as images and sound files from a server into your application.</p> | 26 such as images and sound files from a server into your application.</p> |
27 <p>The example discussed in this chapter is included in the SDK in the directory | 27 <p>The example discussed in this section is included in the SDK in the directory |
28 <code>examples/api/url_loader</code>.</p> | 28 <code>examples/api/url_loader</code>.</p> |
29 <h2 id="reference-information">Reference information</h2> | 29 <h2 id="reference-information">Reference information</h2> |
30 <p>For reference information related to loading data from URLs, see the | 30 <p>For reference information related to loading data from URLs, see the |
31 following documentation:</p> | 31 following documentation:</p> |
32 <ul class="small-gap"> | 32 <ul class="small-gap"> |
33 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__lo
ader_8h">url_loader.h</a> - Contains | 33 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__lo
ader_8h">url_loader.h</a> - Contains |
34 <code>URLLoader</code> class for loading data from URLs</li> | 34 <code>URLLoader</code> class for loading data from URLs</li> |
35 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
quest__info_8h">url_request_info.h</a> - Contains | 35 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
quest__info_8h">url_request_info.h</a> - Contains |
36 <code>URLRequest</code> class for creating and manipulating URL requests</li> | 36 <code>URLRequest</code> class for creating and manipulating URL requests</li> |
37 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
sponse__info_8h">url_response_info.h</a> - Contains | 37 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
sponse__info_8h">url_response_info.h</a> - Contains |
38 <code>URLResponse</code> class for examaning URL responses</li> | 38 <code>URLResponse</code> class for examaning URL responses</li> |
39 </ul> | 39 </ul> |
40 <h2 id="background">Background</h2> | 40 <h2 id="background">Background</h2> |
41 <p>When a user launches your Native Client web application, Chrome downloads and | 41 <p>When a user launches your Native Client web application, Chrome downloads and |
42 caches your application’s HTML file, manifest file (.nmf), and Native Clie
nt | 42 caches your application’s HTML file, manifest file (.nmf), and Native Clie
nt |
43 module (.pexe or .nexe). If your application needs additional assets, such as | 43 module (.pexe or .nexe). If your application needs additional assets, such as |
44 images and sound files, it must explicitly load those assets. You can use the | 44 images and sound files, it must explicitly load those assets. You can use the |
45 Pepper APIs described in this chapter to load assets from a URL into your | 45 Pepper APIs described in this section to load assets from a URL into your |
46 application.</p> | 46 application.</p> |
47 <p>After you’ve loaded assets into your application, Chrome will cache tho
se | 47 <p>After you’ve loaded assets into your application, Chrome will cache tho
se |
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 <a class="reference external" href="/native-client/pepper_stable/cpp/
classpp_1_1_file_i_o">Pepper FileIO API</a> to write those assets | 49 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 |
50 to a persistent, sandboxed location on the user’s file system.</p> | 50 to a persistent, sandboxed location on the user’s file system.</p> |
51 <h2 id="the-url-loader-example">The <code>url_loader</code> example</h2> | 51 <h2 id="the-url-loader-example">The <code>url_loader</code> example</h2> |
52 <p>The SDK includes an example called <code>url_loader</code> demonstrating down
loading | 52 <p>The SDK includes an example called <code>url_loader</code> demonstrating down
loading |
53 files from a server. This example has these primary files:</p> | 53 files from a server. This example has these primary files:</p> |
54 <ul class="small-gap"> | 54 <ul class="small-gap"> |
55 <li><code>index.html</code> - The HTML code that launches the Native Client modu
le.</li> | 55 <li><code>index.html</code> - The HTML code that launches the Native Client modu
le.</li> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 or there is an error (less than -1). <code>OnRead</code> is called in the event
of an | 212 or there is an error (less than -1). <code>OnRead</code> is called in the event
of an |
213 error or <code>PP_OK</code>.</p> | 213 error or <code>PP_OK</code>.</p> |
214 <h3 id="displaying-a-result">Displaying a result</h3> | 214 <h3 id="displaying-a-result">Displaying a result</h3> |
215 <p>OnRead calls <code>ReportResultAndDie</code> when either an error or <code>PP
_OK</code> is | 215 <p>OnRead calls <code>ReportResultAndDie</code> when either an error or <code>PP
_OK</code> is |
216 returned to indicate streaming of file is complete. <code>ReportResultAndDie</co
de> then | 216 returned to indicate streaming of file is complete. <code>ReportResultAndDie</co
de> then |
217 calls <code>ReportResult,</code> which calls <code>PostMessage</code> to send th
e result back to | 217 calls <code>ReportResult,</code> which calls <code>PostMessage</code> to send th
e result back to |
218 the HTML page.</p> | 218 the HTML page.</p> |
219 </section> | 219 </section> |
220 | 220 |
221 {{/partials.standard_nacl_article}} | 221 {{/partials.standard_nacl_article}} |
OLD | NEW |