зеркало из https://github.com/mozilla/gecko-dev.git
Threaded plugin sample code, not part of the build
This commit is contained in:
Родитель
e1f417638e
Коммит
d3ea494b95
|
@ -34,3 +34,54 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __ACTION_H__
|
||||
#define __ACTION_H__
|
||||
|
||||
#include "npapi.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
action_invalid = 0,
|
||||
action_npn_version,
|
||||
action_npn_get_url_notify,
|
||||
action_npn_get_url,
|
||||
action_npn_post_url_notify,
|
||||
action_npn_post_url,
|
||||
action_npn_request_read,
|
||||
action_npn_new_stream,
|
||||
action_npn_write,
|
||||
action_npn_destroy_stream,
|
||||
action_npn_status,
|
||||
action_npn_user_agent,
|
||||
action_npn_mem_alloc,
|
||||
action_npn_mem_free,
|
||||
action_npn_mem_flush,
|
||||
action_npn_reload_plugins,
|
||||
action_npn_get_java_env,
|
||||
action_npn_get_java_peer,
|
||||
action_npn_get_value,
|
||||
action_npn_set_value,
|
||||
action_npn_invalidate_rect,
|
||||
action_npn_invalidate_region,
|
||||
action_npn_force_redraw,
|
||||
|
||||
action_npp_new, // 23
|
||||
action_npp_destroy,
|
||||
action_npp_set_window,
|
||||
action_npp_new_stream,
|
||||
action_npp_destroy_stream,
|
||||
action_npp_stream_as_file,
|
||||
action_npp_write_ready,
|
||||
action_npp_write,
|
||||
action_npp_print,
|
||||
action_npp_handle_event,
|
||||
action_npp_url_notify,
|
||||
action_npp_get_java_class,
|
||||
action_npp_get_value,
|
||||
action_npp_set_value
|
||||
} npapiAction;
|
||||
|
||||
char * FormatAction(int aAction);
|
||||
|
||||
#endif // __ACTION_H__
|
||||
|
|
|
@ -34,3 +34,32 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __DBG_HPP_
|
||||
#define __DBG_HPP_
|
||||
|
||||
#ifdef NTRACE
|
||||
|
||||
#define dbgOut1(x) ((void)0)
|
||||
#define dbgOut2(x,y) ((void)0)
|
||||
#define dbgOut3(x,y,z) ((void)0)
|
||||
#define dbgOut4(x,y,z,t) ((void)0)
|
||||
#define dbgOut5(x,y,z,t,u) ((void)0)
|
||||
#define dbgOut6(x,y,z,t,u,v) ((void)0)
|
||||
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
|
||||
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
|
||||
|
||||
#else
|
||||
|
||||
void __cdecl dbgOut(LPSTR format, ...);
|
||||
#define dbgOut1(x) dbgOut(x)
|
||||
#define dbgOut2(x,y) dbgOut(x, y)
|
||||
#define dbgOut3(x,y,z) dbgOut(x, y, z)
|
||||
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
|
||||
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
|
||||
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
|
||||
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
|
||||
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -34,3 +34,37 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _PLUGIN_H_
|
||||
#define _PLUGIN_H_
|
||||
|
||||
#include "thread.h"
|
||||
#include "action.h"
|
||||
|
||||
class nsPluginThread : CThread
|
||||
{
|
||||
public:
|
||||
nsPluginThread(DWORD aP1);
|
||||
~nsPluginThread();
|
||||
|
||||
private:
|
||||
BOOL init();
|
||||
void shut();
|
||||
void dispatch();
|
||||
|
||||
public:
|
||||
DWORD callNPP(npapiAction aAction, DWORD aP1=NULL,
|
||||
DWORD aP2=NULL, DWORD aP3=NULL, DWORD aP4=NULL,
|
||||
DWORD aP5=NULL, DWORD aP6=NULL, DWORD aP7=NULL);
|
||||
|
||||
private:
|
||||
DWORD mP1;
|
||||
DWORD mP2;
|
||||
DWORD mP3;
|
||||
DWORD mP4;
|
||||
DWORD mP5;
|
||||
DWORD mP6;
|
||||
DWORD mP7;
|
||||
};
|
||||
|
||||
#endif // _PLUGIN_H_
|
||||
|
|
|
@ -34,3 +34,12 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __PLUGLOAD_H__
|
||||
#define __PLUGLOAD_H__
|
||||
|
||||
DWORD GetPluginsDir(char * path, DWORD maxsize);
|
||||
HINSTANCE LoadRealPlugin(char * mimetype);
|
||||
void UnloadRealPlugin(HINSTANCE hLib);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,3 +34,57 @@
|
|||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __THREAD_H__
|
||||
#define __THREAD_H__
|
||||
|
||||
typedef enum {
|
||||
ts_dead = 0,
|
||||
ts_ready,
|
||||
ts_busy
|
||||
|
||||
} ThreadState;
|
||||
|
||||
class CThread {
|
||||
private:
|
||||
HANDLE mThread;
|
||||
DWORD mID;
|
||||
HANDLE mEventThreadInitializationFinished;
|
||||
HANDLE mEventThreadShutdownFinished;
|
||||
DWORD mInitTimeOut;
|
||||
DWORD mShutTimeOut;
|
||||
HANDLE mEventDo;
|
||||
ThreadState mState;
|
||||
|
||||
protected:
|
||||
int mAction;
|
||||
|
||||
public:
|
||||
BOOL setInitEvent();
|
||||
BOOL setShutEvent();
|
||||
BOOL isAlive();
|
||||
BOOL isBusy();
|
||||
HANDLE getHandle();
|
||||
|
||||
void run();
|
||||
|
||||
// outside thread interface
|
||||
CThread(DWORD aInitTimeOut = INFINITE, DWORD aShutTimeOut = INFINITE);
|
||||
virtual ~CThread();
|
||||
|
||||
BOOL open(CThread * aThread);
|
||||
void close(CThread * aThread);
|
||||
|
||||
BOOL tryAction(int aAction);
|
||||
BOOL doAction(int aAction);
|
||||
|
||||
// virtuals
|
||||
virtual BOOL init() = 0;
|
||||
virtual void shut() = 0;
|
||||
virtual void dispatch() = 0;
|
||||
};
|
||||
|
||||
BOOL InitThreadLib(HINSTANCE aInstance);
|
||||
void ShutThreadLib(HINSTANCE aInstance);
|
||||
|
||||
#endif // THREAD_HPP__
|
||||
|
|
Загрузка…
Ссылка в новой задаче