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

Side by Side Diff: native_client_sdk/src/examples/tutorial/load_progress/load_progress.cc

Issue 14607005: [NaCl SDK] Cleanup examples. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 7 years, 7 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
« no previous file with comments | « native_client_sdk/src/examples/tutorial/load_progress/check_browser.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /// @file
6 /// This example demonstrates loading and running a very simple NaCl
7 /// module. To load the NaCl module, the browser first looks for the
8 /// CreateModule() factory method (at the end of this file). It calls
9 /// CreateModule() once to load the module code from your .nexe. After the
10 /// .nexe code is loaded, CreateModule() is not called again.
11 ///
12 /// Once the .nexe code is loaded, the browser then calls the
13 /// LoadProgressModule::CreateInstance()
14 /// method on the object returned by CreateModule(). It calls CreateInstance()
15 /// each time it encounters an <embed> tag that references your NaCl module.
16
17 #include "ppapi/cpp/instance.h" 5 #include "ppapi/cpp/instance.h"
18 #include "ppapi/cpp/module.h" 6 #include "ppapi/cpp/module.h"
19 #include "ppapi/cpp/var.h"
20 7
21 namespace load_progress {
22 /// The Instance class. One of these exists for each instance of your NaCl
23 /// module on the web page. The browser will ask the Module object to create
24 /// a new Instance for each occurrence of the <embed> tag that has these
25 /// attributes:
26 /// <pre>
27 /// type="application/x-nacl"
28 /// nacl="hello_world.nmf"
29 /// </pre>
30 class LoadProgressInstance : public pp::Instance { 8 class LoadProgressInstance : public pp::Instance {
31 public: 9 public:
32 explicit LoadProgressInstance(PP_Instance instance) 10 explicit LoadProgressInstance(PP_Instance instance)
33 : pp::Instance(instance) {} 11 : pp::Instance(instance) {}
34 virtual ~LoadProgressInstance() {} 12 virtual ~LoadProgressInstance() {}
35 }; 13 };
36 14
37 /// The Module class. The browser calls the CreateInstance() method to create
38 /// an instance of your NaCl module on the web page. The browser creates a new
39 /// instance for each <embed> tag with
40 /// <code>type="application/x-nacl"</code>.
41 class LoadProgressModule : public pp::Module { 15 class LoadProgressModule : public pp::Module {
42 public: 16 public:
43 LoadProgressModule() : pp::Module() {} 17 LoadProgressModule() : pp::Module() {}
44 virtual ~LoadProgressModule() {} 18 virtual ~LoadProgressModule() {}
45 19
46 /// Create and return a HelloWorldInstance object.
47 /// @param[in] instance a handle to a plug-in instance.
48 /// @return a newly created HelloWorldInstance.
49 /// @note The browser is responsible for calling @a delete when done.
50 virtual pp::Instance* CreateInstance(PP_Instance instance) { 20 virtual pp::Instance* CreateInstance(PP_Instance instance) {
51 return new LoadProgressInstance(instance); 21 return new LoadProgressInstance(instance);
52 } 22 }
53 }; 23 };
54 } // namespace load_progress
55 24
56 namespace pp { 25 namespace pp {
57 /// Factory function called by the browser when the module is first loaded. 26 Module* CreateModule() { return new LoadProgressModule(); }
58 /// The browser keeps a singleton of this module. It calls the
59 /// CreateInstance() method on the object you return to make instances. There
60 /// is one instance per <embed> tag on the page. This is the main binding
61 /// point for your NaCl module with the browser.
62 /// @return new LoadProgressModule.
63 /// @note The browser is responsible for deleting returned @a Module.
64 Module* CreateModule() { return new load_progress::LoadProgressModule(); }
65 } // namespace pp 27 } // namespace pp
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/tutorial/load_progress/check_browser.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698