Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1450)

Unified Diff: native_client_sdk/src/libraries/ppapi_simple/ps_instance.h

Issue 23005005: [NaCl SDK] nacl_io: Add initial implementations of kill and signal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
index 2df1550dbbd24c4b3deb78abefb62522d6c16c34..1c761ea0130caebefbdeb11498da6fe5c70c4fff 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_instance.h
@@ -26,6 +26,16 @@
#include "sdk_util/thread_safe_queue.h"
+typedef void (*MessageHandler_t)(const pp::Var& key,
+ const pp::Var& value,
+ void* user_data);
+
+struct MessageHandler {
+ MessageHandler_t handler;
+ void* user_data;
+};
+
+typedef std::map<std::string, MessageHandler> MessageHandlerMap;
binji 2013/08/22 20:10:55 put this inside the PSInstance
Sam Clegg 2013/08/22 20:19:03 Done.
// The basic instance class which also inherits the MouseLock and
// Graphics3DClient interfaces.
@@ -73,6 +83,18 @@ class PSInstance : public pp::Instance, pp::MouseLock, pp::Graphics3DClient {
PSEvent* WaitAcquireEvent();
void ReleaseEvent(PSEvent* event);
+ // Register a message handler for messages that arrive
+ // from JavaScript with a give names. Messages are of the
+ // form:
+ // message_name { <value> }
binji 2013/08/22 20:10:55 this still looks weird to me. You'd never write f
Sam Clegg 2013/08/22 20:19:03 Oops. Fixed. (do you object to the <> too?)
+ // PSInstance wht then not generate events but instead
binji 2013/08/22 20:10:55 s/wht/will/
Sam Clegg 2013/08/22 20:19:03 Done.
+ // cause the handler to be called upon message arrival.
+ // If handler is NULL then the current handler will be
+ // removed.
+ void RegisterMessageHandler(std::string message_name,
+ MessageHandler_t handler,
+ void* user_data);
+
protected:
// Callback functions triggered by Pepper
//
@@ -113,6 +135,26 @@ class PSInstance : public pp::Instance, pp::MouseLock, pp::Graphics3DClient {
private:
static void* MainThreadThunk(void *start_info);
+ ssize_t TtyOutputHandler(const char* buf, size_t count);
+ void MessageHandlerInput(const pp::Var& message);
+ void MessageHandlerResize(const pp::Var& message);
+
+ static ssize_t TtyOutputHandlerStatic(const char* buf, size_t count,
+ void* user_data);
+
+ /// Handle input message from JavaScript. The valu is
binji 2013/08/22 20:10:55 value
Sam Clegg 2013/08/22 20:19:03 Done.
+ /// expected to be of type string.
+ static void MessageHandlerInputStatic(const pp::Var& key,
+ const pp::Var& value,
+ void* user_data);
+
+
+ /// Handle resizs message from JavaScript. The value is
+ /// expected to be an array of 2 integers representing the
+ /// number of columns and rows in the TTY.
+ static void MessageHandlerResizeStatic(const pp::Var& key,
+ const pp::Var& value,
+ void* user_data);
protected:
pp::MessageLoop* main_loop_;
@@ -120,7 +162,11 @@ class PSInstance : public pp::Instance, pp::MouseLock, pp::Graphics3DClient {
sdk_util::ThreadSafeQueue<PSEvent> event_queue_;
uint32_t events_enabled_;
Verbosity verbosity_;
- int fd_tty_;
+
+ // TTY handling
+ int tty_fd_;
+ const char* tty_prefix_;
+ MessageHandlerMap message_handlers_;
PSMainFunc_t main_cb_;
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_tty.cc ('k') | native_client_sdk/src/libraries/ppapi_simple/ps_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698