summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 22:21:18 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 22:21:18 +0000
commit192287dbdb72c4d75865a9bd844f7b395523249c (patch)
tree9f9b05351880e00e6a321bded0f09db47e9d5084 /native_client_sdk/src
parentd61d0e2e6c3578c641fcf35499975e219a87f716 (diff)
downloadchromium_src-192287dbdb72c4d75865a9bd844f7b395523249c.zip
chromium_src-192287dbdb72c4d75865a9bd844f7b395523249c.tar.gz
chromium_src-192287dbdb72c4d75865a9bd844f7b395523249c.tar.bz2
[NaCl SDK] Fix a typo in nacl_io example.
Also, made the root mounted as a memfs again (nacl_io mounts as passthrough by default now). BUG=none R=noelallen@chromium.org Review URL: https://codereview.chromium.org/14658002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk/src')
-rw-r--r--native_client_sdk/src/examples/demo/nacl_io/hello_nacl_io.c68
-rw-r--r--native_client_sdk/src/examples/demo/nacl_io/index.html2
2 files changed, 33 insertions, 37 deletions
diff --git a/native_client_sdk/src/examples/demo/nacl_io/hello_nacl_io.c b/native_client_sdk/src/examples/demo/nacl_io/hello_nacl_io.c
index fde9c1e..f187e3c 100644
--- a/native_client_sdk/src/examples/demo/nacl_io/hello_nacl_io.c
+++ b/native_client_sdk/src/examples/demo/nacl_io/hello_nacl_io.c
@@ -36,7 +36,6 @@ typedef struct {
HandleFunc function;
} FuncNameMapping;
-
static PP_Instance g_instance = 0;
static PPB_GetInterface get_browser_interface = NULL;
static PPB_Messaging* ppb_messaging_interface = NULL;
@@ -78,7 +77,7 @@ char* VprintfToNewString(const char* format, va_list args) {
va_copy(args_copy, args);
length = vsnprintf(NULL, 0, format, args);
- buffer = (char*)malloc(length + 1); /* +1 for NULL-terminator. */
+ buffer = (char*)malloc(length + 1); /* +1 for NULL-terminator. */
result = vsnprintf(&buffer[0], length + 1, format, args_copy);
assert(result == length);
return buffer;
@@ -180,7 +179,7 @@ static size_t ParseMessage(char* message,
return num_params;
}
- *separator = 0; /* NULL-terminate function. */
+ *separator = 0; /* NULL-terminate function. */
while (separator && num_params < max_params) {
param_start = separator + 1;
@@ -237,13 +236,15 @@ static void HandleMessage(char* message) {
/* Error. */
struct PP_Var var;
if (output != NULL) {
- var = PrintfToVar(
- "Error: Function \"%s\" returned error %d. "
- "Additional output: %s", function_name, result, output);
+ var = PrintfToVar("Error: Function \"%s\" returned error %d. "
+ "Additional output: %s",
+ function_name,
+ result,
+ output);
free(output);
} else {
- var = PrintfToVar("Error: Function \"%s\" returned error %d.",
- function_name, result);
+ var = PrintfToVar(
+ "Error: Function \"%s\" returned error %d.", function_name, result);
}
/* Post the error to JavaScript, so the user can see it. */
@@ -269,26 +270,30 @@ void* HandleMessageThread(void* user_data) {
}
}
-
static PP_Bool Instance_DidCreate(PP_Instance instance,
uint32_t argc,
const char* argn[],
const char* argv[]) {
g_instance = instance;
nacl_io_init_ppapi(instance, get_browser_interface);
- mount(
- "", /* source */
- "/persistent", /* target */
- "html5fs", /* filesystemtype */
- 0, /* mountflags */
- "type=PERSISTENT,expected_size=1048576"); /* data */
-
- mount(
- "", /* source. Use relative URL */
- "/http", /* target */
- "httpfs", /* filesystemtype */
- 0, /* mountflags */
- ""); /* data */
+
+ // By default, nacl_io mounts / to pass through to the original NaCl
+ // filesystem (which doesn't do much). Let's remount it to a memfs
+ // filesystem.
+ umount("/");
+ mount("", "/", "memfs", 0, "");
+
+ mount("", /* source */
+ "/persistent", /* target */
+ "html5fs", /* filesystemtype */
+ 0, /* mountflags */
+ "type=PERSISTENT,expected_size=1048576"); /* data */
+
+ mount("", /* source. Use relative URL */
+ "/http", /* target */
+ "httpfs", /* filesystemtype */
+ 0, /* mountflags */
+ ""); /* data */
pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL);
InitializeMessageQueue();
@@ -296,17 +301,12 @@ static PP_Bool Instance_DidCreate(PP_Instance instance,
return PP_TRUE;
}
-
-static void Instance_DidDestroy(PP_Instance instance) {
-}
+static void Instance_DidDestroy(PP_Instance instance) {}
static void Instance_DidChangeView(PP_Instance instance,
- PP_Resource view_resource) {
-}
+ PP_Resource view_resource) {}
-static void Instance_DidChangeFocus(PP_Instance instance,
- PP_Bool has_focus) {
-}
+static void Instance_DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {}
static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,
PP_Resource url_loader) {
@@ -321,8 +321,7 @@ static void Messaging_HandleMessage(PP_Instance instance,
if (!EnqueueMessage(strdup(buffer))) {
struct PP_Var var;
var = PrintfToVar(
- "Warning: dropped message \"%s\" because the queue was full.",
- message);
+ "Warning: dropped message \"%s\" because the queue was full.", message);
ppb_messaging_interface->PostMessage(g_instance, var);
}
}
@@ -336,7 +335,6 @@ PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id,
return PP_OK;
}
-
PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
static PPP_Instance instance_interface = {
@@ -356,6 +354,4 @@ PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
return NULL;
}
-
-PP_EXPORT void PPP_ShutdownModule() {
-}
+PP_EXPORT void PPP_ShutdownModule() {}
diff --git a/native_client_sdk/src/examples/demo/nacl_io/index.html b/native_client_sdk/src/examples/demo/nacl_io/index.html
index baed38d..aafa1cb 100644
--- a/native_client_sdk/src/examples/demo/nacl_io/index.html
+++ b/native_client_sdk/src/examples/demo/nacl_io/index.html
@@ -25,7 +25,7 @@ found in the LICENSE file.
directories, the mount determines how those operations should be performed.
</p>
<p>
- This example has three mounts by default.
+ This example has four mounts by default.
<ol>
<li><i>/</i> the root of the filesystem. This is a memory mount, and
is non-persistent.</li>