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

Unified Diff: native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc

Issue 334983007: [NaCl SDK] Remove use of TIOCNACLINPUT from nacl_io/ppapi_simple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 6 years, 6 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/nacl_io/devfs/tty_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
index 211451fd8411246d01dff14e981650373dc7d34b..d237fdddd1fe25b7cb1a810cc19c0ab6de940d90 100644
--- a/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/devfs/tty_node.cc
@@ -18,6 +18,7 @@
#include "nacl_io/ioctl.h"
#include "nacl_io/kernel_handle.h"
#include "nacl_io/kernel_intercept.h"
+#include "nacl_io/log.h"
#include "nacl_io/pepper_interface.h"
#include "sdk_util/auto_lock.h"
@@ -167,11 +168,32 @@ Error TtyNode::Echo(const char* string, int count) {
return 0;
}
-Error TtyNode::ProcessInput(struct tioc_nacl_input_string* message) {
- AUTO_LOCK(emitter_->GetLock())
+Error TtyNode::ProcessInput(PP_Var message) {
+ if (message.type != PP_VARTYPE_STRING) {
+ LOG_ERROR("ProcessInput: expected VarString but got %d.", message.type);
+ return EINVAL;
+ }
+
+ PepperInterface* ppapi = filesystem_->ppapi();
+ if (!ppapi) {
+ LOG_ERROR("ProcessInput: ppapi is NULL.");
+ return EINVAL;
+ }
+
+ VarInterface* var_iface = ppapi->GetVarInterface();
+ if (!var_iface) {
+ LOG_ERROR("ProcessInput: Var interface pointer is NULL.");
+ return EINVAL;
+ }
- const char* buffer = message->buffer;
- size_t num_bytes = message->length;
+ uint32_t num_bytes;
+ const char* buffer = var_iface->VarToUtf8(message, &num_bytes);
+ Error error = ProcessInput(buffer, num_bytes);
+ return error;
+}
+
+Error TtyNode::ProcessInput(const char* buffer, size_t num_bytes) {
+ AUTO_LOCK(emitter_->GetLock())
for (size_t i = 0; i < num_bytes; i++) {
char c = buffer[i];
@@ -248,12 +270,9 @@ Error TtyNode::VIoctl(int request, va_list args) {
output_handler_ = *arg;
return 0;
}
- case TIOCNACLINPUT: {
- // This ioctl is used to deliver data from the user to this tty node's
- // input buffer.
- struct tioc_nacl_input_string* message =
- va_arg(args, struct tioc_nacl_input_string*);
- return ProcessInput(message);
+ case NACL_IOC_HANDLEMESSAGE: {
+ struct PP_Var* message = va_arg(args, struct PP_Var*);
+ return ProcessInput(*message);
}
case TIOCSWINSZ: {
struct winsize* size = va_arg(args, struct winsize*);
@@ -280,6 +299,9 @@ Error TtyNode::VIoctl(int request, va_list args) {
size->ws_col = cols_;
return 0;
}
+ default: {
+ LOG_ERROR("TtyNode:VIoctl: Unknown request: %#x", request);
+ }
}
return EINVAL;

Powered by Google App Engine
This is Rietveld 408576698