</div><p>There are five types of events that developers can respond to in Native Client:
progress, message, view change, focus, and input events (each described in the
-glossary below). This chapter describes how to monitor progress events (events
+glossary below). This section describes how to monitor progress events (events
that occur during the loading and execution of a Native Client module). This
-chapter assumes you are familiar with the material presented in the
+section assumes you are familiar with the material presented in the
<a class="reference internal" href="/native-client/overview.html"><em>Technical Overview</em></a>.</p>
<aside class="note">
The load_progress example illustrates progress event handling. You can find
-this code in the <code>/examples/tutorial/load_progress/</code> directory in the Native
-Client SDK download.
+this code in the <code>/pepper_<version>/examples/tutorial/load_progress/</code>
+directory in the Native Client SDK download.
</aside>
-<section id="module-loading-and-progress-events">
<h2 id="module-loading-and-progress-events">Module loading and progress events</h2>
<p>The Native Client runtime reports a set of state changes during the module
loading process by means of DOM progress events. This set of events is a direct
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Event</th>
-<th class="head">Description</th>
-<th class="head">Number of
-times
+<th class="head">Times
triggered</th>
-<th class="head">When event is
+<th class="head">When
triggered</th>
<th class="head">How you might
-react to
-event</th>
+respond</th>
</tr>
</thead>
<tbody valign="top">
-<tr class="row-even"><td><code>loadstart</code></td>
-<td>Native Client has
-started to load a
-Native Client
-module.</td>
+<tr class="row-even"><td><dl class="first last docutils">
+<dt><code>loadstart</code></dt>
+<dd>Native Client has started to
+load a Native Client module.</dd>
+</dl>
+</td>
<td>once</td>
-<td>This is the
+<td>The
first
progress
event
-triggered
after the
Native Client
module is
as
“Loading...”</td>
</tr>
-<tr class="row-odd"><td><code>progress</code></td>
-<td>Part of the module
-has been loaded.</td>
+<tr class="row-odd"><td><dl class="first last docutils">
+<dt><code>progress</code></dt>
+<dd>Part of the module has been
+loaded.</dd>
+</dl>
+</td>
<td>zero or
more</td>
<td>After
<td>Display a
progress bar.</td>
</tr>
-<tr class="row-even"><td><code>error</code></td>
-<td>The Native Client
-module failed to
-start execution
-(includes any
-error before or
-during
-initialization of
-the module). The
-<code>lastError</code>
-attribute
-(mentioned later)
-provides details
-on the error
-(initialization
-failed, sel_ldr
-did not start,
-and so on).</td>
+<tr class="row-even"><td><dl class="first last docutils">
+<dt><code>error</code></dt>
+<dd>The Native Client module failed
+to start execution (includes any
+error before or during
+initialization of the module).
+The <code>lastError</code> attribute
+(mentioned later) provides
+details on the error
+(initialization failed, sel_ldr
+did not start, and so on).</dd>
+</dl>
+</td>
<td>zero or
once</td>
-<td>After the
-last
+<td>After the last
<code>progress</code>
-event has
-been
+event has been
dispatched,
or after
<code>loadstart</code>
failed to
load.</td>
</tr>
-<tr class="row-odd"><td><code>abort</code></td>
-<td>Loading of the
-Native Client
-module was
-aborted by the
-user.</td>
+<tr class="row-odd"><td><dl class="first last docutils">
+<dt><code>abort</code></dt>
+<dd>Loading of the NativeClient
+module was aborted by the user.</dd>
+</dl>
+</td>
<td>zero or
once</td>
-<td>After the
-last
+<td>After the last
<code>progress</code>
-event has
-been
-dispatched,
-or after
+event has been
+dispatched, or
+after
<code>loadstart</code>
if no
<code>progress</code>
respond to
this event.</td>
</tr>
-<tr class="row-even"><td><code>load</code></td>
-<td>The Native Client
-module was
-successfully
-loaded, and
-execution was
-started. (The
-module was
-initialized
-successfully.)</td>
+<tr class="row-even"><td><dl class="first last docutils">
+<dt><code>load</code></dt>
+<dd>The Native Client module was
+successfully loaded, and
+execution was started.
+(The module was initialized
+successfully.)</dd>
+</dl>
+</td>
<td>zero or
once</td>
<td>After the
last
<code>progress</code>
-event has
-been
-dispatched,
-or after
+event has been
+dispatched, or
+after
<code>loadstart</code>
if no
<code>progress</code>
<td>Remove the
progress bar.</td>
</tr>
-<tr class="row-odd"><td><code>loadend</code></td>
-<td>Loading of the
-Native Client
-module has
-stopped. Load
-succeeded
-(<code>load</code>),
-failed
-(<code>error</code>), or
-was aborted
-(<code>abort</code>).</td>
+<tr class="row-odd"><td><dl class="first last docutils">
+<dt><code>loadend</code></dt>
+<dd>Loading of the Native Client
+module has stopped. Load
+succeeded (<code>load</code>), failed
+(<code>error</code>), or was aborted
+(<code>abort</code>).</dd>
+</dl>
+</td>
<td>once</td>
<td>After an
<code>error</code>,
<td>Indicate
loading is
over
-(regardless
-of failure or
+(regardless of
+failure or
not).</td>
</tr>
-<tr class="row-even"><td><code>crash</code></td>
-<td>The Native Client
-module is not
-responding (died
-on an
-<code>assert()</code> or
-<code>exit()</code>) after
-a successful
-load. This event
-is unique to
-Native Client and
-is not part of
-the W3C Progress
-Events standard.
-The <code>exitStatus</code>
-attribute provides
-the numeric exit
-status value.</td>
+<tr class="row-even"><td><dl class="first last docutils">
+<dt><code>crash</code></dt>
+<dd>The Native Client module is not
+responding (died on an
+<code>assert()</code> or <code>exit()</code>)
+after a successful load. This
+event is unique to Native Client
+and is not part of the W3C
+Progress Events standard. The
+<code>exitStatus</code> attribute
+provides the numeric exit
+status.</dd>
+</dl>
+</td>
<td>zero or
once</td>
<td>After a
</table>
<p>Errors that occur during loading are logged to the JavaScript console in Google
Chrome (select the menu icon <img alt="menu-icon" src="/native-client/images/menu-icon.png" /> > Tools > JavaScript console).</p>
-</section><section id="handling-progress-events">
<h2 id="handling-progress-events">Handling progress events</h2>
<p>You should add event listeners in a <code><script></code> element to listen for these
events before the <code><embed></code> element is parsed. For example, the following code
from inner elements. For more information, see the W3 specifications for <a class="reference external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-capture">event
flow capture</a> and
<a class="reference external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">event listener registration</a>.</p>
-</section><section id="displaying-load-status">
<h2 id="displaying-load-status">Displaying load status</h2>
<p>One common response to progress events is to display the percentage of the
module that has been loaded. In the load_progress example, when the <code>progress</code>
}
}
</pre>
-</section><section id="the-lasterror-attribute">
<h2 id="the-lasterror-attribute">The <code>lastError</code> attribute</h2>
<p>The <code><embed></code> element has a <code>lastError</code> attribute that is set to an
informative string whenever a load failure (an <code>error</code> or <code>abort</code> event)
common.logMessage('error: ' + common.naclModule.lastError);
}
</pre>
-</section><section id="the-readystate-attribute">
<h2 id="the-readystate-attribute">The <code>readyState</code> attribute</h2>
<p>You can use the <code>readyState</code> attribute to monitor the loading process. This
attribute is particularly useful if you don’t care about the details of
</body>
</html>
</pre>
-</section><section id="the-exitstatus-attribute">
<h2 id="the-exitstatus-attribute">The <code>exitStatus</code> attribute</h2>
<p>This read-only attribute is set if the application calls <code>exit(n)</code>,
<code>abort()</code>, or crashes. Since NaCl modules are event handlers, there is no
rely on the <code>exitStatus</code> value being stable in these cases, but the value
may nevertheless be useful for temporary debugging.</li>
</ul>
-</section></section>
+</section>
{{/partials.standard_nacl_article}}