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

Side by Side Diff: ppapi/cpp/module.h

Issue 7621019: Missed some items to document here. New documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef PPAPI_CPP_MODULE_H_ 5 #ifndef PPAPI_CPP_MODULE_H_
6 #define PPAPI_CPP_MODULE_H_ 6 #define PPAPI_CPP_MODULE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 18 matching lines...) Expand all
29 class Module { 29 class Module {
30 public: 30 public:
31 typedef std::map<PP_Instance, Instance*> InstanceMap; 31 typedef std::map<PP_Instance, Instance*> InstanceMap;
32 32
33 // You may not call any other PP functions from the constructor, put them 33 // You may not call any other PP functions from the constructor, put them
34 // in Init instead. Various things will not be set up until the constructor 34 // in Init instead. Various things will not be set up until the constructor
35 // completes. 35 // completes.
36 Module(); 36 Module();
37 virtual ~Module(); 37 virtual ~Module();
38 38
39 // Returns the global instance of this module object, or NULL if the module 39 /// Get() returns the global instance of this module object, or NULL if the
40 // is not initialized yet. 40 /// module is not initialized yet.
41 ///
42 /// @return The global instance of the module object.
41 static Module* Get(); 43 static Module* Get();
42 44
43 // This function will be automatically called after the object is created. 45 /// Init() is automatically called after the object is created. This is where
44 // This is where you can put functions that rely on other parts of the API, 46 /// you can put functions that rely on other parts of the API, now that the
45 // now that the module has been created. 47 /// module has been created.
48 ///
49 /// @return True if success, otherwise false.
dmichael (off chromium) 2011/08/11 22:20:50 True->true if->on ? (or success->successful)?
jond 2011/08/12 16:58:18 Done.
jond 2011/08/12 16:58:18 Done.
46 virtual bool Init(); 50 virtual bool Init();
47 51
48 // Returns the internal module handle. 52 /// The <code>pp_module</code> function returns the internal module handle.
dmichael (off chromium) 2011/08/11 22:20:50 Why are you using 'The <code>function_name</code>
jond 2011/08/12 16:58:18 The function name here is lowercase. So, I thought
dmichael (off chromium) 2011/08/12 19:13:55 Okay, that's fine. But it should still be pp_modul
jond 2011/08/12 19:29:24 Actually saying pp_module() function is wrong. Tha
dmichael (off chromium) 2011/08/12 19:42:29 Why? I don't read it 'function function'. All I'm
jond 2011/08/12 19:54:37 I agree. I'll have to change this in several spots
53 ///
54 /// @return A <code>PP_Module</code> internal module handle.
49 PP_Module pp_module() const { return pp_module_; } 55 PP_Module pp_module() const { return pp_module_; }
50 56
51 // Returns the internal get_browser_interface pointer. 57 /// The <code>get_browser_interface</code> the internal get_browser_interface
dmichael (off chromium) 2011/08/11 22:20:50 /// get_browser_interface() returns the internal g
jond 2011/08/12 16:58:18 Done.
52 // TODO(sehr): This should be removed once the NaCl browser plugin no longer 58 /// pointer.
53 // needs it. 59 /// TODO(sehr): This should be removed once the NaCl browser plugin no longer
60 /// needs it.
61 ///
62 /// @return A <code>PPB_GetInterface</code> internal pointer.
54 PPB_GetInterface get_browser_interface() const { 63 PPB_GetInterface get_browser_interface() const {
55 return get_browser_interface_; 64 return get_browser_interface_;
56 } 65 }
57 66
58 // Returns the core interface for doing basic global operations. This is 67 /// The <code>core</code> function returns the core interface for doing basic
dmichael (off chromium) 2011/08/11 22:20:50 core() returns...
jond 2011/08/12 16:58:18 See above. I will talk to Josie about this, but fo
59 // guaranteed to be non-NULL once the module has successfully initialized 68 /// global operations. The return value is guaranteed to be non-NULL once the
60 // and during the Init() call. 69 /// module has successfully initialized and during the Init() call.
61 // 70 ///
62 // It will be NULL before Init() has been called. 71 /// It will be NULL before Init() has been called.
72 ///
73 /// @return The core interface for doing basic global operations.
63 Core* core() { return core_; } 74 Core* core() { return core_; }
64 75
65 // Implements GetInterface for the browser to get plugin interfaces. If you 76 /// GetPluginInterface() implements <code>GetInterface</code> for the browser
66 // need to provide your own implementations of new interfaces, you can use 77 /// to get module interfaces. If you need to provide your own implementations
67 // AddPluginInterface which this function will use. 78 /// of new interfaces, use AddPluginInterface() which this function will use.
79 ///
80 /// @param[in] interface_name The module interface for the browser to get.
68 const void* GetPluginInterface(const char* interface_name); 81 const void* GetPluginInterface(const char* interface_name);
69 82
70 // Returns an interface in the browser. 83 /// GetBrowserInterface() returns an interface in the browser.
dmichael (off chromium) 2011/08/11 22:20:50 I think the original wording is confusing. Maybe:
jond 2011/08/12 16:58:18 Done.
84 ///
85 /// @param[in] interface_name The browser interface for the moduel to get.
71 const void* GetBrowserInterface(const char* interface_name); 86 const void* GetBrowserInterface(const char* interface_name);
72 87
73 // Returns the object associated with this PP_Instance, or NULL if one is 88 /// InstanceForPPInstance() returns the object associated with this
74 // not found. 89 /// <code>PP_Instance</code>, or NULL if one is not found.
90 ///
91 /// @param[in] instance This <code>PP_Instance</code>.
92 ///
93 /// @return The object associated with this <code>PP_Instance</code>,
94 /// or NULL if one is not found.
75 Instance* InstanceForPPInstance(PP_Instance instance); 95 Instance* InstanceForPPInstance(PP_Instance instance);
76 96
77 // Adds a handler for a given interface name. When the browser requests 97 /// AddPluginInterface() adds a handler for a provided interface name. When
78 // that interface name, the given |vtable| will be returned. 98 /// the browser requests that interface name, the provided
79 // 99 /// <code>vtable</code> will be returned.
80 // In general, plugins will not need to call this directly. Instead, the 100 ///
81 // C++ wrappers for each interface will register themselves with this 101 /// In general, modules will not need to call this directly. Instead, the
82 // function. 102 /// C++ wrappers for each interface will register themselves with this
83 // 103 /// function.
84 // This function may be called more than once with the same interface name 104 ///
85 // and vtable with no effect. However, it may not be used to register a 105 /// This function may be called more than once with the same interface name
86 // different vtable for an already-registered interface. It will assert for 106 /// and vtable with no effect. However, it may not be used to register a
87 // a different registration for an already-registered interface in debug 107 /// different vtable for an already-registered interface. It will assert for
88 // mode, and just ignore the registration in release mode. 108 /// a different registration for an already-registered interface in debug
109 /// mode, and just ignore the registration in release mode.
110 ///
111 /// @param[in] interface_name The interface name that will receive a handler.
112 /// @param[in,out] vtable The vtable returned for <code>interface_name</code>.
dmichael (off chromium) 2011/08/11 22:20:50 'returned'->'to return'
jond 2011/08/12 16:58:18 Done.
89 void AddPluginInterface(const std::string& interface_name, 113 void AddPluginInterface(const std::string& interface_name,
90 const void* vtable); 114 const void* vtable);
91 115
92 // Sets the browser interface and calls the regular init function that 116 // InternalInit() sets the browser interface and calls the regular init
dmichael (off chromium) 2011/08/11 22:20:50 init -> Init()
jond 2011/08/12 16:58:18 Done.
93 // can be overridden by the base classes. 117 /// function that can be overridden by the base classes.
94 // 118 ///
95 // TODO(brettw) make this private when I can figure out how to make the 119 /// TODO(brettw) make this private when I can figure out how to make the
96 // initialize function a friend. 120 /// initialize function a friend.
121 ///
122 /// @param[in] mod A <code>PP_Module</code>.
123 /// @param[in] get_browser_interface The browser interface to set.
124 ///
125 /// @return True if successful, otherwise false.
dmichael (off chromium) 2011/08/11 22:20:50 True->true
jond 2011/08/12 16:58:18 Again, I was hoping to start sentences with a capi
dmichael (off chromium) 2011/08/12 19:13:55 When case is important, my opinion is it's much be
jond 2011/08/12 19:29:24 Okay, I'll change that one. On 2011/08/12 19:13:5
dmichael (off chromium) 2011/08/12 19:42:29 Thanks!
97 bool InternalInit(PP_Module mod, 126 bool InternalInit(PP_Module mod,
98 PPB_GetInterface get_browser_interface); 127 PPB_GetInterface get_browser_interface);
99 128
100 // Allows iteration over the current instances in the module. 129 /// The <code>current_instance</code> allows iteration over the current
dmichael (off chromium) 2011/08/11 22:20:50 /// current_instances() allows...
jond 2011/08/12 16:58:18 Done.
jond 2011/08/12 16:58:18 Done.
130 /// instances in the module.
131 ///
132 /// @return An <code>InstanceMap</code> of all instances in the module.
101 const InstanceMap& current_instances() const { return current_instances_; } 133 const InstanceMap& current_instances() const { return current_instances_; }
102 134
103 protected: 135 protected:
104 // Override to create your own plugin type. 136 /// CreateInstance() should be overridden to create your own module type.
137 ///
138 /// @param[in] instance A <code>PP_Instance</code>.
139 ///
140 /// @return The resulting instance.
105 virtual Instance* CreateInstance(PP_Instance instance) = 0; 141 virtual Instance* CreateInstance(PP_Instance instance) = 0;
106 142
107 private: 143 private:
108 friend PP_Bool Instance_DidCreate(PP_Instance pp_instance, 144 friend PP_Bool Instance_DidCreate(PP_Instance pp_instance,
109 uint32_t argc, 145 uint32_t argc,
110 const char* argn[], 146 const char* argn[],
111 const char* argv[]); 147 const char* argv[]);
112 friend void Instance_DidDestroy(PP_Instance instance); 148 friend void Instance_DidDestroy(PP_Instance instance);
113 149
114 // Unimplemented (disallow copy and assign). 150 // Unimplemented (disallow copy and assign).
(...skipping 10 matching lines...) Expand all
125 161
126 // All additional interfaces this plugin can handle as registered by 162 // All additional interfaces this plugin can handle as registered by
127 // AddPluginInterface. 163 // AddPluginInterface.
128 typedef std::map<std::string, const void*> InterfaceMap; 164 typedef std::map<std::string, const void*> InterfaceMap;
129 InterfaceMap additional_interfaces_; 165 InterfaceMap additional_interfaces_;
130 }; 166 };
131 167
132 } // namespace pp 168 } // namespace pp
133 169
134 #endif // PPAPI_CPP_MODULE_H_ 170 #endif // PPAPI_CPP_MODULE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698