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 /// This file defines the C++ wrapper for an instance. | 9 /// This file defines the C++ wrapper for an instance. |
10 | 10 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 /// | 450 /// |
451 /// @param[in] message A <code>Var</code> containing the data to be sent to | 451 /// @param[in] message A <code>Var</code> containing the data to be sent to |
452 /// JavaScript. Message can have a numeric, boolean, or string value; arrays | 452 /// JavaScript. Message can have a numeric, boolean, or string value; arrays |
453 /// and dictionaries are not yet supported. Ref-counted var types are copied, | 453 /// and dictionaries are not yet supported. Ref-counted var types are copied, |
454 /// and are therefore not shared between the instance and the browser. | 454 /// and are therefore not shared between the instance and the browser. |
455 void PostMessage(const Var& message); | 455 void PostMessage(const Var& message); |
456 | 456 |
457 /// @} | 457 /// @} |
458 | 458 |
459 /// AddPerInstanceObject() associates an instance with an interface, | 459 /// AddPerInstanceObject() associates an instance with an interface, |
460 /// creating an object... {PENDING: clarify!} | 460 /// creating an object. |
461 /// | 461 /// |
462 /// Many optional interfaces are associated with a plugin instance. For | 462 /// Many optional interfaces are associated with a plugin instance. For |
463 /// example, the find in PPP_Find interface receives updates on a per-instance | 463 /// example, the find in PPP_Find interface receives updates on a per-instance |
464 /// basis. This "per-instance" tracking allows such objects to associate | 464 /// basis. This "per-instance" tracking allows such objects to associate |
465 /// themselves with an instance as "the" handler for that interface name. | 465 /// themselves with an instance as "the" handler for that interface name. |
466 /// | 466 /// |
467 /// In the case of the find example, the find object registers with its | 467 /// In the case of the find example, the find object registers with its |
468 /// associated instance in its constructor and unregisters in its destructor. | 468 /// associated instance in its constructor and unregisters in its destructor. |
469 /// Then whenever it gets updates with a PP_Instance parameter, it can | 469 /// Then whenever it gets updates with a PP_Instance parameter, it can |
470 /// map back to the find object corresponding to that given PP_Instance by | 470 /// map back to the find object corresponding to that given PP_Instance by |
471 /// calling GetPerInstanceObject. | 471 /// calling GetPerInstanceObject. |
472 /// | 472 /// |
473 /// This lookup is done on a per-interface-name basis. This means you can | 473 /// This lookup is done on a per-interface-name basis. This means you can |
474 /// only have one object of a given interface name associated with an | 474 /// only have one object of a given interface name associated with an |
475 /// instance. | 475 /// instance. |
476 /// | 476 /// |
477 /// If you are adding a handler for an additional interface, be sure to | 477 /// If you are adding a handler for an additional interface, be sure to |
478 /// register with the module (AddPluginInterface) for your interface name to | 478 /// register with the module (AddPluginInterface) for your interface name to |
479 /// get the C calls in the first place. | 479 /// get the C calls in the first place. |
480 /// | 480 /// |
481 /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further | 481 /// Refer to RemovePerInstanceObject() and GetPerInstanceObject() for further |
482 /// information. | 482 /// information. |
483 /// | 483 /// |
484 /// @param[in] interface_name The name of the interface to associate with the | 484 /// @param[in] interface_name The name of the interface to associate with the |
485 /// instance | 485 /// instance |
486 /// @param[in] object | 486 /// @param[in] object |
487 void AddPerInstanceObject(const std::string& interface_name, void* object); | 487 void AddPerInstanceObject(const std::string& interface_name, void* object); |
488 | 488 |
489 /// {PENDING: summarize Remove method here} | 489 // {PENDING: summarize Remove method here} |
490 /// | 490 /// |
491 /// Refer to AddPerInstanceObject() for further information. | 491 /// Refer to AddPerInstanceObject() for further information. |
492 /// | 492 /// |
493 /// @param[in] interface_name The name of the interface to associate with the | 493 /// @param[in] interface_name The name of the interface to associate with the |
494 /// instance | 494 /// instance |
495 /// @param[in] object | 495 /// @param[in] object |
496 void RemovePerInstanceObject(const std::string& interface_name, void* object); | 496 void RemovePerInstanceObject(const std::string& interface_name, void* object); |
497 | 497 |
498 /// Look up an object previously associated with an instance. Returns NULL | 498 /// Look up an object previously associated with an instance. Returns NULL |
499 /// if the instance is invalid or there is no object for the given interface | 499 /// if the instance is invalid or there is no object for the given interface |
(...skipping 10 matching lines...) Expand all Loading... |
510 private: | 510 private: |
511 PP_Instance pp_instance_; | 511 PP_Instance pp_instance_; |
512 | 512 |
513 typedef std::map<std::string, void*> InterfaceNameToObjectMap; | 513 typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
514 InterfaceNameToObjectMap interface_name_to_objects_; | 514 InterfaceNameToObjectMap interface_name_to_objects_; |
515 }; | 515 }; |
516 | 516 |
517 } // namespace pp | 517 } // namespace pp |
518 | 518 |
519 #endif // PPAPI_CPP_INSTANCE_H_ | 519 #endif // PPAPI_CPP_INSTANCE_H_ |
OLD | NEW |