| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 #ifndef O3D_PLUGIN_CROSS_MAIN_H_ | 37 #ifndef O3D_PLUGIN_CROSS_MAIN_H_ |
| 38 #define O3D_PLUGIN_CROSS_MAIN_H_ | 38 #define O3D_PLUGIN_CROSS_MAIN_H_ |
| 39 | 39 |
| 40 #include <npupp.h> | 40 #include <npupp.h> |
| 41 #include <stdio.h> | 41 #include <stdio.h> |
| 42 | 42 |
| 43 #include <fstream> | 43 #include <fstream> |
| 44 #include <iostream> | 44 #include <iostream> |
| 45 | 45 |
| 46 #if !defined(O3D_INTERNAL_PLUGIN) |
| 46 #include "breakpad/win/exception_handler_win32.h" | 47 #include "breakpad/win/exception_handler_win32.h" |
| 48 #endif // O3D_INTERNAL_PLUGIN |
| 49 |
| 47 #include "core/cross/renderer.h" | 50 #include "core/cross/renderer.h" |
| 48 #include "core/cross/renderer_platform.h" | 51 #include "core/cross/renderer_platform.h" |
| 49 #include "plugin/cross/o3d_glue.h" | 52 #include "plugin/cross/o3d_glue.h" |
| 50 #include "plugin/cross/config.h" | 53 #include "plugin/cross/config.h" |
| 51 #include "plugin/cross/stream_manager.h" | 54 #include "plugin/cross/stream_manager.h" |
| 52 #include "third_party/nixysa/files/static_glue/npapi/common.h" | 55 #include "third_party/nixysa/files/static_glue/npapi/common.h" |
| 53 #include "third_party/nixysa/files/static_glue/npapi/npn_api.h" | 56 #include "third_party/nixysa/files/static_glue/npapi/npn_api.h" |
| 54 | 57 |
| 58 #if defined(O3D_INTERNAL_PLUGIN) |
| 59 #define HANDLE_CRASHES void(0) |
| 60 #else // O3D_INTERNAL_PLUGIN |
| 61 |
| 55 extern ExceptionManager *g_exception_manager; | 62 extern ExceptionManager *g_exception_manager; |
| 56 | 63 |
| 57 class RenderOnDemandCallbackHandler | |
| 58 : public o3d::Client::RenderOnDemandCallback { | |
| 59 public: | |
| 60 explicit RenderOnDemandCallbackHandler(glue::_o3d::PluginObject* obj) | |
| 61 : obj_(obj) { | |
| 62 } | |
| 63 | |
| 64 // This function is implemented for each platform. | |
| 65 virtual void Run(); | |
| 66 private: | |
| 67 glue::_o3d::PluginObject* obj_; | |
| 68 }; | |
| 69 | |
| 70 // BreakpadEnabler is a simple class to keep track of whether or not | 64 // BreakpadEnabler is a simple class to keep track of whether or not |
| 71 // we're executing code that we want to handle crashes for | 65 // we're executing code that we want to handle crashes for |
| 72 // (when the o3d plugin is running in Firefox, we don't want to handle | 66 // (when the o3d plugin is running in Firefox, we don't want to handle |
| 73 // crashes for the Flash plugin or Firefox, just the o3d code) | 67 // crashes for the Flash plugin or Firefox, just the o3d code) |
| 74 // Create a stack-based instance at the start of each function | 68 // Create a stack-based instance at the start of each function |
| 75 // where crash handling is desired. | 69 // where crash handling is desired. |
| 76 | 70 |
| 77 #define HANDLE_CRASHES BreakpadEnabler enabler | 71 #define HANDLE_CRASHES BreakpadEnabler enabler |
| 78 | 72 |
| 79 class BreakpadEnabler { | 73 class BreakpadEnabler { |
| 80 public: | 74 public: |
| 81 BreakpadEnabler() { | 75 BreakpadEnabler() { |
| 82 ++scope_count_; | 76 ++scope_count_; |
| 83 } | 77 } |
| 84 | 78 |
| 85 virtual ~BreakpadEnabler() { | 79 virtual ~BreakpadEnabler() { |
| 86 --scope_count_; | 80 --scope_count_; |
| 87 } | 81 } |
| 88 | 82 |
| 89 static bool IsEnabled() { return scope_count_ > 0; } | 83 static bool IsEnabled() { return scope_count_ > 0; } |
| 90 | 84 |
| 91 private: | 85 private: |
| 92 static int scope_count_; | 86 static int scope_count_; |
| 93 }; | 87 }; |
| 94 | 88 |
| 89 #endif // O3D_INTERNAL_PLUGIN |
| 90 |
| 91 #if defined(O3D_INTERNAL_PLUGIN) |
| 92 namespace o3d { |
| 93 #else |
| 94 extern "C" { |
| 95 #endif |
| 96 NPError OSCALL NP_Shutdown(void); |
| 97 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); |
| 98 } |
| 95 | 99 |
| 96 namespace o3d { | 100 namespace o3d { |
| 101 |
| 102 class RenderOnDemandCallbackHandler |
| 103 : public o3d::Client::RenderOnDemandCallback { |
| 104 public: |
| 105 explicit RenderOnDemandCallbackHandler(glue::_o3d::PluginObject* obj) |
| 106 : obj_(obj) { |
| 107 } |
| 108 |
| 109 // This function is implemented for each platform. |
| 110 virtual void Run(); |
| 111 private: |
| 112 glue::_o3d::PluginObject* obj_; |
| 113 }; |
| 114 |
| 97 void WriteLogString(const char* text, int length); | 115 void WriteLogString(const char* text, int length); |
| 98 } // end namespace o3d | 116 NPError NPP_Destroy(NPP instance, NPSavedData **save); |
| 117 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason); |
| 118 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); |
| 119 |
| 120 NPError NPP_New(NPMIMEType pluginType, |
| 121 NPP instance, |
| 122 uint16 mode, |
| 123 int16 argc, |
| 124 char *argn[], |
| 125 char *argv[], |
| 126 NPSavedData *saved); |
| 127 |
| 128 NPError NPP_NewStream(NPP instance, |
| 129 NPMIMEType type, |
| 130 NPStream *stream, |
| 131 NPBool seekable, |
| 132 uint16 *stype); |
| 99 | 133 |
| 100 NPError PlatformNPPGetValue(NPP instance, NPPVariable variable, void *value); | 134 NPError PlatformNPPGetValue(NPP instance, NPPVariable variable, void *value); |
| 135 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); |
| 136 NPError NPP_SetWindow(NPP instance, NPWindow *window); |
| 101 | 137 |
| 102 // NPAPI declarations. Some of these are only implemented in the | 138 int32 NPP_Write(NPP instance, |
| 103 // platform-specific versions of "main.cc". | 139 NPStream *stream, |
| 140 int32 offset, |
| 141 int32 len, |
| 142 void *buffer); |
| 104 | 143 |
| 105 extern "C" { | 144 int32 NPP_WriteReady(NPP instance, NPStream *stream); |
| 106 NPError OSCALL NP_Shutdown(void); | 145 void NPP_Print(NPP instance, NPPrint *platformPrint); |
| 107 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); | 146 int16 NPP_HandleEvent(NPP instance, void *event); |
| 108 NPError NPP_Destroy(NPP instance, NPSavedData **save); | |
| 109 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason); | |
| 110 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); | |
| 111 | 147 |
| 112 NPError NPP_New(NPMIMEType pluginType, | 148 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname); |
| 113 NPP instance, | |
| 114 uint16 mode, | |
| 115 int16 argc, | |
| 116 char *argn[], | |
| 117 char *argv[], | |
| 118 NPSavedData *saved); | |
| 119 | 149 |
| 120 NPError NPP_NewStream(NPP instance, | 150 void NPP_URLNotify(NPP instance, |
| 121 NPMIMEType type, | 151 const char *url, |
| 122 NPStream *stream, | 152 NPReason reason, |
| 123 NPBool seekable, | 153 void *notifyData); |
| 124 uint16 *stype); | 154 }; // namespace o3d |
| 125 | |
| 126 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); | |
| 127 NPError NPP_SetWindow(NPP instance, NPWindow *window); | |
| 128 | |
| 129 int32 NPP_Write(NPP instance, | |
| 130 NPStream *stream, | |
| 131 int32 offset, | |
| 132 int32 len, | |
| 133 void *buffer); | |
| 134 | |
| 135 int32 NPP_WriteReady(NPP instance, NPStream *stream); | |
| 136 void NPP_Print(NPP instance, NPPrint *platformPrint); | |
| 137 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname); | |
| 138 | |
| 139 void NPP_URLNotify(NPP instance, | |
| 140 const char *url, | |
| 141 NPReason reason, | |
| 142 void *notifyData); | |
| 143 }; // end extern "C" | |
| 144 | 155 |
| 145 #endif // O3D_PLUGIN_CROSS_MAIN_H_ | 156 #endif // O3D_PLUGIN_CROSS_MAIN_H_ |
| OLD | NEW |