OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PPAPI_CPP_MESSAGE_HANDLER_H_ | |
6 #define PPAPI_CPP_MESSAGE_HANDLER_H_ | |
7 | |
8 namespace pp { | |
9 | |
10 /// <code>MessageHandler</code> is an abstract base class that the plugin may | |
11 /// implement if it wants to receive messages from JavaScript (postMessage() or | |
bbudge
2014/09/18 12:41:17
the first ( doesn't seem to have a matching )
| |
12 /// postMessageAndAwaitResponse() on a background thread. See | |
13 /// pp::Instance::RegisterMessageHandler() for usage. | |
14 class MessageHandler { | |
15 public: | |
16 virtual ~MessageHandler() {}; | |
17 | |
18 /// Invoked as a result of JavaScript invoking postMessage() on the plugin's | |
19 /// DOM element. | |
20 /// | |
21 /// @param[in] instance An <code>InstanceHandle</code> identifying one | |
22 /// instance of a module. | |
23 /// @param[in] message_data A copy of the parameter that JavaScript provided | |
24 /// to postMessage(). | |
25 virtual void HandleMessage(pp::InstanceHandle instance, | |
26 const Var& message_data) = 0; | |
27 | |
28 /// Invoked as a result of JavaScript invoking postMessageAndAwaitResponse() | |
29 /// on the plugin's DOM element. | |
30 /// | |
31 /// NOTE: JavaScript execution is blocked during the duration of this call. | |
32 /// Hence, the plugin should respond as quickly as possible. For this reason, | |
33 /// blocking completion callbacks are disallowed while handling a blocking | |
34 /// message. | |
35 /// | |
36 /// @param[in] instance An <code>InstanceHandle</code> identifying one | |
37 /// instance of a module. | |
38 /// @param[in] message is a copy of the parameter that JavaScript provided | |
bbudge
2014/09/18 12:41:17
s/message/message_data
This should be identical to
| |
39 /// to postMessageAndAwaitResponse. | |
40 /// @return Returns a pp::Var that is then copied to a JavaScript object | |
41 /// which is returned as the result of JavaScript's call of | |
42 /// postMessageAndAwaitResponse(). | |
43 virtual pp::Var HandleBlockingMessage(pp::InstanceHandle instance, | |
44 const Var& message_data) = 0; | |
45 | |
46 /// Invoked when this MessageHandler is no longer needed. After this, no more | |
47 /// calls will be made to this object. | |
48 /// | |
49 /// @param[in] instance An <code>InstanceHandle</code> identifying one | |
50 /// instance of a module. | |
51 virtual void WasUnregistered(pp::InstanceHandle instance) = 0; | |
52 }; | |
53 | |
54 } // namespace pp | |
55 | |
56 #endif // PPAPI_CPP_MESSAGE_HANDLER_H_ | |
OLD | NEW |