OLD | NEW |
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 | 5 /// @file |
6 /// This example demonstrates building a dynamic library which is loaded by the | 6 /// This example demonstrates building a dynamic library which is loaded by the |
7 /// NaCl module. To load the NaCl module, the browser first looks for the | 7 /// NaCl module. To load the NaCl module, the browser first looks for the |
8 /// CreateModule() factory method (at the end of this file). It calls | 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 | 9 /// CreateModule() once to load the module code from your .nexe. After the |
10 /// .nexe code is loaded, CreateModule() is not called again. | 10 /// .nexe code is loaded, CreateModule() is not called again. |
11 /// | 11 /// |
12 /// Once the .nexe code is loaded, the browser then calls the CreateInstance() | 12 /// Once the .nexe code is loaded, the browser then calls the CreateInstance() |
13 /// method on the object returned by CreateModule(). If the CreateInstance | 13 /// method on the object returned by CreateModule(). If the CreateInstance |
14 /// returns successfully, then Init function is called, which will load the | 14 /// returns successfully, then Init function is called, which will load the |
15 /// shared object on a worker thread. We use a worker because dlopen is | 15 /// shared object on a worker thread. We use a worker because dlopen is |
16 /// a blocking call, which is not alowed on the main thread. | 16 /// a blocking call, which is not allowed on the main thread. |
17 | 17 |
18 #include <dlfcn.h> | 18 #include <dlfcn.h> |
19 #include <pthread.h> | 19 #include <pthread.h> |
20 #include <stdio.h> | 20 #include <stdio.h> |
21 #include <stdlib.h> | 21 #include <stdlib.h> |
22 #include <string.h> | 22 #include <string.h> |
23 | 23 |
24 #include <ppapi/cpp/completion_callback.h> | 24 #include <ppapi/cpp/completion_callback.h> |
25 #include <ppapi/cpp/instance.h> | 25 #include <ppapi/cpp/instance.h> |
26 #include <ppapi/cpp/module.h> | 26 #include <ppapi/cpp/module.h> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // The browser keeps a singleton of this module. It calls the | 193 // The browser keeps a singleton of this module. It calls the |
194 // CreateInstance() method on the object you return to make instances. There | 194 // CreateInstance() method on the object you return to make instances. There |
195 // is one instance per <embed> tag on the page. This is the main binding | 195 // is one instance per <embed> tag on the page. This is the main binding |
196 // point for your NaCl module with the browser. | 196 // point for your NaCl module with the browser. |
197 namespace pp { | 197 namespace pp { |
198 Module* CreateModule() { | 198 Module* CreateModule() { |
199 return new dlOpenModule(); | 199 return new dlOpenModule(); |
200 } | 200 } |
201 } // namespace pp | 201 } // namespace pp |
202 | 202 |
OLD | NEW |