Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: native_client_sdk/doc_generated/devguide/tutorial/tutorial-part1.html

Issue 438403003: [NaCl SDK Docs] Only generate one top-level <section> element. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {{+bindTo:partials.standard_nacl_article}} 1 {{+bindTo:partials.standard_nacl_article}}
2 2
3 <section id="c-tutorial-getting-started-part-1"> 3 <section id="c-tutorial-getting-started-part-1">
4 <span id="tutorial"></span><h1 id="c-tutorial-getting-started-part-1"><span id=" tutorial"></span>C++ Tutorial: Getting Started (Part 1)</h1> 4 <span id="tutorial"></span><h1 id="c-tutorial-getting-started-part-1"><span id=" tutorial"></span>C++ Tutorial: Getting Started (Part 1)</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><p class="first"><a class="reference internal" href="#overview" id="id1">Ove rview</a></p> 7 <li><p class="first"><a class="reference internal" href="#overview" id="id1">Ove rview</a></p>
8 <ul class="small-gap"> 8 <ul class="small-gap">
9 <li><a class="reference internal" href="#what-the-application-in-this-tutorial-d oes" id="id2">What the application in this tutorial does</a></li> 9 <li><a class="reference internal" href="#what-the-application-in-this-tutorial-d oes" id="id2">What the application in this tutorial does</a></li>
10 <li><a class="reference internal" href="#communication-between-javascript-and-na tive-client-modules" id="id3">Communication between JavaScript and Native Client modules</a></li> 10 <li><a class="reference internal" href="#communication-between-javascript-and-na tive-client-modules" id="id3">Communication between JavaScript and Native Client modules</a></li>
11 </ul> 11 </ul>
12 </li> 12 </li>
13 <li><a class="reference internal" href="#step-1-download-and-install-the-native- client-sdk" id="id4">Step 1: Download and install the Native Client SDK</a></li> 13 <li><a class="reference internal" href="#step-1-download-and-install-the-native- client-sdk" id="id4">Step 1: Download and install the Native Client SDK</a></li>
14 <li><a class="reference internal" href="#step-2-start-a-local-server" id="id5">S tep 2: Start a local server</a></li> 14 <li><a class="reference internal" href="#step-2-start-a-local-server" id="id5">S tep 2: Start a local server</a></li>
15 <li><a class="reference internal" href="#step-3-set-up-the-chrome-browser" id="i d6">Step 3: Set up the Chrome browser</a></li> 15 <li><a class="reference internal" href="#step-3-set-up-the-chrome-browser" id="i d6">Step 3: Set up the Chrome browser</a></li>
16 <li><a class="reference internal" href="#step-4-stub-code-for-the-tutorial" id=" id7">Step 4: Stub code for the tutorial</a></li> 16 <li><a class="reference internal" href="#step-4-stub-code-for-the-tutorial" id=" id7">Step 4: Stub code for the tutorial</a></li>
17 <li><a class="reference internal" href="#step-5-compile-the-native-client-module -and-run-the-stub-application" id="id8">Step 5: Compile the Native Client module and run the stub application</a></li> 17 <li><a class="reference internal" href="#step-5-compile-the-native-client-module -and-run-the-stub-application" id="id8">Step 5: Compile the Native Client module and run the stub application</a></li>
18 <li><a class="reference internal" href="#step-6-modify-the-javascript-code-to-se nd-a-message-to-the-native-client-module" id="id9">Step 6: Modify the JavaScript code to send a message to the Native Client module</a></li> 18 <li><a class="reference internal" href="#step-6-modify-the-javascript-code-to-se nd-a-message-to-the-native-client-module" id="id9">Step 6: Modify the JavaScript code to send a message to the Native Client module</a></li>
19 <li><a class="reference internal" href="#step-7-implement-a-message-handler-in-t he-native-client-module" id="id10">Step 7: Implement a message handler in the Na tive Client module</a></li> 19 <li><a class="reference internal" href="#step-7-implement-a-message-handler-in-t he-native-client-module" id="id10">Step 7: Implement a message handler in the Na tive Client module</a></li>
20 <li><a class="reference internal" href="#step-8-compile-the-native-client-module -and-run-the-application-again" id="id11">Step 8: Compile the Native Client modu le and run the application again</a></li> 20 <li><a class="reference internal" href="#step-8-compile-the-native-client-module -and-run-the-application-again" id="id11">Step 8: Compile the Native Client modu le and run the application again</a></li>
21 <li><a class="reference internal" href="#troubleshooting" id="id12">Troubleshoot ing</a></li> 21 <li><a class="reference internal" href="#troubleshooting" id="id12">Troubleshoot ing</a></li>
22 <li><a class="reference internal" href="#next-steps" id="id13">Next steps</a></l i> 22 <li><a class="reference internal" href="#next-steps" id="id13">Next steps</a></l i>
23 </ul> 23 </ul>
24 24
25 </div><section id="overview"> 25 </div><h2 id="overview">Overview</h2>
26 <h2 id="overview">Overview</h2>
27 <p>This tutorial shows how to build and run a web application using Portable Nat ive 26 <p>This tutorial shows how to build and run a web application using Portable Nat ive
28 Client (PNaCl). This is a client-side application that uses HTML, JavaScript and 27 Client (PNaCl). This is a client-side application that uses HTML, JavaScript and
29 a Native Client module written in C++. The PNaCl toolchain is used to enable 28 a Native Client module written in C++. The PNaCl toolchain is used to enable
30 running the Native Client module directly from a web page.</p> 29 running the Native Client module directly from a web page.</p>
31 <p>It&#8217;s recommended to read the <a class="reference internal" href="/nativ e-client/overview.html"><em>Native Client Technical Overview</em></a> prior to g oing through this tutorial.</p> 30 <p>It&#8217;s recommended to read the <a class="reference internal" href="/nativ e-client/overview.html"><em>Native Client Technical Overview</em></a> prior to g oing through this tutorial.</p>
32 <section id="what-the-application-in-this-tutorial-does">
33 <h3 id="what-the-application-in-this-tutorial-does">What the application in this tutorial does</h3> 31 <h3 id="what-the-application-in-this-tutorial-does">What the application in this tutorial does</h3>
34 <p>The application in this tutorial shows how to load a Native Client module in a 32 <p>The application in this tutorial shows how to load a Native Client module in a
35 web page, and how to send messages between JavaScript and the C++ code in the 33 web page, and how to send messages between JavaScript and the C++ code in the
36 Native Client module. In this simple application, the JavaScript code in the web 34 Native Client module. In this simple application, the JavaScript code in the web
37 page sends a <code>'hello'</code> message to the Native Client module. When the Native 35 page sends a <code>'hello'</code> message to the Native Client module. When the Native
38 Client module receives a message, it checks whether the message is equal to the 36 Client module receives a message, it checks whether the message is equal to the
39 string <code>'hello'</code>. If it is, the Native Client module returns a messag e saying 37 string <code>'hello'</code>. If it is, the Native Client module returns a messag e saying
40 <code>'hello from NaCl'</code>. A JavaScript alert panel displays the message re ceived 38 <code>'hello from NaCl'</code>. A JavaScript alert panel displays the message re ceived
41 from the Native Client module.</p> 39 from the Native Client module.</p>
42 </section><section id="communication-between-javascript-and-native-client-module s">
43 <h3 id="communication-between-javascript-and-native-client-modules">Communicatio n between JavaScript and Native Client modules</h3> 40 <h3 id="communication-between-javascript-and-native-client-modules">Communicatio n between JavaScript and Native Client modules</h3>
44 <p>The Native Client programming model supports bidirectional communication betw een 41 <p>The Native Client programming model supports bidirectional communication betw een
45 JavaScript and the Native Client module (C/C++ code). Both sides can initiate 42 JavaScript and the Native Client module (C/C++ code). Both sides can initiate
46 and respond to messages. In all cases, the communication is asynchronous: The 43 and respond to messages. In all cases, the communication is asynchronous: The
47 caller (JavaScript or the Native Client module) sends a message, but the caller 44 caller (JavaScript or the Native Client module) sends a message, but the caller
48 does not wait for, or may not even expect, a response. This behavior is 45 does not wait for, or may not even expect, a response. This behavior is
49 analogous to client/server communication on the web, where the client posts a 46 analogous to client/server communication on the web, where the client posts a
50 message to the server and returns immediately. The Native Client messaging 47 message to the server and returns immediately. The Native Client messaging
51 system is part of the Pepper API, and is described in detail in 48 system is part of the Pepper API, and is described in detail in
52 <a class="reference internal" href="/native-client/devguide/coding/message-syste m.html"><em>Developer&#8217;s Guide: Messaging System</em></a>. 49 <a class="reference internal" href="/native-client/devguide/coding/message-syste m.html"><em>Developer&#8217;s Guide: Messaging System</em></a>.
53 It is also similar to the way <a class="reference external" href="http://en.wiki pedia.org/wiki/Web_worker">web workers</a> interact with the main document in 50 It is also similar to the way <a class="reference external" href="http://en.wiki pedia.org/wiki/Web_worker">web workers</a> interact with the main document in
54 JavaScript.</p> 51 JavaScript.</p>
55 </section></section><section id="step-1-download-and-install-the-native-client-s dk">
56 <h2 id="step-1-download-and-install-the-native-client-sdk">Step 1: Download and install the Native Client SDK</h2> 52 <h2 id="step-1-download-and-install-the-native-client-sdk">Step 1: Download and install the Native Client SDK</h2>
57 <p>Follow the instructions on the <a class="reference internal" href="/native-cl ient/sdk/download.html"><em>Download</em></a> page to 53 <p>Follow the instructions on the <a class="reference internal" href="/native-cl ient/sdk/download.html"><em>Download</em></a> page to
58 download and install the Native Client SDK.</p> 54 download and install the Native Client SDK.</p>
59 </section><section id="step-2-start-a-local-server"> 55 <h2 id="step-2-start-a-local-server"><span id="tutorial-step-2"></span>Step 2: S tart a local server</h2>
60 <span id="tutorial-step-2"></span><h2 id="step-2-start-a-local-server"><span id= "tutorial-step-2"></span>Step 2: Start a local server</h2>
61 <p>To simulate a production environment, the SDK provides a simple web server th at 56 <p>To simulate a production environment, the SDK provides a simple web server th at
62 can be used to serve the application on <code>localhost</code>. A convenience Ma kefile 57 can be used to serve the application on <code>localhost</code>. A convenience Ma kefile
63 rule called <code>serve</code> is the easiest way to invoke it:</p> 58 rule called <code>serve</code> is the easiest way to invoke it:</p>
64 <pre> 59 <pre>
65 $ cd pepper_$(VERSION)/getting_started 60 $ cd pepper_$(VERSION)/getting_started
66 $ make serve 61 $ make serve
67 </pre> 62 </pre>
68 <aside class="note"> 63 <aside class="note">
69 The SDK may consist of several &#8220;bundles&#8221;, one per Chrome/Pepper vers ion (see 64 The SDK may consist of several &#8220;bundles&#8221;, one per Chrome/Pepper vers ion (see
70 <a class="reference internal" href="/native-client/version.html"><em>versioning information</em></a>). In the sample invocation above 65 <a class="reference internal" href="/native-client/version.html"><em>versioning information</em></a>). In the sample invocation above
71 <code>pepper_$(VERSION)</code> refers to the specific version you want to use. F or 66 <code>pepper_$(VERSION)</code> refers to the specific version you want to use. F or
72 example, <code>pepper_31</code>. If you don&#8217;t know which version you need, use the 67 example, <code>pepper_31</code>. If you don&#8217;t know which version you need, use the
73 one labeled <code>(stable)</code> by <code>naclsdk list</code>. See <a class="re ference internal" href="/native-client/sdk/download.html"><em>Download the Nativ e 68 one labeled <code>(stable)</code> by <code>naclsdk list</code>. See <a class="re ference internal" href="/native-client/sdk/download.html"><em>Download the Nativ e
74 Client SDK</em></a> for more details. 69 Client SDK</em></a> for more details.
75 </aside> 70 </aside>
76 <p>If no port number is specified, the server defaults to port 5103, and can be 71 <p>If no port number is specified, the server defaults to port 5103, and can be
77 accessed at <code>http://localhost:5103</code>.</p> 72 accessed at <code>http://localhost:5103</code>.</p>
78 <p>Any server can be used for the purpose of development. The one provided with the 73 <p>Any server can be used for the purpose of development. The one provided with the
79 SDK is just a convenience, not a requirement.</p> 74 SDK is just a convenience, not a requirement.</p>
80 </section><section id="step-3-set-up-the-chrome-browser"> 75 <h2 id="step-3-set-up-the-chrome-browser"><span id="tutorial-step-3"></span>Step 3: Set up the Chrome browser</h2>
81 <span id="tutorial-step-3"></span><h2 id="step-3-set-up-the-chrome-browser"><spa n id="tutorial-step-3"></span>Step 3: Set up the Chrome browser</h2>
82 <p>PNaCl is enabled by default in Chrome version 31 and later. Please make sure 76 <p>PNaCl is enabled by default in Chrome version 31 and later. Please make sure
83 that you have a suitable version to work through this tutorial. It&#8217;s also 77 that you have a suitable version to work through this tutorial. It&#8217;s also
84 important to use a Chrome version that&#8217;s the same or newer than the SDK bu ndle 78 important to use a Chrome version that&#8217;s the same or newer than the SDK bu ndle
85 used to build the Native Client modules.</p> 79 used to build the Native Client modules.</p>
86 <aside class="note"> 80 <aside class="note">
87 To find out the version of Chrome, type <code>about:chrome</code> in the address bar. 81 To find out the version of Chrome, type <code>about:chrome</code> in the address bar.
88 </aside> 82 </aside>
89 <p>For a better development experience, it&#8217;s also recommended to disable t he 83 <p>For a better development experience, it&#8217;s also recommended to disable t he
90 Chrome cache. Chrome caches resources aggressively; disabling the cache helps 84 Chrome cache. Chrome caches resources aggressively; disabling the cache helps
91 make sure that the latest version of the Native Client module is loaded during 85 make sure that the latest version of the Native Client module is loaded during
92 development.</p> 86 development.</p>
93 <ul class="small-gap"> 87 <ul class="small-gap">
94 <li>Open Chrome&#8217;s developer tools by clicking the menu icon <img alt="menu -icon" src="/native-client/images/menu-icon.png" /> and 88 <li>Open Chrome&#8217;s developer tools by clicking the menu icon <img alt="menu -icon" src="/native-client/images/menu-icon.png" /> and
95 choosing <code>Tools &gt; Developer tools</code>.</li> 89 choosing <code>Tools &gt; Developer tools</code>.</li>
96 <li>Click the gear icon <img alt="gear-icon" src="/native-client/images/gear-ico n.png" /> in the bottom right corner of the Chrome 90 <li>Click the gear icon <img alt="gear-icon" src="/native-client/images/gear-ico n.png" /> in the bottom right corner of the Chrome
97 window.</li> 91 window.</li>
98 <li>Under the &#8220;General&#8221; settings, check the box next to &#8220;Disab le cache (while 92 <li>Under the &#8220;General&#8221; settings, check the box next to &#8220;Disab le cache (while
99 DevTools is open)&#8221;.</li> 93 DevTools is open)&#8221;.</li>
100 <li>Keep the Developer Tools pane open while developing Native Client 94 <li>Keep the Developer Tools pane open while developing Native Client
101 applications.</li> 95 applications.</li>
102 </ul> 96 </ul>
103 </section><section id="step-4-stub-code-for-the-tutorial">
104 <h2 id="step-4-stub-code-for-the-tutorial">Step 4: Stub code for the tutorial</h 2> 97 <h2 id="step-4-stub-code-for-the-tutorial">Step 4: Stub code for the tutorial</h 2>
105 <p>The stub code for the tutorial is avalable in the SDK, in 98 <p>The stub code for the tutorial is avalable in the SDK, in
106 <code>pepper_$(VERSION)/getting_started/part1</code>. It contains the following files:</p> 99 <code>pepper_$(VERSION)/getting_started/part1</code>. It contains the following files:</p>
107 <ul class="small-gap"> 100 <ul class="small-gap">
108 <li><p class="first"><code>index.html</code>: Contains the HTML layout of the pa ge as well as the JavaScript 101 <li><p class="first"><code>index.html</code>: Contains the HTML layout of the pa ge as well as the JavaScript
109 code that interacts with the Native Client module.</p> 102 code that interacts with the Native Client module.</p>
110 <p>The Native Client module is included in the page with an <code>&lt;embed&gt;< /code> tag that 103 <p>The Native Client module is included in the page with an <code>&lt;embed&gt;< /code> tag that
111 points to a manifest file.</p> 104 points to a manifest file.</p>
112 </li> 105 </li>
113 <li><code>hello_tutorial.nmf</code>: A manifest file that&#8217;s used to point the HTML to the 106 <li><code>hello_tutorial.nmf</code>: A manifest file that&#8217;s used to point the HTML to the
114 Native Client module and optionally provide additional commands to the PNaCl 107 Native Client module and optionally provide additional commands to the PNaCl
115 translator that is part of the Chrome browser.</li> 108 translator that is part of the Chrome browser.</li>
116 <li><code>hello_tutorial.cc</code>: C++ code for a simple Native Client module.< /li> 109 <li><code>hello_tutorial.cc</code>: C++ code for a simple Native Client module.< /li>
117 <li><code>Makefile</code>: Compilation commands to build the <strong>pexe</stron g> (portable executable) 110 <li><code>Makefile</code>: Compilation commands to build the <strong>pexe</stron g> (portable executable)
118 from the C++ code in <code>hello_tutorial.cc</code>.</li> 111 from the C++ code in <code>hello_tutorial.cc</code>.</li>
119 </ul> 112 </ul>
120 <p>It&#8217;s a good idea to take a look at these files now&#8212;they contain a large amount 113 <p>It&#8217;s a good idea to take a look at these files now&#8212;they contain a large amount
121 of comments that help explain their structure and contents. For more details 114 of comments that help explain their structure and contents. For more details
122 on the structure of a typical Native Client application, see 115 on the structure of a typical Native Client application, see
123 <a class="reference internal" href="/native-client/devguide/coding/application-s tructure.html"><em>Application Structure</em></a>.</p> 116 <a class="reference internal" href="/native-client/devguide/coding/application-s tructure.html"><em>Application Structure</em></a>.</p>
124 <p>The stub code is intentionally very minimal. The C++ code does not do anythin g 117 <p>The stub code is intentionally very minimal. The C++ code does not do anythin g
125 except correctly initialize itself. The JavaScript code waits for the Native 118 except correctly initialize itself. The JavaScript code waits for the Native
126 Client module to load and changes the status text on the web page accordingly.</ p> 119 Client module to load and changes the status text on the web page accordingly.</ p>
127 </section><section id="step-5-compile-the-native-client-module-and-run-the-stub- application"> 120 <h2 id="step-5-compile-the-native-client-module-and-run-the-stub-application"><s pan id="tutorial-step-5"></span>Step 5: Compile the Native Client module and run the stub application</h2>
128 <span id="tutorial-step-5"></span><h2 id="step-5-compile-the-native-client-modul e-and-run-the-stub-application"><span id="tutorial-step-5"></span>Step 5: Compil e the Native Client module and run the stub application</h2>
129 <p>To compile the Native Client module, run <code>make</code>:</p> 121 <p>To compile the Native Client module, run <code>make</code>:</p>
130 <pre> 122 <pre>
131 $ cd pepper_$(VERSION)/getting_started/part1 123 $ cd pepper_$(VERSION)/getting_started/part1
132 $ make 124 $ make
133 </pre> 125 </pre>
134 <p>Since the sample is located within the SDK tree, the Makefile knows how to fi nd 126 <p>Since the sample is located within the SDK tree, the Makefile knows how to fi nd
135 the PNaCl toolchain automatically and use it to build the module. If you&#8217;r e 127 the PNaCl toolchain automatically and use it to build the module. If you&#8217;r e
136 building applications outside the NaCl SDK tree, you should set the 128 building applications outside the NaCl SDK tree, you should set the
137 <code>$NACL_SDK_ROOT</code> environment variable. See <a class="reference intern al" href="/native-client/devguide/devcycle/building.html"><em>Building Native Cl ient 129 <code>$NACL_SDK_ROOT</code> environment variable. See <a class="reference intern al" href="/native-client/devguide/devcycle/building.html"><em>Building Native Cl ient
138 Modules</em></a> for more details.</p> 130 Modules</em></a> for more details.</p>
139 <p>Assuming the local server was started according to the instructions in 131 <p>Assuming the local server was started according to the instructions in
140 <a class="reference internal" href="#tutorial-step-2"><em>Step 2</em></a>, you c an now load the sample by pointing Chrome 132 <a class="reference internal" href="#tutorial-step-2"><em>Step 2</em></a>, you c an now load the sample by pointing Chrome
141 to <code>http://localhost:5103/part1</code>. Chrome should load the Native Clien t module 133 to <code>http://localhost:5103/part1</code>. Chrome should load the Native Clien t module
142 successfully and the Status text should change from &#8220;LOADING...&#8221; to &#8220;SUCCESS&#8221;. 134 successfully and the Status text should change from &#8220;LOADING...&#8221; to &#8220;SUCCESS&#8221;.
143 If you run into problems, check out the <a class="reference internal" href="#tut orial-troubleshooting"><em>Troubleshooting section</em></a> below.</p> 135 If you run into problems, check out the <a class="reference internal" href="#tut orial-troubleshooting"><em>Troubleshooting section</em></a> below.</p>
144 </section><section id="step-6-modify-the-javascript-code-to-send-a-message-to-th e-native-client-module">
145 <h2 id="step-6-modify-the-javascript-code-to-send-a-message-to-the-native-client -module">Step 6: Modify the JavaScript code to send a message to the Native Clie nt module</h2> 136 <h2 id="step-6-modify-the-javascript-code-to-send-a-message-to-the-native-client -module">Step 6: Modify the JavaScript code to send a message to the Native Clie nt module</h2>
146 <p>In this step, you&#8217;ll modify the web page (<code>index.html</code>) to s end a message to 137 <p>In this step, you&#8217;ll modify the web page (<code>index.html</code>) to s end a message to
147 the Native Client module after the page loads the module.</p> 138 the Native Client module after the page loads the module.</p>
148 <p>Look for the JavaScript function <code>moduleDidLoad()</code>, and add new co de to send 139 <p>Look for the JavaScript function <code>moduleDidLoad()</code>, and add new co de to send
149 a &#8216;hello&#8217; message to the module. The new function should look as fol lows:</p> 140 a &#8216;hello&#8217; message to the module. The new function should look as fol lows:</p>
150 <pre class="prettyprint"> 141 <pre class="prettyprint">
151 function moduleDidLoad() { 142 function moduleDidLoad() {
152 HelloTutorialModule = document.getElementById('hello_tutorial'); 143 HelloTutorialModule = document.getElementById('hello_tutorial');
153 updateStatus('SUCCESS'); 144 updateStatus('SUCCESS');
154 // Send a message to the Native Client module 145 // Send a message to the Native Client module
155 HelloTutorialModule.postMessage('hello'); 146 HelloTutorialModule.postMessage('hello');
156 } 147 }
157 </pre> 148 </pre>
158 </section><section id="step-7-implement-a-message-handler-in-the-native-client-m odule">
159 <h2 id="step-7-implement-a-message-handler-in-the-native-client-module">Step 7: Implement a message handler in the Native Client module</h2> 149 <h2 id="step-7-implement-a-message-handler-in-the-native-client-module">Step 7: Implement a message handler in the Native Client module</h2>
160 <p>In this step, you&#8217;ll modify the Native Client module (<code>hello_tutor ial.cc</code>) to 150 <p>In this step, you&#8217;ll modify the Native Client module (<code>hello_tutor ial.cc</code>) to
161 respond to the message received from the JavaScript code in the application. 151 respond to the message received from the JavaScript code in the application.
162 Specifically, you&#8217;ll:</p> 152 Specifically, you&#8217;ll:</p>
163 <ul class="small-gap"> 153 <ul class="small-gap">
164 <li>Implement the <code>HandleMessage()</code> member function of the module ins tance.</li> 154 <li>Implement the <code>HandleMessage()</code> member function of the module ins tance.</li>
165 <li>Use the <code>PostMessage()</code> member function to send a message from th e module to 155 <li>Use the <code>PostMessage()</code> member function to send a message from th e module to
166 the JavaScript code.</li> 156 the JavaScript code.</li>
167 </ul> 157 </ul>
168 <p>First, add code to define the variables used by the Native Client module (the 158 <p>First, add code to define the variables used by the Native Client module (the
(...skipping 24 matching lines...) Expand all
193 if (message == kHelloString) { 183 if (message == kHelloString) {
194 var_reply = pp::Var(kReplyString); 184 var_reply = pp::Var(kReplyString);
195 PostMessage(var_reply); 185 PostMessage(var_reply);
196 } 186 }
197 } 187 }
198 </pre> 188 </pre>
199 <p>See the Pepper API documentation for additional information about the 189 <p>See the Pepper API documentation for additional information about the
200 <a class="reference external" href="/native-client/pepper_stable/cpp/classpp_1_1 _instance.html#a5dce8c8b36b1df7cfcc12e42397a35e8">pp::Instance.HandleMessage</a> 190 <a class="reference external" href="/native-client/pepper_stable/cpp/classpp_1_1 _instance.html#a5dce8c8b36b1df7cfcc12e42397a35e8">pp::Instance.HandleMessage</a>
201 and <a class="reference external" href="/native-client/pepper_stable/cpp/classpp _1_1_instance.html#a67e888a4e4e23effe7a09625e73ecae9">pp::Instance.PostMessage</ a> 191 and <a class="reference external" href="/native-client/pepper_stable/cpp/classpp _1_1_instance.html#a67e888a4e4e23effe7a09625e73ecae9">pp::Instance.PostMessage</ a>
202 member functions.</p> 192 member functions.</p>
203 </section><section id="step-8-compile-the-native-client-module-and-run-the-appli cation-again">
204 <h2 id="step-8-compile-the-native-client-module-and-run-the-application-again">S tep 8: Compile the Native Client module and run the application again</h2> 193 <h2 id="step-8-compile-the-native-client-module-and-run-the-application-again">S tep 8: Compile the Native Client module and run the application again</h2>
205 <p>Compile the Native Client module by running the <code>make</code> command aga in.</p> 194 <p>Compile the Native Client module by running the <code>make</code> command aga in.</p>
206 <p>Re-run the application by reloading <code>http://localhost:5103/part1</code> in Chrome.</p> 195 <p>Re-run the application by reloading <code>http://localhost:5103/part1</code> in Chrome.</p>
207 <p>After Chrome loads the Native Client module, you should see an alert panel 196 <p>After Chrome loads the Native Client module, you should see an alert panel
208 appear with the message sent from the module.</p> 197 appear with the message sent from the module.</p>
209 </section><section id="troubleshooting"> 198 <h2 id="troubleshooting"><span id="tutorial-troubleshooting"></span>Troubleshoot ing</h2>
210 <span id="tutorial-troubleshooting"></span><h2 id="troubleshooting"><span id="tu torial-troubleshooting"></span>Troubleshooting</h2>
211 <p>If your application doesn&#8217;t run, see <a class="reference internal" href ="#tutorial-step-3"><em>Step 3</em></a> above to 199 <p>If your application doesn&#8217;t run, see <a class="reference internal" href ="#tutorial-step-3"><em>Step 3</em></a> above to
212 verify that you&#8217;ve set up your environment correctly, including both the C hrome 200 verify that you&#8217;ve set up your environment correctly, including both the C hrome
213 browser and the local server. Make sure that you&#8217;re running a correct vers ion of 201 browser and the local server. Make sure that you&#8217;re running a correct vers ion of
214 Chrome, which is also greater or equal than the SDK bundle version you are 202 Chrome, which is also greater or equal than the SDK bundle version you are
215 using.</p> 203 using.</p>
216 <p>Another useful debugging aid is the Chrome JavaScript console (available via the 204 <p>Another useful debugging aid is the Chrome JavaScript console (available via the
217 <code>Tools</code> menu in Chrome). Examine it for clues about what went wrong. For 205 <code>Tools</code> menu in Chrome). Examine it for clues about what went wrong. For
218 example, if there&#8217;s a message saying &#8220;NaCl module crashed&#8221;, th ere is a 206 example, if there&#8217;s a message saying &#8220;NaCl module crashed&#8221;, th ere is a
219 possibility that the Native Client module has a bug; <a class="reference interna l" href="/native-client/devguide/devcycle/debugging.html"><em>debugging</em></a> may be required.</p> 207 possibility that the Native Client module has a bug; <a class="reference interna l" href="/native-client/devguide/devcycle/debugging.html"><em>debugging</em></a> may be required.</p>
220 <p>There&#8217;s more information about troubleshooting in the documentation:</p > 208 <p>There&#8217;s more information about troubleshooting in the documentation:</p >
221 <ul class="small-gap"> 209 <ul class="small-gap">
222 <li><a class="reference internal" href="/native-client/faq.html#faq-troubleshoot ing"><em>FAQ Troubleshooting</em></a>.</li> 210 <li><a class="reference internal" href="/native-client/faq.html#faq-troubleshoot ing"><em>FAQ Troubleshooting</em></a>.</li>
223 <li>The <a class="reference internal" href="/native-client/devguide/coding/progr ess-events.html"><em>Progress Events</em></a> document 211 <li>The <a class="reference internal" href="/native-client/devguide/coding/progr ess-events.html"><em>Progress Events</em></a> document
224 contains some useful information about handling error events.</li> 212 contains some useful information about handling error events.</li>
225 </ul> 213 </ul>
226 </section><section id="next-steps">
227 <h2 id="next-steps">Next steps</h2> 214 <h2 id="next-steps">Next steps</h2>
228 <ul class="small-gap"> 215 <ul class="small-gap">
229 <li>See the <a class="reference internal" href="/native-client/devguide/coding/a pplication-structure.html"><em>Application Structure</em></a> 216 <li>See the <a class="reference internal" href="/native-client/devguide/coding/a pplication-structure.html"><em>Application Structure</em></a>
230 chapter in the Developer&#8217;s Guide for information about how to structure a 217 chapter in the Developer&#8217;s Guide for information about how to structure a
231 Native Client module.</li> 218 Native Client module.</li>
232 <li>Check the <a class="reference external" href="/native-client/pepper_stable/c pp">C++ Reference</a> for details 219 <li>Check the <a class="reference external" href="/native-client/pepper_stable/c pp">C++ Reference</a> for details
233 about how to use the Pepper APIs.</li> 220 about how to use the Pepper APIs.</li>
234 <li>Browse through the source code of the SDK examples (in the <code>examples</c ode> 221 <li>Browse through the source code of the SDK examples (in the <code>examples</c ode>
235 directory) to learn additional techniques for writing Native Client 222 directory) to learn additional techniques for writing Native Client
236 applications and using the Pepper APIs.</li> 223 applications and using the Pepper APIs.</li>
237 <li>See the <a class="reference internal" href="/native-client/devguide/devcycle /building.html"><em>Building</em></a>, <a class="reference internal" href="/nati ve-client/devguide/devcycle/running.html"><em>Running</em></a>, and <a class="re ference internal" href="/native-client/devguide/devcycle/debugging.html"><em>Deb ugging pages</em></a> for information about how to build, run, and 224 <li>See the <a class="reference internal" href="/native-client/devguide/devcycle /building.html"><em>Building</em></a>, <a class="reference internal" href="/nati ve-client/devguide/devcycle/running.html"><em>Running</em></a>, and <a class="re ference internal" href="/native-client/devguide/devcycle/debugging.html"><em>Deb ugging pages</em></a> for information about how to build, run, and
238 debug Native Client applications.</li> 225 debug Native Client applications.</li>
239 <li>Check the <a class="reference external" href="http://code.google.com/p/naclp orts/">naclports</a> project to see 226 <li>Check the <a class="reference external" href="http://code.google.com/p/naclp orts/">naclports</a> project to see
240 what libraries have been ported for use with Native Client. If you port an 227 what libraries have been ported for use with Native Client. If you port an
241 open-source library for your own use, we recommend adding it to naclports 228 open-source library for your own use, we recommend adding it to naclports
242 (see <a class="reference external" href="http://code.google.com/p/naclports/wiki /HowTo_Checkin">How to check code into naclports</a>).</li> 229 (see <a class="reference external" href="http://code.google.com/p/naclports/wiki /HowTo_Checkin">How to check code into naclports</a>).</li>
243 </ul> 230 </ul>
244 </section></section> 231 </section>
245 232
246 {{/partials.standard_nacl_article}} 233 {{/partials.standard_nacl_article}}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698