LCOV - code coverage report
Current view: directory - embedding/components/webbrowserpersist/src - nsWebBrowserPersist.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 0 0.0 %
Date: 2012-06-02 Functions: 2 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  *
       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 the Mozilla browser.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Netscape Communications, Inc.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 1999
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Adam Lock <adamlock@netscape.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #ifndef nsWebBrowserPersist_h__
      41                 : #define nsWebBrowserPersist_h__
      42                 : 
      43                 : #include "nsCOMPtr.h"
      44                 : #include "nsWeakReference.h"
      45                 : 
      46                 : #include "nsIInterfaceRequestor.h"
      47                 : #include "nsIMIMEService.h"
      48                 : #include "nsIStreamListener.h"
      49                 : #include "nsIOutputStream.h"
      50                 : #include "nsIInputStream.h"
      51                 : #include "nsIChannel.h"
      52                 : #include "nsIStyleSheet.h"
      53                 : #include "nsIDocumentEncoder.h"
      54                 : #include "nsITransport.h"
      55                 : #include "nsIProgressEventSink.h"
      56                 : #include "nsILocalFile.h"
      57                 : #include "nsIWebProgressListener2.h"
      58                 : 
      59                 : #include "nsHashtable.h"
      60                 : #include "nsTArray.h"
      61                 : 
      62                 : #include "nsCWebBrowserPersist.h"
      63                 : 
      64                 : class nsEncoderNodeFixup;
      65                 : class nsIStorageStream;
      66                 : 
      67                 : struct URIData;
      68                 : struct CleanupData;
      69                 : struct DocData;
      70                 : 
      71                 : class nsWebBrowserPersist : public nsIInterfaceRequestor,
      72                 :                             public nsIWebBrowserPersist,
      73                 :                             public nsIStreamListener,
      74                 :                             public nsIProgressEventSink,
      75                 :                             public nsSupportsWeakReference
      76                 : {
      77                 :     friend class nsEncoderNodeFixup;
      78                 : 
      79                 : // Public members
      80                 : public:
      81                 :     nsWebBrowserPersist();
      82                 :     
      83                 :     NS_DECL_ISUPPORTS
      84                 :     NS_DECL_NSIINTERFACEREQUESTOR
      85                 :     NS_DECL_NSICANCELABLE
      86                 :     NS_DECL_NSIWEBBROWSERPERSIST
      87                 :     NS_DECL_NSIREQUESTOBSERVER
      88                 :     NS_DECL_NSISTREAMLISTENER
      89                 :     NS_DECL_NSIPROGRESSEVENTSINK
      90                 : 
      91                 : // Protected members
      92                 : protected:    
      93                 :     virtual ~nsWebBrowserPersist();
      94                 :     nsresult CloneNodeWithFixedUpAttributes(
      95                 :         nsIDOMNode *aNodeIn, bool *aSerializeCloneKids, nsIDOMNode **aNodeOut);
      96                 :     nsresult SaveURIInternal(
      97                 :         nsIURI *aURI, nsISupports *aCacheKey, nsIURI *aReferrer,
      98                 :         nsIInputStream *aPostData, const char *aExtraHeaders, nsIURI *aFile,
      99                 :         bool aCalcFileExt);
     100                 :     nsresult SaveChannelInternal(
     101                 :         nsIChannel *aChannel, nsIURI *aFile, bool aCalcFileExt);
     102                 :     nsresult SaveDocumentInternal(
     103                 :         nsIDOMDocument *aDocument, nsIURI *aFile, nsIURI *aDataPath);
     104                 :     nsresult SaveDocuments();
     105                 :     nsresult GetDocEncoderContentType(
     106                 :         nsIDOMDocument *aDocument, const PRUnichar *aContentType,
     107                 :         PRUnichar **aRealContentType);
     108                 :     nsresult GetExtensionForContentType(
     109                 :         const PRUnichar *aContentType, PRUnichar **aExt);
     110                 :     nsresult GetDocumentExtension(nsIDOMDocument *aDocument, PRUnichar **aExt);
     111                 : 
     112                 : // Private members
     113                 : private:
     114                 :     void Cleanup();
     115                 :     void CleanupLocalFiles();
     116                 :     nsresult GetValidURIFromObject(nsISupports *aObject, nsIURI **aURI) const;
     117                 :     nsresult GetLocalFileFromURI(nsIURI *aURI, nsILocalFile **aLocalFile) const;
     118                 :     nsresult AppendPathToURI(nsIURI *aURI, const nsAString & aPath) const;
     119                 :     nsresult MakeAndStoreLocalFilenameInURIMap(
     120                 :         nsIURI *aURI, bool aNeedsPersisting, URIData **aData);
     121                 :     nsresult MakeOutputStream(
     122                 :         nsIURI *aFile, nsIOutputStream **aOutputStream);
     123                 :     nsresult MakeOutputStreamFromFile(
     124                 :         nsILocalFile *aFile, nsIOutputStream **aOutputStream);
     125                 :     nsresult MakeOutputStreamFromURI(nsIURI *aURI, nsIOutputStream  **aOutStream);
     126                 :     nsresult CreateChannelFromURI(nsIURI *aURI, nsIChannel **aChannel);
     127                 :     nsresult StartUpload(nsIStorageStream *aOutStream, nsIURI *aDestinationURI,
     128                 :         const nsACString &aContentType);
     129                 :     nsresult StartUpload(nsIInputStream *aInputStream, nsIURI *aDestinationURI,
     130                 :         const nsACString &aContentType);
     131                 :     nsresult CalculateAndAppendFileExt(nsIURI *aURI, nsIChannel *aChannel,
     132                 :         nsIURI *aOriginalURIWithExtension);
     133                 :     nsresult CalculateUniqueFilename(nsIURI *aURI);
     134                 :     nsresult MakeFilenameFromURI(
     135                 :         nsIURI *aURI, nsString &aFilename);
     136                 :     nsresult StoreURI(
     137                 :         const char *aURI,
     138                 :         bool aNeedsPersisting = true,
     139                 :         URIData **aData = nsnull);
     140                 :     nsresult StoreURI(
     141                 :         nsIURI *aURI,
     142                 :         bool aNeedsPersisting = true,
     143                 :         URIData **aData = nsnull);
     144                 :     nsresult StoreURIAttributeNS(
     145                 :         nsIDOMNode *aNode, const char *aNamespaceURI, const char *aAttribute,
     146                 :         bool aNeedsPersisting = true,
     147                 :         URIData **aData = nsnull);
     148               0 :     nsresult StoreURIAttribute(
     149                 :         nsIDOMNode *aNode, const char *aAttribute,
     150                 :         bool aNeedsPersisting = true,
     151                 :         URIData **aData = nsnull)
     152                 :     {
     153               0 :         return StoreURIAttributeNS(aNode, "", aAttribute, aNeedsPersisting, aData);
     154                 :     }
     155                 :     bool DocumentEncoderExists(const PRUnichar *aContentType);
     156                 : 
     157                 :     nsresult GetNodeToFixup(nsIDOMNode *aNodeIn, nsIDOMNode **aNodeOut);
     158                 :     nsresult FixupURI(nsAString &aURI);
     159                 :     nsresult FixupNodeAttributeNS(nsIDOMNode *aNode, const char *aNamespaceURI, const char *aAttribute);
     160               0 :     nsresult FixupNodeAttribute(nsIDOMNode *aNode, const char *aAttribute)
     161                 :     {
     162               0 :         return FixupNodeAttributeNS(aNode, "", aAttribute);
     163                 :     }
     164                 :     nsresult FixupAnchor(nsIDOMNode *aNode);
     165                 :     nsresult FixupXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, const nsAString &aHref);
     166                 :     nsresult GetXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, nsAString &aHref);
     167                 : 
     168                 :     nsresult StoreAndFixupStyleSheet(nsIStyleSheet *aStyleSheet);
     169                 :     nsresult SaveDocumentWithFixup(
     170                 :         nsIDOMDocument *pDocument, nsIDocumentEncoderNodeFixup *pFixup,
     171                 :         nsIURI *aFile, bool aReplaceExisting, const nsACString &aFormatType,
     172                 :         const nsCString &aSaveCharset, PRUint32  aFlags);
     173                 :     nsresult SaveSubframeContent(
     174                 :         nsIDOMDocument *aFrameContent, URIData *aData);
     175                 :     nsresult SetDocumentBase(nsIDOMDocument *aDocument, nsIURI *aBaseURI);
     176                 :     nsresult SendErrorStatusChange(
     177                 :         bool aIsReadError, nsresult aResult, nsIRequest *aRequest, nsIURI *aURI);
     178                 :     nsresult OnWalkDOMNode(nsIDOMNode *aNode);
     179                 : 
     180                 :     nsresult FixRedirectedChannelEntry(nsIChannel *aNewChannel);
     181                 : 
     182                 :     void EndDownload(nsresult aResult = NS_OK);
     183                 :     nsresult SaveGatheredURIs(nsIURI *aFileAsURI);
     184                 :     bool SerializeNextFile();
     185                 :     void CalcTotalProgress();
     186                 : 
     187                 :     void SetApplyConversionIfNeeded(nsIChannel *aChannel);
     188                 : 
     189                 :     // Hash table enumerators
     190                 :     static bool EnumPersistURIs(
     191                 :         nsHashKey *aKey, void *aData, void* closure);
     192                 :     static bool EnumCleanupURIMap(
     193                 :         nsHashKey *aKey, void *aData, void* closure);
     194                 :     static bool EnumCleanupOutputMap(
     195                 :         nsHashKey *aKey, void *aData, void* closure);
     196                 :     static bool EnumCleanupUploadList(
     197                 :         nsHashKey *aKey, void *aData, void* closure);
     198                 :     static bool EnumCalcProgress(
     199                 :         nsHashKey *aKey, void *aData, void* closure);
     200                 :     static bool EnumCalcUploadProgress(
     201                 :         nsHashKey *aKey, void *aData, void* closure);
     202                 :     static bool EnumFixRedirect(
     203                 :         nsHashKey *aKey, void *aData, void* closure);
     204                 :     static bool EnumCountURIsToPersist(
     205                 :         nsHashKey *aKey, void *aData, void* closure);
     206                 : 
     207                 :     nsCOMPtr<nsIURI>          mCurrentDataPath;
     208                 :     bool                      mCurrentDataPathIsRelative;
     209                 :     nsCString                 mCurrentRelativePathToData;
     210                 :     nsCOMPtr<nsIURI>          mCurrentBaseURI;
     211                 :     nsCString                 mCurrentCharset;
     212                 :     nsCOMPtr<nsIURI>          mTargetBaseURI;
     213                 :     PRUint32                  mCurrentThingsToPersist;
     214                 : 
     215                 :     nsCOMPtr<nsIMIMEService>  mMIMEService;
     216                 :     nsCOMPtr<nsIURI>          mURI;
     217                 :     nsCOMPtr<nsIWebProgressListener> mProgressListener;
     218                 :     /**
     219                 :      * Progress listener for 64-bit values; this is the same object as
     220                 :      * mProgressListener, but is a member to avoid having to qi it for each
     221                 :      * progress notification.
     222                 :      */
     223                 :     nsCOMPtr<nsIWebProgressListener2> mProgressListener2;
     224                 :     nsCOMPtr<nsIProgressEventSink> mEventSink;
     225                 :     nsHashtable               mOutputMap;
     226                 :     nsHashtable               mUploadList;
     227                 :     nsHashtable               mURIMap;
     228                 :     nsTArray<DocData*>        mDocList;
     229                 :     nsTArray<CleanupData*>    mCleanupList;
     230                 :     nsTArray<nsCString>       mFilenameList;
     231                 :     bool                      mFirstAndOnlyUse;
     232                 :     bool                      mCancel;
     233                 :     bool                      mJustStartedLoading;
     234                 :     bool                      mCompleted;
     235                 :     bool                      mStartSaving;
     236                 :     bool                      mReplaceExisting;
     237                 :     bool                      mSerializingOutput;
     238                 :     PRUint32                  mPersistFlags;
     239                 :     PRUint32                  mPersistResult;
     240                 :     PRInt64                   mTotalCurrentProgress;
     241                 :     PRInt64                   mTotalMaxProgress;
     242                 :     PRInt16                   mWrapColumn;
     243                 :     PRUint32                  mEncodingFlags;
     244                 :     nsString                  mContentType;
     245                 : };
     246                 : 
     247                 : // Helper class does node fixup during persistence
     248                 : class nsEncoderNodeFixup : public nsIDocumentEncoderNodeFixup
     249                 : {
     250                 : public:
     251                 :     nsEncoderNodeFixup();
     252                 :     
     253                 :     NS_DECL_ISUPPORTS
     254                 :     NS_IMETHOD FixupNode(nsIDOMNode *aNode, bool *aSerializeCloneKids, nsIDOMNode **aOutNode);
     255                 :     
     256                 :     nsWebBrowserPersist *mWebBrowserPersist;
     257                 : 
     258                 : protected:    
     259                 :     virtual ~nsEncoderNodeFixup();
     260                 : };
     261                 : 
     262                 : #endif

Generated by: LCOV version 1.7