diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 23:51:10 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-07 23:51:10 +0000 |
commit | 038687dc0399a3228985fc168e12015aaba25798 (patch) | |
tree | 856182760b08d3a8c517096771f733bb8e335d1c /native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc | |
parent | bb3ce678a5f19ef41a98e0979b850c4ab799d944 (diff) | |
download | chromium_src-038687dc0399a3228985fc168e12015aaba25798.zip chromium_src-038687dc0399a3228985fc168e12015aaba25798.tar.gz chromium_src-038687dc0399a3228985fc168e12015aaba25798.tar.bz2 |
[NaCl SDK] Cleanup examples.
* Remove duplicated comments.
* Rename main .cc/.c file to the name of the example.
* Remove _module.cc files
BUG=none
R=noelallen@chromium.org
Review URL: https://codereview.chromium.org/14607005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc')
-rw-r--r-- | native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc b/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc index 90a59fd..7d13a10 100644 --- a/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc +++ b/native_client_sdk/src/examples/tutorial/dlopen/dlopen.cc @@ -2,19 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/// @file -/// This example demonstrates building a dynamic library which is loaded by the -/// NaCl module. To load the NaCl module, the browser first looks for the -/// CreateModule() factory method (at the end of this file). It calls -/// CreateModule() once to load the module code from your .nexe. After the -/// .nexe code is loaded, CreateModule() is not called again. -/// -/// Once the .nexe code is loaded, the browser then calls the CreateInstance() -/// method on the object returned by CreateModule(). If the CreateInstance -/// returns successfully, then Init function is called, which will load the -/// shared object on a worker thread. We use a worker because dlopen is -/// a blocking call, which is not allowed on the main thread. - #include <dlfcn.h> #include <pthread.h> #include <stdio.h> @@ -40,9 +27,9 @@ #define STRINGIFY(x) #x #define NACL_ARCH_STRING XSTRINGIFY(NACL_ARCH) -class DlopenInstance : public pp::Instance { +class DlOpenInstance : public pp::Instance { public: - explicit DlopenInstance(PP_Instance instance) + explicit DlOpenInstance(PP_Instance instance) : pp::Instance(instance), eightball_so_(NULL), reverse_so_(NULL), @@ -50,8 +37,7 @@ class DlopenInstance : public pp::Instance { reverse_(NULL), tid_(NULL) {} - virtual ~DlopenInstance() {} - ; + virtual ~DlOpenInstance() {} // Helper function to post a message back to the JS and stdout functions. void logmsg(const char* pStr) { @@ -167,13 +153,13 @@ class DlopenInstance : public pp::Instance { } static void* LoadLibrariesOnWorker(void* pInst) { - DlopenInstance* inst = static_cast<DlopenInstance*>(pInst); + DlOpenInstance* inst = static_cast<DlOpenInstance*>(pInst); inst->LoadLibrary(); return NULL; } static void LoadDoneCB(void* pInst, int32_t result) { - DlopenInstance* inst = static_cast<DlopenInstance*>(pInst); + DlOpenInstance* inst = static_cast<DlOpenInstance*>(pInst); inst->UseLibrary(); } @@ -185,25 +171,17 @@ class DlopenInstance : public pp::Instance { pthread_t tid_; }; -// The Module class. The browser calls the CreateInstance() method to create -// an instance of your NaCl module on the web page. The browser creates a new -// instance for each <embed> tag with type="application/x-nacl". -class dlOpenModule : public pp::Module { +class DlOpenModule : public pp::Module { public: - dlOpenModule() : pp::Module() {} - virtual ~dlOpenModule() {} + DlOpenModule() : pp::Module() {} + virtual ~DlOpenModule() {} - // Create and return a DlopenInstance object. + // Create and return a DlOpenInstance object. virtual pp::Instance* CreateInstance(PP_Instance instance) { - return new DlopenInstance(instance); + return new DlOpenInstance(instance); } }; -// Factory function called by the browser when the module is first loaded. -// The browser keeps a singleton of this module. It calls the -// CreateInstance() method on the object you return to make instances. There -// is one instance per <embed> tag on the page. This is the main binding -// point for your NaCl module with the browser. namespace pp { -Module* CreateModule() { return new dlOpenModule(); } +Module* CreateModule() { return new DlOpenModule(); } } // namespace pp |