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 #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 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/c/pp_stdint.h" | 16 #include "ppapi/c/pp_stdint.h" |
| 17 #include "ppapi/c/ppb_console.h" |
17 #include "ppapi/cpp/instance_handle.h" | 18 #include "ppapi/cpp/instance_handle.h" |
18 #include "ppapi/cpp/view.h" | 19 #include "ppapi/cpp/view.h" |
19 | 20 |
20 // Windows defines 'PostMessage', so we have to undef it. | 21 // Windows defines 'PostMessage', so we have to undef it. |
21 #ifdef PostMessage | 22 #ifdef PostMessage |
22 #undef PostMessage | 23 #undef PostMessage |
23 #endif | 24 #endif |
24 | 25 |
25 struct PP_InputEvent; | 26 struct PP_InputEvent; |
26 | 27 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 /// Refer to HandleMessage() for receiving events from JavaScript. | 466 /// Refer to HandleMessage() for receiving events from JavaScript. |
466 /// | 467 /// |
467 /// @param[in] message A <code>Var</code> containing the data to be sent to | 468 /// @param[in] message A <code>Var</code> containing the data to be sent to |
468 /// JavaScript. Message can have a numeric, boolean, or string value; arrays | 469 /// JavaScript. Message can have a numeric, boolean, or string value; arrays |
469 /// and dictionaries are not yet supported. Ref-counted var types are copied, | 470 /// and dictionaries are not yet supported. Ref-counted var types are copied, |
470 /// and are therefore not shared between the instance and the browser. | 471 /// and are therefore not shared between the instance and the browser. |
471 void PostMessage(const Var& message); | 472 void PostMessage(const Var& message); |
472 | 473 |
473 /// @} | 474 /// @} |
474 | 475 |
| 476 /// @{ |
| 477 /// @name PPB_Console methods for logging to the console: |
| 478 |
| 479 /// Logs the given message to the JavaScript console associated with the |
| 480 /// given plugin instance with the given logging level. The name of the plugin |
| 481 /// issuing the log message will be automatically prepended to the message. |
| 482 /// The value may be any type of Var. |
| 483 void LogToConsole(PP_LogLevel level, const Var& value); |
| 484 |
| 485 /// Logs a message to the console with the given source information rather |
| 486 /// than using the internal PPAPI plugin name. The name must be a string var. |
| 487 /// |
| 488 /// The regular log function will automatically prepend the name of your |
| 489 /// plugin to the message as the "source" of the message. Some plugins may |
| 490 /// wish to override this. For example, if your plugin is a Python |
| 491 /// interpreter, you would want log messages to contain the source .py file |
| 492 /// doing the log statement rather than have "python" show up in the console. |
| 493 void LogToConsoleWithSource(PP_LogLevel level, |
| 494 const Var& source, |
| 495 const Var& value); |
| 496 |
| 497 /// @} |
| 498 |
475 /// AddPerInstanceObject() associates an instance with an interface, | 499 /// AddPerInstanceObject() associates an instance with an interface, |
476 /// creating an object. | 500 /// creating an object. |
477 /// | 501 /// |
478 /// Many optional interfaces are associated with a plugin instance. For | 502 /// Many optional interfaces are associated with a plugin instance. For |
479 /// example, the find in PPP_Find interface receives updates on a per-instance | 503 /// example, the find in PPP_Find interface receives updates on a per-instance |
480 /// basis. This "per-instance" tracking allows such objects to associate | 504 /// basis. This "per-instance" tracking allows such objects to associate |
481 /// themselves with an instance as "the" handler for that interface name. | 505 /// themselves with an instance as "the" handler for that interface name. |
482 /// | 506 /// |
483 /// In the case of the find example, the find object registers with its | 507 /// In the case of the find example, the find object registers with its |
484 /// associated instance in its constructor and unregisters in its destructor. | 508 /// associated instance in its constructor and unregisters in its destructor. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 private: | 557 private: |
534 PP_Instance pp_instance_; | 558 PP_Instance pp_instance_; |
535 | 559 |
536 typedef std::map<std::string, void*> InterfaceNameToObjectMap; | 560 typedef std::map<std::string, void*> InterfaceNameToObjectMap; |
537 InterfaceNameToObjectMap interface_name_to_objects_; | 561 InterfaceNameToObjectMap interface_name_to_objects_; |
538 }; | 562 }; |
539 | 563 |
540 } // namespace pp | 564 } // namespace pp |
541 | 565 |
542 #endif // PPAPI_CPP_INSTANCE_H_ | 566 #endif // PPAPI_CPP_INSTANCE_H_ |
OLD | NEW |