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

Unified Diff: native_client_sdk/src/examples/demo/nacl_io_demo/nacl_io_demo.c

Issue 2156503002: [NaCl SDK] Expose Google Drive to nacl_io. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/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..57e0a81ea9e3a02111798d474a759f4f11ac192c 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
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2016 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
@@ -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 =
+ sprintf(buffer, "instance=%i,token=%s", instance, argv[i]);
+ if (char_written < 0) {
+ 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() {}

Powered by Google App Engine
This is Rietveld 408576698