Chromium Code Reviews| Index: native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c |
| diff --git a/native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c b/native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c |
| index 1ce3b817f49e0504ed505438de72d5c6de713b53..6ca07442864a2cc9894fec9c6ac3ea9d9746ebe5 100644 |
| --- a/native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c |
| +++ b/native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c |
| @@ -292,7 +292,6 @@ static void HandleMessage(struct PP_Var message) { |
| g_ppb_var->Release(result_var); |
| } |
| - |
| /** |
| * Helper function used by EchoThread which reads from a file descriptor |
| * and writes all the data that it reads back to the same descriptor. |
| @@ -342,7 +341,6 @@ static void* EchoThread(void* user_data) { |
| if (FD_ISSET(fd3, &readfds)) |
| EchoInput(fd3); |
| } |
| - |
| } |
| close(fd1); |
| close(fd2); |
| @@ -388,6 +386,23 @@ static PP_Bool Instance_DidCreate(PP_Instance instance, |
| 0, /* mountflags */ |
| ""); /* data */ |
| + for (uint32_t i = 0; i < argc; ++i) { |
| + if (strcmp(argn[i], "token") == 0) { |
| + char buffer[1024]; |
| + int char_written = |
| + snprintf(buffer, sizeof(buffer), "token=%s", argv[i]); |
| + if (char_written < 0 || char_written >= (signed int) sizeof(buffer)) { |
|
binji
2016/08/30 01:39:34
this new check is not necessary, snprintf will tru
chanpatorikku
2016/09/06 14:49:37
Done. Another very good comment of yours.
|
| + return PP_FALSE; |
| + } |
| + |
| + mount("", /* source */ |
| + "/googledrive", /* target */ |
| + "googledrivefs", /* filesystemtype */ |
| + 0, /* mountflags */ |
| + buffer); /* data */ |
| + } |
| + } |
| + |
| pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL); |
| pthread_create(&g_echo_thread, NULL, &EchoThread, NULL); |
| InitializeMessageQueue(); |
| @@ -395,15 +410,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) { |
| @@ -463,18 +475,16 @@ PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id, |
| GET_INTERFACE(g_ppb_messaging, PPB_Messaging, PPB_MESSAGING_INTERFACE); |
| GET_INTERFACE(g_ppb_var, PPB_Var, PPB_VAR_INTERFACE); |
| GET_INTERFACE(g_ppb_var_array, PPB_VarArray, PPB_VAR_ARRAY_INTERFACE); |
| - GET_INTERFACE( |
| - g_ppb_var_dictionary, PPB_VarDictionary, PPB_VAR_DICTIONARY_INTERFACE); |
| + GET_INTERFACE(g_ppb_var_dictionary, PPB_VarDictionary, |
| + PPB_VAR_DICTIONARY_INTERFACE); |
| 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 = { |
| - &Instance_DidCreate, |
| - &Instance_DidDestroy, |
| - &Instance_DidChangeView, |
| - &Instance_DidChangeFocus, |
| + &Instance_DidCreate, &Instance_DidDestroy, |
| + &Instance_DidChangeView, &Instance_DidChangeFocus, |
| &Instance_HandleDocumentLoad, |
| }; |
| return &instance_interface; |
| @@ -487,5 +497,4 @@ PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
| return NULL; |
| } |
| -PP_EXPORT void PPP_ShutdownModule() { |
| -} |
| +PP_EXPORT void PPP_ShutdownModule() {} |