| OLD | NEW |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /** @file hello_world.c | 6 /** @file hello_world.c |
| 7 * This example, is a modified version of hello world. It will start a second | 7 * This example, is a modified version of hello world. It will start a second |
| 8 * thread and cause that thread to crash via a NULL dereference. | 8 * thread and cause that thread to crash via a NULL dereference. |
| 9 */ | 9 */ |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 */ | 83 */ |
| 84 static struct PP_Var CStrToVar(const char* str) { | 84 static struct PP_Var CStrToVar(const char* str) { |
| 85 if (ppb_var_interface != NULL) { | 85 if (ppb_var_interface != NULL) { |
| 86 return ppb_var_interface->VarFromUtf8(str, strlen(str)); | 86 return ppb_var_interface->VarFromUtf8(str, strlen(str)); |
| 87 } | 87 } |
| 88 return PP_MakeUndefined(); | 88 return PP_MakeUndefined(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| 92 static void PostCompletionCallback(void* user_data, int32_t result) { | 92 static void PostCompletionCallback(void* user_data, int32_t result) { |
| 93 ppb_messaging_interface->PostMessage(g_Instance, CStrToVar(user_data)); | 93 const char *str = (const char *) user_data; |
| 94 ppb_messaging_interface->PostMessage(g_Instance, CStrToVar(str)); |
| 94 free(user_data); | 95 free(user_data); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void PostMessage(const char *str) { | 98 void PostMessage(const char *str) { |
| 98 struct PP_CompletionCallback cb; | 99 struct PP_CompletionCallback cb; |
| 99 | 100 |
| 100 if (NULL == str) return; | 101 if (NULL == str) return; |
| 101 if (NULL == ppb_messaging_interface) return; | 102 if (NULL == ppb_messaging_interface) return; |
| 102 if (0 == g_Instance) return; | 103 if (0 == g_Instance) return; |
| 103 | 104 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 */ | 223 */ |
| 223 static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, | 224 static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, |
| 224 PP_Resource url_loader) { | 225 PP_Resource url_loader) { |
| 225 /* NaCl modules do not need to handle the document load function. */ | 226 /* NaCl modules do not need to handle the document load function. */ |
| 226 return PP_FALSE; | 227 return PP_FALSE; |
| 227 } | 228 } |
| 228 | 229 |
| 229 | 230 |
| 230 /** | 231 /** |
| 231 * Handles message from JavaScript. | 232 * Handles message from JavaScript. |
| 232 * | 233 * |
| 233 * Any message from JS is a request to cause the main thread to crash. | 234 * Any message from JS is a request to cause the main thread to crash. |
| 234 */ | 235 */ |
| 235 static void Messaging_HandleMessage(PP_Instance instance, | 236 static void Messaging_HandleMessage(PP_Instance instance, |
| 236 struct PP_Var message) { | 237 struct PP_Var message) { |
| 237 PostMessage("LOG: Got BOOM"); | 238 PostMessage("LOG: Got BOOM"); |
| 238 g_CrashTime = 1; | 239 g_CrashTime = 1; |
| 239 } | 240 } |
| 240 | 241 |
| 241 /** | 242 /** |
| 242 * Entry points for the module. | 243 * Entry points for the module. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 281 } |
| 281 return NULL; | 282 return NULL; |
| 282 } | 283 } |
| 283 | 284 |
| 284 | 285 |
| 285 /** | 286 /** |
| 286 * Called before the plugin module is unloaded. | 287 * Called before the plugin module is unloaded. |
| 287 */ | 288 */ |
| 288 PP_EXPORT void PPP_ShutdownModule() { | 289 PP_EXPORT void PPP_ShutdownModule() { |
| 289 } | 290 } |
| OLD | NEW |