| OLD | NEW |
| 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_INSTANCE_H_ | 5 #ifndef PPAPI_CPP_INSTANCE_H_ |
| 6 #define PPAPI_CPP_INSTANCE_H_ | 6 #define PPAPI_CPP_INSTANCE_H_ |
| 7 | 7 |
| 8 /// @file | 8 /// @file |
| 9 /// Defines the C++ wrapper for an instance. | 9 /// Defines the C++ wrapper for an instance. |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 /// <strong>Note:</strong> This function may be skipped in certain | 59 /// <strong>Note:</strong> This function may be skipped in certain |
| 60 /// call so the instance can perform cleanup-related tasks. Once this function | 60 /// call so the instance can perform cleanup-related tasks. Once this function |
| 61 /// returns, the <code>PP_Instance</code> handle will be invalid. This means | 61 /// returns, the <code>PP_Instance</code> handle will be invalid. This means |
| 62 /// that you can't do any asynchronous operations such as network requests or | 62 /// that you can't do any asynchronous operations such as network requests or |
| 63 /// file writes from this destructor since they will be immediately canceled. | 63 /// file writes from this destructor since they will be immediately canceled. |
| 64 virtual ~Instance(); | 64 virtual ~Instance(); |
| 65 | 65 |
| 66 /// This function returns the <code>PP_Instance</code> identifying this | 66 /// This function returns the <code>PP_Instance</code> identifying this |
| 67 /// object. When using the PPAPI C++ wrappers this is not normally necessary, | 67 /// object. When using the PPAPI C++ wrappers this is not normally necessary, |
| 68 /// but is required when using the lower-level C APIs. | 68 /// but is required when using the lower-level C APIs. |
| 69 /// |
| 70 /// @return A <code>PP_Instance</code> identifying this object. |
| 69 PP_Instance pp_instance() const { return pp_instance_; } | 71 PP_Instance pp_instance() const { return pp_instance_; } |
| 70 | 72 |
| 71 /// Init() initializes this instance with the provided arguments. This | 73 /// Init() initializes this instance with the provided arguments. This |
| 72 /// function will be called immediately after the instance object is | 74 /// function will be called immediately after the instance object is |
| 73 /// constructed. | 75 /// constructed. |
| 74 /// | 76 /// |
| 75 /// @param[in] argc The number of arguments contained in <code>argn</code> | 77 /// @param[in] argc The number of arguments contained in <code>argn</code> |
| 76 /// and <code>argv</code>. | 78 /// and <code>argv</code>. |
| 77 /// | 79 /// |
| 78 /// @param[in] argn An array of argument names. These argument names are | 80 /// @param[in] argn An array of argument names. These argument names are |
| 79 /// supplied in the \<embed\> tag, for example: | 81 /// supplied in the \<embed\> tag, for example: |
| 80 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two | 82 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two |
| 81 /// argument names: "id" and "dimensions". | 83 /// argument names: "id" and "dimensions". |
| 82 /// | 84 /// |
| 83 /// @param[in] argv An array of argument values. These are the values of the | 85 /// @param[in] argv An array of argument values. These are the values of the |
| 84 /// arguments listed in the \<embed\> tag, for example | 86 /// arguments listed in the \<embed\> tag, for example |
| 85 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two | 87 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two |
| 86 /// argument values: "nacl_module" and "2". The indices of these values | 88 /// argument values: "nacl_module" and "2". The indices of these values |
| 87 /// match the indices of the corresponding names in <code>argn</code>. | 89 /// match the indices of the corresponding names in <code>argn</code>. |
| 88 /// | 90 /// |
| 89 /// @return True on success. Returning false causes the instance to be | 91 /// @return true on success. Returning false causes the instance to be |
| 90 /// instance to be deleted and no other functions to be called. | 92 /// instance to be deleted and no other functions to be called. |
| 91 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); | 93 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
| 92 | 94 |
| 93 /// @{ | 95 /// @{ |
| 94 /// @name PPP_Instance methods for the module to override: | 96 /// @name PPP_Instance methods for the module to override: |
| 95 | 97 |
| 96 /// DidChangeView() is called when the position, the size, or the clip | 98 /// DidChangeView() is called when the position, the size, or the clip |
| 97 /// rectangle of the element in the browser that corresponds to this | 99 /// rectangle of the element in the browser that corresponds to this |
| 98 /// instance has changed. | 100 /// instance has changed. |
| 99 /// | 101 /// |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 /// you register for the event classes you want by calling | 172 /// you register for the event classes you want by calling |
| 171 /// <code>RequestInputEvents</code> or | 173 /// <code>RequestInputEvents</code> or |
| 172 /// <code>RequestFilteringInputEvents</code>. If you're still not receiving | 174 /// <code>RequestFilteringInputEvents</code>. If you're still not receiving |
| 173 /// keyboard input events, make sure you're returning true (or using a | 175 /// keyboard input events, make sure you're returning true (or using a |
| 174 /// non-filtered event handler) for mouse events. Otherwise, the instance will | 176 /// non-filtered event handler) for mouse events. Otherwise, the instance will |
| 175 /// not receive focus and keyboard events will not be sent. | 177 /// not receive focus and keyboard events will not be sent. |
| 176 /// | 178 /// |
| 177 /// Refer to <code>RequestInputEvents</code> and | 179 /// Refer to <code>RequestInputEvents</code> and |
| 178 /// <code>RequestFilteringInputEvents</code> for further information. | 180 /// <code>RequestFilteringInputEvents</code> for further information. |
| 179 /// | 181 /// |
| 182 /// @param[in] event The event to handle. |
| 183 /// |
| 180 /// @return true if the event was handled, false if not. If you have | 184 /// @return true if the event was handled, false if not. If you have |
| 181 /// registered to filter this class of events by calling | 185 /// registered to filter this class of events by calling |
| 182 /// <code>RequestFilteringInputEvents</code>, and you return false, | 186 /// <code>RequestFilteringInputEvents</code>, and you return false, |
| 183 /// the event will be forwarded to the page (and eventually the browser) | 187 /// the event will be forwarded to the page (and eventually the browser) |
| 184 /// for the default handling. For non-filtered events, the return value | 188 /// for the default handling. For non-filtered events, the return value |
| 185 /// will be ignored. | 189 /// will be ignored. |
| 186 virtual bool HandleInputEvent(const pp::InputEvent& event); | 190 virtual bool HandleInputEvent(const pp::InputEvent& event); |
| 187 | 191 |
| 188 /// HandleDocumentLoad() is called after Init() for a full-frame | 192 /// HandleDocumentLoad() is called after Init() for a full-frame |
| 189 /// instance that was instantiated based on the MIME type of a DOMWindow | 193 /// instance that was instantiated based on the MIME type of a DOMWindow |
| (...skipping 16 matching lines...) Expand all Loading... |
| 206 /// | 210 /// |
| 207 /// @return true if the data was handled, false otherwise. | 211 /// @return true if the data was handled, false otherwise. |
| 208 virtual bool HandleDocumentLoad(const URLLoader& url_loader); | 212 virtual bool HandleDocumentLoad(const URLLoader& url_loader); |
| 209 | 213 |
| 210 /// HandleMessage() is a function that the browser calls when PostMessage() | 214 /// HandleMessage() is a function that the browser calls when PostMessage() |
| 211 /// is invoked on the DOM element for the instance in JavaScript. Note | 215 /// is invoked on the DOM element for the instance in JavaScript. Note |
| 212 /// that PostMessage() in the JavaScript interface is asynchronous, meaning | 216 /// that PostMessage() in the JavaScript interface is asynchronous, meaning |
| 213 /// JavaScript execution will not be blocked while HandleMessage() is | 217 /// JavaScript execution will not be blocked while HandleMessage() is |
| 214 /// processing the message. | 218 /// processing the message. |
| 215 /// | 219 /// |
| 216 /// @param[in] message A <code>Var</code> containing the data sent from | |
| 217 /// JavaScript. Message can have an int32_t, double, bool, or string value | |
| 218 /// (objects are not supported). | |
| 219 /// | |
| 220 /// \see PostMessage for sending messages to JavaScript. | |
| 221 /// | |
| 222 /// <strong>Example:</strong> | 220 /// <strong>Example:</strong> |
| 223 /// | 221 /// |
| 224 /// The following JavaScript code invokes <code>HandleMessage</code>, passing | 222 /// The following JavaScript code invokes <code>HandleMessage</code>, passing |
| 225 /// the instance on which it was invoked, with <code>message</code> being a | 223 /// the instance on which it was invoked, with <code>message</code> being a |
| 226 /// string <code>Var</code> containing "Hello world!" | 224 /// string <code>Var</code> containing "Hello world!" |
| 227 /// | 225 /// |
| 228 /// @code | 226 /// @code |
| 229 /// | 227 /// |
| 230 /// <body> | 228 /// <body> |
| 231 /// <object id="plugin" | 229 /// <object id="plugin" |
| 232 /// type="application/x-ppapi-postMessage-example"/> | 230 /// type="application/x-ppapi-postMessage-example"/> |
| 233 /// <script type="text/javascript"> | 231 /// <script type="text/javascript"> |
| 234 /// document.getElementById('plugin').postMessage("Hello world!"); | 232 /// document.getElementById('plugin').postMessage("Hello world!"); |
| 235 /// </script> | 233 /// </script> |
| 236 /// </body> | 234 /// </body> |
| 237 /// | 235 /// |
| 238 /// @endcode | 236 /// @endcode |
| 237 /// |
| 238 /// Refer to PostMessage() for sending messages to JavaScript. |
| 239 /// |
| 240 /// @param[in] message A <code>Var</code> containing the data sent from |
| 241 /// JavaScript. Message can have an int32_t, double, bool, or string value |
| 242 /// (objects are not supported). |
| 239 virtual void HandleMessage(const Var& message); | 243 virtual void HandleMessage(const Var& message); |
| 240 | 244 |
| 241 /// @} | 245 /// @} |
| 242 | 246 |
| 243 /// @{ | 247 /// @{ |
| 244 /// @name PPB_Instance methods for querying the browser: | 248 /// @name PPB_Instance methods for querying the browser: |
| 245 | 249 |
| 246 /// BindGraphics() binds the given graphics as the current display surface. | 250 /// BindGraphics() binds the given graphics as the current display surface. |
| 247 /// The contents of this device is what will be displayed in the instance's | 251 /// The contents of this device is what will be displayed in the instance's |
| 248 /// area on the web page. The device must be a 2D or a 3D device. | 252 /// area on the web page. The device must be a 2D or a 3D device. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 262 /// | 266 /// |
| 263 /// @param[in] graphics A <code>Graphics2D</code> to bind. | 267 /// @param[in] graphics A <code>Graphics2D</code> to bind. |
| 264 /// | 268 /// |
| 265 /// @return true if bind was successful or false if the device was not the | 269 /// @return true if bind was successful or false if the device was not the |
| 266 /// correct type. On success, a reference to the device will be held by the | 270 /// correct type. On success, a reference to the device will be held by the |
| 267 /// instance, so the caller can release its reference if it chooses. | 271 /// instance, so the caller can release its reference if it chooses. |
| 268 bool BindGraphics(const Graphics2D& graphics); | 272 bool BindGraphics(const Graphics2D& graphics); |
| 269 | 273 |
| 270 /// Binds the given Graphics3D as the current display surface. | 274 /// Binds the given Graphics3D as the current display surface. |
| 271 /// See BindGraphics(const Graphics2D& graphics). | 275 /// See BindGraphics(const Graphics2D& graphics). |
| 276 /// |
| 277 /// @param[in] graphics A <code>Graphics3D_Dev</code> to bind. |
| 278 /// |
| 279 /// @return true if bind was successful or false if the device was not the |
| 280 /// correct type. On success, a reference to the device will be held by the |
| 281 /// instance, so the caller can release its reference if it chooses. |
| 272 bool BindGraphics(const Graphics3D_Dev& graphics); | 282 bool BindGraphics(const Graphics3D_Dev& graphics); |
| 273 | 283 |
| 274 /// Binds the given Surface3D as the current display surface. | 284 /// Binds the given Surface3D as the current display surface. |
| 275 /// See BindGraphics(const Graphics2D& graphics). | 285 /// See BindGraphics(const Graphics2D& graphics). |
| 286 /// @param[in] graphics A <code>Surface3D_Dev</code> to bind. |
| 287 /// |
| 288 /// @return true if bind was successful or false if the device was not the |
| 289 /// correct type. On success, a reference to the device will be held by the |
| 290 /// instance, so the caller can release its reference if it chooses. |
| 276 bool BindGraphics(const Surface3D_Dev& graphics); | 291 bool BindGraphics(const Surface3D_Dev& graphics); |
| 277 | 292 |
| 278 /// IsFullFrame() determines if the instance is full-frame (repr). | 293 /// IsFullFrame() determines if the instance is full-frame (repr). |
| 279 /// Such an instance represents the entire document in a frame rather than an | 294 /// Such an instance represents the entire document in a frame rather than an |
| 280 /// embedded resource. This can happen if the user does a top-level | 295 /// embedded resource. This can happen if the user does a top-level |
| 281 /// navigation or the page specifies an iframe to a resource with a MIME | 296 /// navigation or the page specifies an iframe to a resource with a MIME |
| 282 /// type registered by the module. | 297 /// type registered by the module. |
| 283 /// | 298 /// |
| 284 /// @return true if the instance is full-frame, false if not. | 299 /// @return true if the instance is full-frame, false if not. |
| 285 bool IsFullFrame(); | 300 bool IsFullFrame(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 /// | 362 /// |
| 348 /// <strong>Example:</strong> | 363 /// <strong>Example:</strong> |
| 349 /// | 364 /// |
| 350 /// @code | 365 /// @code |
| 351 /// | 366 /// |
| 352 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 367 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
| 353 /// RequestFilteringInputEvents( | 368 /// RequestFilteringInputEvents( |
| 354 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); | 369 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); |
| 355 /// | 370 /// |
| 356 /// @endcode | 371 /// @endcode |
| 357 //// | 372 /// |
| 373 /// @param event_classes A combination of flags from |
| 374 /// <code>PP_InputEvent_Class</code> that identifies the classes of events |
| 375 /// the instance is requesting. The flags are combined by logically ORing |
| 376 /// their values. |
| 377 /// |
| 358 /// @return <code>PP_OK</code> if the operation succeeded, | 378 /// @return <code>PP_OK</code> if the operation succeeded, |
| 359 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or | 379 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or |
| 360 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were | 380 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were |
| 361 /// illegal. In the case of an invalid bit, all valid bits will be applied | 381 /// illegal. In the case of an invalid bit, all valid bits will be applied |
| 362 /// and only the illegal bits will be ignored. | 382 /// and only the illegal bits will be ignored. |
| 363 int32_t RequestFilteringInputEvents(uint32_t event_classes); | 383 int32_t RequestFilteringInputEvents(uint32_t event_classes); |
| 364 | 384 |
| 365 /// ClearInputEventRequest() requests that input events corresponding to the | 385 /// ClearInputEventRequest() requests that input events corresponding to the |
| 366 /// given input classes no longer be delivered to the instance. | 386 /// given input classes no longer be delivered to the instance. |
| 367 /// | 387 /// |
| 368 /// By default, no input events are delivered. If you have previously | 388 /// By default, no input events are delivered. If you have previously |
| 369 /// requested input events using RequestInputEvents() or | 389 /// requested input events using RequestInputEvents() or |
| 370 /// RequestFilteringInputEvents(), this function will unregister handling | 390 /// RequestFilteringInputEvents(), this function will unregister handling |
| 371 /// for the given instance. This will allow greater browser performance for | 391 /// for the given instance. This will allow greater browser performance for |
| 372 /// those events. | 392 /// those events. |
| 373 /// | 393 /// |
| 374 /// <strong>Note: </strong> You may still get some input events after | 394 /// <strong>Note: </strong> You may still get some input events after |
| 375 /// clearing the flag if they were dispatched before the request was cleared. | 395 /// clearing the flag if they were dispatched before the request was cleared. |
| 376 /// For example, if there are 3 mouse move events waiting to be delivered, | 396 /// For example, if there are 3 mouse move events waiting to be delivered, |
| 377 /// and you clear the mouse event class during the processing of the first | 397 /// and you clear the mouse event class during the processing of the first |
| 378 /// one, you'll still receive the next two. You just won't get more events | 398 /// one, you'll still receive the next two. You just won't get more events |
| 379 /// generated. | 399 /// generated. |
| 380 /// | 400 /// |
| 381 /// @param event_classes A combination of flags from | 401 /// @param[in] event_classes A combination of flags from |
| 382 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the | 402 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the |
| 383 /// instance is no longer interested in. | 403 /// instance is no longer interested in. |
| 384 void ClearInputEventRequest(uint32_t event_classes); | 404 void ClearInputEventRequest(uint32_t event_classes); |
| 385 | 405 |
| 386 /// PostMessage() asynchronously invokes any listeners for message events on | 406 /// PostMessage() asynchronously invokes any listeners for message events on |
| 387 /// the DOM element for the given instance. A call to PostMessage() will | 407 /// the DOM element for the given instance. A call to PostMessage() will |
| 388 /// not block while the message is processed. | 408 /// not block while the message is processed. |
| 389 /// | 409 /// |
| 390 /// @param[in] message A <code>Var</code> containing the data to be sent to | |
| 391 /// JavaScript. | |
| 392 /// Message can have a numeric, boolean, or string value; arrays and | |
| 393 /// dictionaries are not yet supported. Ref-counted var types are copied, and | |
| 394 /// are therefore not shared between the instance and the browser. | |
| 395 /// | |
| 396 /// Listeners for message events in JavaScript code will receive an object | |
| 397 /// conforming to the HTML 5 <code>MessageEvent</code> interface. | |
| 398 /// Specifically, the value of message will be contained as a property called | |
| 399 /// data in the received <code>MessageEvent</code>. | |
| 400 /// | |
| 401 /// This messaging system is similar to the system used for listening for | |
| 402 /// messages from Web Workers. Refer to | |
| 403 /// <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for | |
| 404 /// further information. | |
| 405 /// | |
| 406 /// @see HandleMessage() for receiving events from JavaScript. | |
| 407 /// | |
| 408 /// <strong>Example:</strong> | 410 /// <strong>Example:</strong> |
| 409 /// | 411 /// |
| 410 /// @code | 412 /// @code |
| 411 /// | 413 /// |
| 412 /// <body> | 414 /// <body> |
| 413 /// <object id="plugin" | 415 /// <object id="plugin" |
| 414 /// type="application/x-ppapi-postMessage-example"/> | 416 /// type="application/x-ppapi-postMessage-example"/> |
| 415 /// <script type="text/javascript"> | 417 /// <script type="text/javascript"> |
| 416 /// var plugin = document.getElementById('plugin'); | 418 /// var plugin = document.getElementById('plugin'); |
| 417 /// plugin.AddEventListener("message", | 419 /// plugin.AddEventListener("message", |
| 418 /// function(message) { alert(message.data); }, | 420 /// function(message) { alert(message.data); }, |
| 419 /// false); | 421 /// false); |
| 420 /// </script> | 422 /// </script> |
| 421 /// </body> | 423 /// </body> |
| 422 /// | 424 /// |
| 423 /// @endcode | 425 /// @endcode |
| 424 /// | 426 /// |
| 425 /// The instance then invokes PostMessage() as follows: | 427 /// The instance then invokes PostMessage() as follows: |
| 426 /// | 428 /// |
| 427 /// @code | 429 /// @code |
| 428 /// | 430 /// |
| 429 /// PostMessage(pp::Var("Hello world!")); | 431 /// PostMessage(pp::Var("Hello world!")); |
| 430 /// | 432 /// |
| 431 /// @endcode | 433 /// @endcode |
| 432 /// | 434 /// |
| 433 /// The browser will pop-up an alert saying "Hello world!" | 435 /// The browser will pop-up an alert saying "Hello world!" |
| 436 /// |
| 437 /// Listeners for message events in JavaScript code will receive an object |
| 438 /// conforming to the HTML 5 <code>MessageEvent</code> interface. |
| 439 /// Specifically, the value of message will be contained as a property called |
| 440 /// data in the received <code>MessageEvent</code>. |
| 441 /// |
| 442 /// This messaging system is similar to the system used for listening for |
| 443 /// messages from Web Workers. Refer to |
| 444 /// <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
| 445 /// further information. |
| 446 /// |
| 447 /// Refer to HandleMessage() for receiving events from JavaScript. |
| 448 /// |
| 449 /// @param[in] message A <code>Var</code> containing the data to be sent to |
| 450 /// JavaScript. Message can have a numeric, boolean, or string value; arrays |
| 451 /// and dictionaries are not yet supported. Ref-counted var types are copied, |
| 452 /// and are therefore not shared between the instance and the browser. |
| 434 void PostMessage(const Var& message); | 453 void PostMessage(const Var& message); |
| 435 | 454 |
| 436 /// @} | 455 /// @} |
| 437 | 456 |
| 438 /// AddPerInstanceObject() associates an instance with an interface, | 457 /// AddPerInstanceObject() associates an instance with an interface, |
| 439 /// creating an object... {PENDING: clarify!} | 458 /// creating an object... {PENDING: clarify!} |
| 440 /// | 459 /// |
| 441 /// Many optional interfaces are associated with a plugin instance. For | 460 /// Many optional interfaces are associated with a plugin instance. For |
| 442 /// example, the find in PPP_Find interface receives updates on a per-instance | 461 /// example, the find in PPP_Find interface receives updates on a per-instance |
| 443 /// basis. This "per-instance" tracking allows such objects to associate | 462 /// basis. This "per-instance" tracking allows such objects to associate |
| 444 /// themselves with an instance as "the" handler for that interface name. | 463 /// themselves with an instance as "the" handler for that interface name. |
| 445 /// | 464 /// |
| 446 /// In the case of the find example, the find object registers with its | 465 /// In the case of the find example, the find object registers with its |
| 447 /// associated instance in its constructor and unregisters in its destructor. | 466 /// associated instance in its constructor and unregisters in its destructor. |
| 448 /// Then whenever it gets updates with a PP_Instance parameter, it can | 467 /// Then whenever it gets updates with a PP_Instance parameter, it can |
| 449 /// map back to the find object corresponding to that given PP_Instance by | 468 /// map back to the find object corresponding to that given PP_Instance by |
| 450 /// calling GetPerInstanceObject. | 469 /// calling GetPerInstanceObject. |
| 451 /// | 470 /// |
| 452 /// This lookup is done on a per-interface-name basis. This means you can | 471 /// This lookup is done on a per-interface-name basis. This means you can |
| 453 /// only have one object of a given interface name associated with an | 472 /// only have one object of a given interface name associated with an |
| 454 /// instance. | 473 /// instance. |
| 455 /// | 474 /// |
| 456 /// If you are adding a handler for an additional interface, be sure to | 475 /// If you are adding a handler for an additional interface, be sure to |
| 457 /// register with the module (AddPluginInterface) for your interface name to | 476 /// register with the module (AddPluginInterface) for your interface name to |
| 458 /// get the C calls in the first place. | 477 /// get the C calls in the first place. |
| 459 /// | 478 /// |
| 460 /// @see RemovePerInstanceObject | 479 /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further |
| 461 /// @see GetPerInstanceObject | 480 /// information. |
| 481 /// |
| 482 /// @param[in] interface_name The name of the interface to associate with the |
| 483 /// instance |
| 484 /// @param[in] object |
| 462 void AddPerInstanceObject(const std::string& interface_name, void* object); | 485 void AddPerInstanceObject(const std::string& interface_name, void* object); |
| 463 | 486 |
| 464 /// {PENDING: summarize Remove method here} | 487 /// {PENDING: summarize Remove method here} |
| 465 /// | 488 /// |
| 466 /// @see AddPerInstanceObject | 489 /// Refer to AddPerInstanceObject() for further information. |
| 490 /// |
| 491 /// @param[in] interface_name The name of the interface to associate with the |
| 492 /// instance |
| 493 /// @param[in] object |
| 467 void RemovePerInstanceObject(const std::string& interface_name, void* object); | 494 void RemovePerInstanceObject(const std::string& interface_name, void* object); |
| 468 | 495 |
| 469 /// Look up an object previously associated with an instance. Returns NULL | 496 /// Look up an object previously associated with an instance. Returns NULL |
| 470 /// if the instance is invalid or there is no object for the given interface | 497 /// if the instance is invalid or there is no object for the given interface |
| 471 /// name on the instance. | 498 /// name on the instance. |
| 472 /// | 499 /// |
| 473 /// @see AddPerInstanceObject | 500 /// Refer to AddPerInstanceObject() for further information. |
| 501 /// |
| 502 /// @param[in] instance |
| 503 /// @param[in] interface_name The name of the interface to associate with the |
| 504 /// instance. |
| 474 static void* GetPerInstanceObject(PP_Instance instance, | 505 static void* GetPerInstanceObject(PP_Instance instance, |
| 475 const std::string& interface_name); | 506 const std::string& interface_name); |
| 476 | 507 |
| 477 private: | 508 private: |
| 478 PP_Instance pp_instance_; | 509 PP_Instance pp_instance_; |
| 479 | 510 |
| 480 typedef std::map<std::string, void*> InterfaceNameToObjectMap; | 511 typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
| 481 InterfaceNameToObjectMap interface_name_to_objects_; | 512 InterfaceNameToObjectMap interface_name_to_objects_; |
| 482 }; | 513 }; |
| 483 | 514 |
| 484 } // namespace pp | 515 } // namespace pp |
| 485 | 516 |
| 486 #endif // PPAPI_CPP_INSTANCE_H_ | 517 #endif // PPAPI_CPP_INSTANCE_H_ |
| OLD | NEW |