LCOV - app.info - dom/plugins/base/nsNPAPIPluginStreamListener.h

LCOV - code coverage report
| Current view: | directory - dom/plugins/base - nsNPAPIPluginStreamListener.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 30 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 11 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is mozilla.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : #ifndef nsNPAPIPluginStreamListener_h_
          39                 : #define nsNPAPIPluginStreamListener_h_
          40                 :
          41                 : #include "nscore.h"
          42                 : #include "nsIPluginStreamListener.h"
          43                 : #include "nsIPluginStreamInfo.h"
          44                 : #include "nsIHTTPHeaderListener.h"
          45                 : #include "nsIRequest.h"
          46                 : #include "nsITimer.h"
          47                 : #include "nsAutoPtr.h"
          48                 : #include "nsCOMArray.h"
          49                 : #include "nsIOutputStream.h"
          50                 : #include "nsIPluginInstanceOwner.h"
          51                 : #include "nsString.h"
          52                 : #include "nsNPAPIPluginInstance.h"
          53                 : #include "nsIAsyncVerifyRedirectCallback.h"
          54                 : #include "mozilla/PluginLibrary.h"
          55                 :
          56                 : #define MAX_PLUGIN_NECKO_BUFFER 16384
          57                 :
          58                 : class nsINPAPIPluginStreamInfo;
          59                 : class nsPluginStreamListenerPeer;
          60                 :
          61                 : // nsINPAPIPluginStreamInfo is an internal helper interface that exposes
          62                 : // the underlying necko request to consumers of nsIPluginStreamInfo's.
          63                 : #define NS_INPAPIPLUGINSTREAMINFO_IID       \
          64                 : { 0x097fdaaa, 0xa2a3, 0x49c2, \
          65                 : {0x91, 0xee, 0xeb, 0xc5, 0x7d, 0x6c, 0x9c, 0x97} }
          66                 :
          67                 : class nsINPAPIPluginStreamInfo : public nsIPluginStreamInfo
          68               0 : {
          69                 : public:
          70                 :   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INPAPIPLUGINSTREAMINFO_IID)
          71                 :
          72               0 :   void TrackRequest(nsIRequest* request)
          73                 :   {
          74               0 :     mRequests.AppendObject(request);
          75               0 :   }
          76                 :
          77               0 :   void ReplaceRequest(nsIRequest* oldRequest, nsIRequest* newRequest)
          78                 :   {
          79               0 :     PRInt32 i = mRequests.IndexOfObject(oldRequest);
          80               0 :     if (i == -1) {
          81               0 :       NS_ASSERTION(mRequests.Count() == 0,
          82                 :                    "Only our initial stream should be unknown!");
          83               0 :       mRequests.AppendObject(oldRequest);
          84                 :     }
          85                 :     else {
          86               0 :       mRequests.ReplaceObjectAt(newRequest, i);
          87                 :     }
          88               0 :   }
          89                 :
          90               0 :   void CancelRequests(nsresult status)
          91                 :   {
          92                 :     // Copy the array to avoid modification during the loop.
          93               0 :     nsCOMArray<nsIRequest> requestsCopy(mRequests);
          94               0 :     for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
          95               0 :       requestsCopy[i]->Cancel(status);
          96               0 :   }
          97                 :
          98               0 :   void SuspendRequests() {
          99               0 :     nsCOMArray<nsIRequest> requestsCopy(mRequests);
         100               0 :     for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
         101               0 :       requestsCopy[i]->Suspend();
         102               0 :   }
         103                 :
         104               0 :   void ResumeRequests() {
         105               0 :     nsCOMArray<nsIRequest> requestsCopy(mRequests);
         106               0 :     for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
         107               0 :       requestsCopy[i]->Resume();
         108               0 :   }
         109                 :
         110                 : protected:
         111                 :   friend class nsPluginByteRangeStreamListener;
         112                 :
         113                 :   nsCOMArray<nsIRequest> mRequests;
         114                 : };
         115                 :
         116                 : NS_DEFINE_STATIC_IID_ACCESSOR(nsINPAPIPluginStreamInfo,
         117                 :                               NS_INPAPIPLUGINSTREAMINFO_IID)
         118                 :
         119                 : // Used to handle NPN_NewStream() - writes the stream as received by the plugin
         120                 : // to a file and at completion (NPN_DestroyStream), tells the browser to load it into
         121                 : // a plugin-specified target
         122                 : class nsPluginStreamToFile : public nsIOutputStream
         123                 : {
         124                 : public:
         125                 :   nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner);
         126                 :   virtual ~nsPluginStreamToFile();
         127                 :
         128                 :   NS_DECL_ISUPPORTS
         129                 :   NS_DECL_NSIOUTPUTSTREAM
         130                 : protected:
         131                 :   char* mTarget;
         132                 :   nsCString mFileURL;
         133                 :   nsCOMPtr<nsILocalFile> mTempFile;
         134                 :   nsCOMPtr<nsIOutputStream> mOutputStream;
         135                 :   nsIPluginInstanceOwner* mOwner;
         136                 : };
         137                 :
         138                 : class nsNPAPIPluginStreamListener : public nsIPluginStreamListener,
         139                 :                                     public nsITimerCallback,
         140                 :                                     public nsIHTTPHeaderListener
         141                 : {
         142                 : private:
         143                 :   typedef mozilla::PluginLibrary PluginLibrary;
         144                 :
         145                 : public:
         146                 :   NS_DECL_ISUPPORTS
         147                 :   NS_DECL_NSIPLUGINSTREAMLISTENER
         148                 :   NS_DECL_NSITIMERCALLBACK
         149                 :   NS_DECL_NSIHTTPHEADERLISTENER
         150                 :
         151                 :   nsNPAPIPluginStreamListener(nsNPAPIPluginInstance* inst, void* notifyData,
         152                 :                               const char* aURL);
         153                 :   virtual ~nsNPAPIPluginStreamListener();
         154                 :
         155                 :   bool IsStarted();
         156                 :   nsresult CleanUpStream(NPReason reason);
         157                 :   void CallURLNotify(NPReason reason);
         158               0 :   void SetCallNotify(bool aCallNotify) { mCallNotify = aCallNotify; }
         159                 :   void SuspendRequest();
         160                 :   void ResumeRequest();
         161                 :   nsresult StartDataPump();
         162                 :   void StopDataPump();
         163                 :   bool PluginInitJSLoadInProgress();
         164                 :
         165               0 :   void* GetNotifyData() { return mNPStream.notifyData; }
         166               0 :   nsPluginStreamListenerPeer* GetStreamListenerPeer() { return mStreamListenerPeer; }
         167               0 :   void SetStreamListenerPeer(nsPluginStreamListenerPeer* aPeer) { mStreamListenerPeer = aPeer; }
         168                 :
         169                 :   // Returns true if the redirect will be handled by NPAPI, false otherwise.
         170                 :   bool HandleRedirectNotification(nsIChannel *oldChannel, nsIChannel *newChannel,
         171                 :                                   nsIAsyncVerifyRedirectCallback* callback);
         172                 :   void URLRedirectResponse(NPBool allow);
         173                 :
         174                 : protected:
         175                 :   char* mStreamBuffer;
         176                 :   char* mNotifyURL;
         177                 :   nsRefPtr<nsNPAPIPluginInstance> mInst;
         178                 :   nsPluginStreamListenerPeer* mStreamListenerPeer;
         179                 :   NPStream mNPStream;
         180                 :   PRUint32 mStreamBufferSize;
         181                 :   PRInt32 mStreamBufferByteCount;
         182                 :   PRInt32 mStreamType;
         183                 :   bool mStreamStarted;
         184                 :   bool mStreamCleanedUp;
         185                 :   bool mCallNotify;
         186                 :   bool mIsSuspended;
         187                 :   bool mIsPluginInitJSStream;
         188                 :   bool mRedirectDenied;
         189                 :   nsCString mResponseHeaders;
         190                 :   char* mResponseHeaderBuf;
         191                 :   nsCOMPtr<nsITimer> mDataPumpTimer;
         192                 :   nsCOMPtr<nsIAsyncVerifyRedirectCallback> mHTTPRedirectCallback;
         193                 :
         194                 : public:
         195                 :   nsCOMPtr<nsIPluginStreamInfo> mStreamInfo;
         196                 : };
         197                 :
         198                 : #endif // nsNPAPIPluginStreamListener_h_

Generated by: LCOV version 1.7