LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla/plugins - PluginModuleParent.h (source / functions) Found Hit Coverage
Test: app.info Lines: 9 0 0.0 %
Date: 2012-06-02 Functions: 5 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * vim: sw=4 ts=4 et :
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Plugin App.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  *   Chris Jones <jones.chris.g@gmail.com>
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2009
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef dom_plugins_PluginModuleParent_h
      40                 : #define dom_plugins_PluginModuleParent_h 1
      41                 : 
      42                 : #include <cstring>
      43                 : 
      44                 : #include "base/basictypes.h"
      45                 : 
      46                 : #include "prlink.h"
      47                 : 
      48                 : #include "npapi.h"
      49                 : #include "npfunctions.h"
      50                 : 
      51                 : #include "base/string_util.h"
      52                 : 
      53                 : #include "mozilla/FileUtils.h"
      54                 : #include "mozilla/PluginLibrary.h"
      55                 : #include "mozilla/plugins/PPluginModuleParent.h"
      56                 : #include "mozilla/plugins/PluginInstanceParent.h"
      57                 : #include "mozilla/plugins/PluginProcessParent.h"
      58                 : #include "mozilla/plugins/PluginIdentifierParent.h"
      59                 : 
      60                 : #include "nsAutoPtr.h"
      61                 : #include "nsDataHashtable.h"
      62                 : #include "nsHashKeys.h"
      63                 : #include "nsIFileStreams.h"
      64                 : 
      65                 : namespace mozilla {
      66                 : namespace dom {
      67                 : class PCrashReporterParent;
      68                 : class CrashReporterParent;
      69                 : }
      70                 : 
      71                 : namespace plugins {
      72                 : //-----------------------------------------------------------------------------
      73                 : 
      74                 : class BrowserStreamParent;
      75                 : 
      76                 : /**
      77                 :  * PluginModuleParent
      78                 :  *
      79                 :  * This class implements the NPP API from the perspective of the rest
      80                 :  * of Gecko, forwarding NPP calls along to the child process that is
      81                 :  * actually running the plugin.
      82                 :  *
      83                 :  * This class /also/ implements a version of the NPN API, because the
      84                 :  * child process needs to make these calls back into Gecko proper.
      85                 :  * This class is responsible for "actually" making those function calls.
      86                 :  */
      87                 : class PluginModuleParent : public PPluginModuleParent, PluginLibrary
      88                 : {
      89                 : private:
      90                 :     typedef mozilla::PluginLibrary PluginLibrary;
      91                 :     typedef mozilla::dom::PCrashReporterParent PCrashReporterParent;
      92                 :     typedef mozilla::dom::CrashReporterParent CrashReporterParent;
      93                 : 
      94                 : protected:
      95                 : 
      96                 :     virtual PPluginIdentifierParent*
      97                 :     AllocPPluginIdentifier(const nsCString& aString,
      98                 :                            const int32_t& aInt,
      99                 :                            const bool& aTemporary);
     100                 : 
     101                 :     virtual bool
     102                 :     DeallocPPluginIdentifier(PPluginIdentifierParent* aActor);
     103                 : 
     104                 :     PPluginInstanceParent*
     105                 :     AllocPPluginInstance(const nsCString& aMimeType,
     106                 :                          const uint16_t& aMode,
     107                 :                          const InfallibleTArray<nsCString>& aNames,
     108                 :                          const InfallibleTArray<nsCString>& aValues,
     109                 :                          NPError* rv);
     110                 : 
     111                 :     virtual bool
     112                 :     DeallocPPluginInstance(PPluginInstanceParent* aActor);
     113                 : 
     114                 : public:
     115                 :     // aFilePath is UTF8, not native!
     116                 :     PluginModuleParent(const char* aFilePath);
     117                 :     virtual ~PluginModuleParent();
     118                 : 
     119               0 :     NS_OVERRIDE virtual void SetPlugin(nsNPAPIPlugin* plugin)
     120                 :     {
     121               0 :         mPlugin = plugin;
     122               0 :     }
     123                 : 
     124                 :     NS_OVERRIDE virtual void ActorDestroy(ActorDestroyReason why);
     125                 : 
     126                 :     /**
     127                 :      * LoadModule
     128                 :      *
     129                 :      * This may or may not launch a plugin child process,
     130                 :      * and may or may not be very expensive.
     131                 :      */
     132                 :     static PluginLibrary* LoadModule(const char* aFilePath);
     133                 : 
     134                 :     const NPNetscapeFuncs* GetNetscapeFuncs() {
     135                 :         return mNPNIface;
     136                 :     }
     137                 : 
     138                 :     PluginProcessParent* Process() const { return mSubprocess; }
     139                 :     base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
     140                 : 
     141               0 :     bool OkToCleanup() const {
     142               0 :         return !IsOnCxxStack();
     143                 :     }
     144                 : 
     145                 :     /**
     146                 :      * Get an identifier actor for this NPIdentifier. If this is a temporary
     147                 :      * identifier, the temporary refcount is increased by one. This method
     148                 :      * is intended only for use by StackIdentifier and the scriptable
     149                 :      * Enumerate hook.
     150                 :      */
     151                 :     PluginIdentifierParent*
     152                 :     GetIdentifierForNPIdentifier(NPP npp, NPIdentifier aIdentifier);
     153                 : 
     154                 :     void ProcessRemoteNativeEventsInRPCCall();
     155                 : 
     156                 : protected:
     157                 :     NS_OVERRIDE
     158                 :     virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
     159               0 :     MediateRPCRace(const Message& parent, const Message& child)
     160                 :     {
     161               0 :         return MediateRace(parent, child);
     162                 :     }
     163                 : 
     164               0 :     virtual bool RecvXXX_HACK_FIXME_cjones(Shmem& mem) { NS_RUNTIMEABORT("not reached"); return false; }
     165                 : 
     166                 :     NS_OVERRIDE
     167                 :     virtual bool ShouldContinueFromReplyTimeout();
     168                 : 
     169                 :     NS_OVERRIDE
     170                 :     virtual bool
     171                 :     RecvBackUpXResources(const FileDescriptor& aXSocketFd);
     172                 : 
     173                 :     virtual bool
     174                 :     AnswerNPN_UserAgent(nsCString* userAgent);
     175                 : 
     176                 :     virtual bool
     177                 :     AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
     178                 :                                       NPError* aError,
     179                 :                                       bool* aBoolVal);
     180                 : 
     181                 :     NS_OVERRIDE
     182                 :     virtual bool AnswerProcessSomeEvents();
     183                 : 
     184                 :     NS_OVERRIDE virtual bool
     185                 :     RecvProcessNativeEventsInRPCCall();
     186                 : 
     187                 :     NS_OVERRIDE virtual bool
     188                 :     RecvPluginShowWindow(const uint32_t& aWindowId, const bool& aModal,
     189                 :                          const int32_t& aX, const int32_t& aY,
     190                 :                          const size_t& aWidth, const size_t& aHeight);
     191                 : 
     192                 :     NS_OVERRIDE virtual bool
     193                 :     RecvPluginHideWindow(const uint32_t& aWindowId);
     194                 : 
     195                 :     NS_OVERRIDE virtual PCrashReporterParent*
     196                 :     AllocPCrashReporter(mozilla::dom::NativeThreadId* id,
     197                 :                         PRUint32* processType);
     198                 :     NS_OVERRIDE virtual bool
     199                 :     DeallocPCrashReporter(PCrashReporterParent* actor);
     200                 : 
     201                 :     NS_OVERRIDE virtual bool
     202                 :     RecvSetCursor(const NSCursorInfo& aCursorInfo);
     203                 : 
     204                 :     NS_OVERRIDE virtual bool
     205                 :     RecvShowCursor(const bool& aShow);
     206                 : 
     207                 :     NS_OVERRIDE virtual bool
     208                 :     RecvPushCursor(const NSCursorInfo& aCursorInfo);
     209                 : 
     210                 :     NS_OVERRIDE virtual bool
     211                 :     RecvPopCursor();
     212                 : 
     213                 :     NS_OVERRIDE virtual bool
     214                 :     RecvGetNativeCursorsSupported(bool* supported);
     215                 : 
     216                 :     NS_OVERRIDE virtual bool
     217                 :     RecvNPN_SetException(PPluginScriptableObjectParent* aActor,
     218                 :                          const nsCString& aMessage);
     219                 : 
     220                 :     static PluginInstanceParent* InstCast(NPP instance);
     221                 :     static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
     222                 : 
     223                 : private:
     224                 :     void SetPluginFuncs(NPPluginFuncs* aFuncs);
     225                 : 
     226                 :     // Implement the module-level functions from NPAPI; these are
     227                 :     // normally resolved directly from the DSO.
     228                 : #ifdef OS_LINUX
     229                 :     NPError NP_Initialize(const NPNetscapeFuncs* npnIface,
     230                 :                           NPPluginFuncs* nppIface);
     231                 : #else
     232                 :     NPError NP_Initialize(const NPNetscapeFuncs* npnIface);
     233                 :     NPError NP_GetEntryPoints(NPPluginFuncs* nppIface);
     234                 : #endif
     235                 : 
     236                 :     // NPP-like API that Gecko calls are trampolined into.  These 
     237                 :     // messages then get forwarded along to the plugin instance,
     238                 :     // and then eventually the child process.
     239                 : 
     240                 :     static NPError NPP_Destroy(NPP instance, NPSavedData** save);
     241                 : 
     242                 :     static NPError NPP_SetWindow(NPP instance, NPWindow* window);
     243                 :     static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
     244                 :                                  NPBool seekable, uint16_t* stype);
     245                 :     static NPError NPP_DestroyStream(NPP instance,
     246                 :                                      NPStream* stream, NPReason reason);
     247                 :     static int32_t NPP_WriteReady(NPP instance, NPStream* stream);
     248                 :     static int32_t NPP_Write(NPP instance, NPStream* stream,
     249                 :                              int32_t offset, int32_t len, void* buffer);
     250                 :     static void NPP_StreamAsFile(NPP instance,
     251                 :                                  NPStream* stream, const char* fname);
     252                 :     static void NPP_Print(NPP instance, NPPrint* platformPrint);
     253                 :     static int16_t NPP_HandleEvent(NPP instance, void* event);
     254                 :     static void NPP_URLNotify(NPP instance, const char* url,
     255                 :                               NPReason reason, void* notifyData);
     256                 :     static NPError NPP_GetValue(NPP instance,
     257                 :                                 NPPVariable variable, void *ret_value);
     258                 :     static NPError NPP_SetValue(NPP instance, NPNVariable variable,
     259                 :                                 void *value);
     260                 :     static void NPP_URLRedirectNotify(NPP instance, const char* url,
     261                 :                                       int32_t status, void* notifyData);
     262                 : 
     263                 :     virtual bool HasRequiredFunctions();
     264                 :     virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window);
     265                 :     virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer);
     266                 :     virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize);
     267               0 :     NS_OVERRIDE virtual bool UseAsyncPainting() { return true; }
     268                 :     NS_OVERRIDE
     269                 :     virtual nsresult SetBackgroundUnknown(NPP instance);
     270                 :     NS_OVERRIDE
     271                 :     virtual nsresult BeginUpdateBackground(NPP instance,
     272                 :                                            const nsIntRect& aRect,
     273                 :                                            gfxContext** aCtx);
     274                 :     NS_OVERRIDE
     275                 :     virtual nsresult EndUpdateBackground(NPP instance,
     276                 :                                          gfxContext* aCtx,
     277                 :                                          const nsIntRect& aRect);
     278                 : 
     279                 : #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
     280                 :     virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);
     281                 : #else
     282                 :     virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
     283                 : #endif
     284                 :     virtual nsresult NP_Shutdown(NPError* error);
     285                 :     virtual nsresult NP_GetMIMEDescription(const char** mimeDesc);
     286                 :     virtual nsresult NP_GetValue(void *future, NPPVariable aVariable,
     287                 :                                  void *aValue, NPError* error);
     288                 : #if defined(XP_WIN) || defined(XP_MACOSX) || defined(XP_OS2)
     289                 :     virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error);
     290                 : #endif
     291                 :     virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance,
     292                 :                              uint16_t mode, int16_t argc, char* argn[],
     293                 :                              char* argv[], NPSavedData* saved,
     294                 :                              NPError* error);
     295                 :     virtual nsresult NPP_ClearSiteData(const char* site, uint64_t flags,
     296                 :                                        uint64_t maxAge);
     297                 :     virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result);
     298                 : 
     299                 : #if defined(XP_MACOSX)
     300                 :     virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing);
     301                 : #endif
     302                 : #if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
     303                 :     virtual nsresult HandleGUIEvent(NPP instance, const nsGUIEvent& anEvent,
     304                 :                                     bool* handled);
     305                 : #endif
     306                 : 
     307                 : private:
     308                 :     CrashReporterParent* CrashReporter();
     309                 : 
     310                 : #ifdef MOZ_CRASHREPORTER
     311                 :     void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes);
     312                 : #endif
     313                 :     void CleanupFromTimeout();
     314                 :     static int TimeoutChanged(const char* aPref, void* aModule);
     315                 :     void NotifyPluginCrashed();
     316                 : 
     317                 :     PluginProcessParent* mSubprocess;
     318                 :     // the plugin thread in mSubprocess
     319                 :     NativeThreadId mPluginThread;
     320                 :     bool mShutdown;
     321                 :     bool mClearSiteDataSupported;
     322                 :     bool mGetSitesWithDataSupported;
     323                 :     const NPNetscapeFuncs* mNPNIface;
     324                 :     nsDataHashtable<nsVoidPtrHashKey, PluginIdentifierParent*> mIdentifiers;
     325                 :     nsNPAPIPlugin* mPlugin;
     326                 :     ScopedRunnableMethodFactory<PluginModuleParent> mTaskFactory;
     327                 :     nsString mPluginDumpID;
     328                 :     nsString mBrowserDumpID;
     329                 :     nsString mHangID;
     330                 : 
     331                 : #ifdef MOZ_X11
     332                 :     // Dup of plugin's X socket, used to scope its resources to this
     333                 :     // object instead of the plugin process's lifetime
     334                 :     ScopedClose mPluginXSocketFdDup;
     335                 : #endif
     336                 : 
     337                 :     friend class mozilla::dom::CrashReporterParent;
     338                 : };
     339                 : 
     340                 : } // namespace plugins
     341                 : } // namespace mozilla
     342                 : 
     343                 : #endif  // ifndef dom_plugins_PluginModuleParent_h

Generated by: LCOV version 1.7