summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/testing_instance.h
diff options
context:
space:
mode:
authordmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 21:07:15 +0000
committerdmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 21:07:15 +0000
commit9888f134c655a95c5922c980eb59d3337341d653 (patch)
tree8ec7b6849cd94196df9bf3ee7810f6a838242e8d /ppapi/tests/testing_instance.h
parent2752bf6a3120e172d216ab7bde42222a3ae4b5cb (diff)
downloadchromium_src-9888f134c655a95c5922c980eb59d3337341d653.zip
chromium_src-9888f134c655a95c5922c980eb59d3337341d653.tar.gz
chromium_src-9888f134c655a95c5922c980eb59d3337341d653.tar.bz2
A proposal and implementation for an initial postMessage interface. These interfaces will allow JavaScript to send data asynchronously to a module instance, and the module instance to asynchronously send data to a JavaScript message handler.
Note, I did something differently from other per-instance interfaces. While the C interface has 'PPB_Messaging' and 'PPP_Messaging' separate from the Instance interfaces, I stuck the per-instance messaging in to pp::Instance. It seems more intuitive to me, and doesn't have the drawbacks of having too many functions in the C layer instance interfaces. Happy to back off of that position, but it's worth a shot. Overview: From JavaScript, you can invoke 'postMessage' on the embedded module. That results in a call to 'PPP_Messaging::HandleMessage'. From Native Code, you can invoke 'PPB_Messaging::PostMessage', which results in a call to an 'onmessage' function on the DOM element for the module instance in the JavaScript code (if one has been registered). Please see the included example or the examples in the comments of PPB_Messaging and PPP_Messaging. Restrictions: - This implementation is synchronous. A later CL will make it asynchronous. - This implementation supports only intrinsic values and strings (all types that PP_Var supports except for objects). Object & array support will come later. - This implementation only allows for 1 channel per instance. You can not expose other 'channels' or 'ports'. Future CLs will add support for MessagePorts. BUG=None TEST=test_post_message.h/.cc (This CL replaces http://codereview.chromium.org/6538028/ ) Review URL: http://codereview.chromium.org/6716005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/testing_instance.h')
-rw-r--r--ppapi/tests/testing_instance.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/ppapi/tests/testing_instance.h b/ppapi/tests/testing_instance.h
index 5eedf24..5bb95ae 100644
--- a/ppapi/tests/testing_instance.h
+++ b/ppapi/tests/testing_instance.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef PPAPI_TEST_TESTING_INSTANCE_H_
-#define PPAPI_TEST_TESTING_INSTANCE_H_
+#ifndef PPAPI_TESTS_TESTING_INSTANCE_H_
+#define PPAPI_TESTS_TESTING_INSTANCE_H_
#include <string>
@@ -14,7 +14,7 @@ class TestCase;
class TestingInstance : public pp::Instance {
public:
- TestingInstance(PP_Instance instance);
+ explicit TestingInstance(PP_Instance instance);
// pp::Instance override.
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
@@ -41,6 +41,10 @@ class TestingInstance : public pp::Instance {
// Appends an error message to the log.
void AppendError(const std::string& message);
+ // Passes the message_data through to the HandleMessage method on the
+ // TestClass object that's associated with this instance.
+ virtual void HandleMessage(const pp::Var& message_data);
+
private:
void ExecuteTests(int32_t unused);
@@ -75,4 +79,5 @@ class TestingInstance : public pp::Instance {
bool nacl_mode_;
};
-#endif // PPAPI_TEST_TESTING_INSTANCE_H_
+#endif // PPAPI_TESTS_TESTING_INSTANCE_H_
+