| 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="htt
ps://developers.google.com/native-client/peppercpp/classpp_1_1_u_r_l_loader">URL
Loader API</a> | 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 |
| 27 to load resources such as images and sound files from a server into your | 27 such as images and sound files from a server into your application.</p> |
| 28 application.</p> | |
| 29 <p>The example discussed in this chapter is included in the SDK in the directory | 28 <p>The example discussed in this chapter is included in the SDK in the directory |
| 30 <code>examples/api/url_loader</code>.</p> | 29 <code>examples/api/url_loader</code>.</p> |
| 31 </section><section id="reference-information"> | 30 </section><section id="reference-information"> |
| 32 <h2 id="reference-information">Reference information</h2> | 31 <h2 id="reference-information">Reference information</h2> |
| 33 <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 |
| 34 following documentation:</p> | 33 following documentation:</p> |
| 35 <ul class="small-gap"> | 34 <ul class="small-gap"> |
| 36 <li><a class="reference external" href="https://developers.google.com/native-cli
ent/peppercpp/url__loader_8h">url_loader.h</a> - | 35 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__lo
ader_8h">url_loader.h</a> - Contains |
| 37 Contains <code>URLLoader</code> class for loading data from URLs</li> | 36 <code>URLLoader</code> class for loading data from URLs</li> |
| 38 <li><a class="reference external" href="https://developers.google.com/native-cli
ent/peppercpp/url__request__info_8h">url_request_info.h</a> | 37 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
quest__info_8h">url_request_info.h</a> - Contains |
| 39 - Contains <code>URLRequest</code> class for creating and manipulating URL reque
sts</li> | 38 <code>URLRequest</code> class for creating and manipulating URL requests</li> |
| 40 <li><a class="reference external" href="https://developers.google.com/native-cli
ent/peppercpp/url__response__info_8h">url_response_info.h</a> | 39 <li><a class="reference external" href="/native-client/pepper_stable/cpp/url__re
sponse__info_8h">url_response_info.h</a> - Contains |
| 41 - Contains <code>URLResponse</code> class for examaning URL responses</li> | 40 <code>URLResponse</code> class for examaning URL responses</li> |
| 42 </ul> | 41 </ul> |
| 43 </section><section id="background"> | 42 </section><section id="background"> |
| 44 <h2 id="background">Background</h2> | 43 <h2 id="background">Background</h2> |
| 45 <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 |
| 46 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 |
| 47 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 |
| 48 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 |
| 49 Pepper APIs described in this chapter to load assets from a URL into your | 48 Pepper APIs described in this chapter to load assets from a URL into your |
| 50 application.</p> | 49 application.</p> |
| 51 <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 |
| 52 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 |
| 53 to use the <a class="reference external" href="https://developers.google.com/nat
ive-client/peppercpp/classpp_1_1_file_i_o">Pepper FileIO API</a> | 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 |
| 54 to write those assets to a persistent, sandboxed location on the user’s fi
le | 53 to a persistent, sandboxed location on the user’s file system.</p> |
| 55 system.</p> | |
| 56 </section><section id="the-url-loader-example"> | 54 </section><section id="the-url-loader-example"> |
| 57 <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> |
| 58 <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 |
| 59 files from a server. This example has these primary files:</p> | 57 files from a server. This example has these primary files:</p> |
| 60 <ul class="small-gap"> | 58 <ul class="small-gap"> |
| 61 <li><code>index.html</code> - The HTML code that launches the Native Client modu
le.</li> | 59 <li><code>index.html</code> - The HTML code that launches the Native Client modu
le.</li> |
| 62 <li><code>example.js</code> - The JavaScript file for index.html. It has code th
at sends | 60 <li><code>example.js</code> - The JavaScript file for index.html. It has code th
at sends |
| 63 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 |
| 64 is clicked.</li> | 62 is clicked.</li> |
| 65 <li><code>url_loader_success.html</code> - An HTML file on the server whose cont
ents are | 63 <li><code>url_loader_success.html</code> - An HTML file on the server whose cont
ents are |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 error or <code>PP_OK</code>.</p> | 221 error or <code>PP_OK</code>.</p> |
| 224 </section><section id="displaying-a-result"> | 222 </section><section id="displaying-a-result"> |
| 225 <h3 id="displaying-a-result">Displaying a result</h3> | 223 <h3 id="displaying-a-result">Displaying a result</h3> |
| 226 <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 |
| 227 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 |
| 228 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 |
| 229 the HTML page.</p> | 227 the HTML page.</p> |
| 230 </section></section></section> | 228 </section></section></section> |
| 231 | 229 |
| 232 {{/partials.standard_nacl_article}} | 230 {{/partials.standard_nacl_article}} |
| OLD | NEW |