LCOV - app.info - uriloader/prefetch/nsPrefetchService.h

LCOV - code coverage report
| Current view: | directory - uriloader/prefetch - nsPrefetchService.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 3 | 3 | 100.0 %
| Date: | 2012-06-02 | Functions: | 3 | 3 | 100.0 %

           1                 : /* ***** BEGIN LICENSE BLOCK *****
           2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           3                 :  *
           4                 :  * The contents of this file are subject to the Mozilla Public License Version
           5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           6                 :  * the License. You may obtain a copy of the License at
           7                 :  * http://www.mozilla.org/MPL/
           8                 :  *
           9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          11                 :  * for the specific language governing rights and limitations under the
          12                 :  * License.
          13                 :  *
          14                 :  * The Original Code is Mozilla.
          15                 :  *
          16                 :  * The Initial Developer of the Original Code is
          17                 :  * Netscape Communications Corporation.
          18                 :  * Portions created by the Initial Developer are Copyright (C) 2002
          19                 :  * the Initial Developer. All Rights Reserved.
          20                 :  *
          21                 :  * Contributor(s):
          22                 :  *   Darin Fisher <darin@netscape.com> (original author)
          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 nsPrefetchService_h__
          39                 : #define nsPrefetchService_h__
          40                 :
          41                 : #include "nsCPrefetchService.h"
          42                 : #include "nsIObserver.h"
          43                 : #include "nsIInterfaceRequestor.h"
          44                 : #include "nsIChannelEventSink.h"
          45                 : #include "nsIWebProgressListener.h"
          46                 : #include "nsIStreamListener.h"
          47                 : #include "nsIChannel.h"
          48                 : #include "nsIURI.h"
          49                 : #include "nsIDOMDocument.h"
          50                 : #include "nsIDOMLoadStatus.h"
          51                 : #include "nsWeakReference.h"
          52                 : #include "nsCOMPtr.h"
          53                 : #include "nsAutoPtr.h"
          54                 :
          55                 : class nsPrefetchService;
          56                 : class nsPrefetchListener;
          57                 : class nsPrefetchNode;
          58                 :
          59                 : //-----------------------------------------------------------------------------
          60                 : // nsPrefetchService
          61                 : //-----------------------------------------------------------------------------
          62                 :
          63                 : class nsPrefetchService : public nsIPrefetchService
          64                 :                         , public nsIWebProgressListener
          65                 :                         , public nsIObserver
          66                 :                         , public nsSupportsWeakReference
          67                 : {
          68                 : public:
          69                 :     NS_DECL_ISUPPORTS
          70                 :     NS_DECL_NSIPREFETCHSERVICE
          71                 :     NS_DECL_NSIWEBPROGRESSLISTENER
          72                 :     NS_DECL_NSIOBSERVER
          73                 :
          74                 :     nsPrefetchService();
          75                 :
          76                 :     nsresult Init();
          77                 :     void     ProcessNextURI();
          78                 :
          79               3 :     nsPrefetchNode *GetCurrentNode() { return mCurrentNode.get(); }
          80               3 :     nsPrefetchNode *GetQueueHead() { return mQueueHead; }
          81                 :
          82                 :     void NotifyLoadRequested(nsPrefetchNode *node);
          83                 :     void NotifyLoadCompleted(nsPrefetchNode *node);
          84                 :
          85                 : private:
          86                 :     ~nsPrefetchService();
          87                 :
          88                 :     nsresult Prefetch(nsIURI *aURI,
          89                 :                       nsIURI *aReferrerURI,
          90                 :                       nsIDOMNode *aSource,
          91                 :                       bool aExplicit);
          92                 :
          93                 :     void     AddProgressListener();
          94                 :     void     RemoveProgressListener();
          95                 :     nsresult EnqueueURI(nsIURI *aURI, nsIURI *aReferrerURI,
          96                 :                         nsIDOMNode *aSource, nsPrefetchNode **node);
          97                 :     nsresult EnqueueNode(nsPrefetchNode *node);
          98                 :     nsresult DequeueNode(nsPrefetchNode **node);
          99                 :     void     EmptyQueue();
         100                 :
         101                 :     void     StartPrefetching();
         102                 :     void     StopPrefetching();
         103                 :
         104                 :     nsPrefetchNode                   *mQueueHead;
         105                 :     nsPrefetchNode                   *mQueueTail;
         106                 :     nsRefPtr<nsPrefetchNode>          mCurrentNode;
         107                 :     PRInt32                           mStopCount;
         108                 :     // true if pending document loads have ever reached zero.
         109                 :     PRInt32                           mHaveProcessed;
         110                 :     bool                              mDisabled;
         111                 : };
         112                 :
         113                 : //-----------------------------------------------------------------------------
         114                 : // nsPrefetchNode
         115                 : //-----------------------------------------------------------------------------
         116                 :
         117                 : class nsPrefetchNode : public nsIDOMLoadStatus
         118                 :                      , public nsIStreamListener
         119                 :                      , public nsIInterfaceRequestor
         120                 :                      , public nsIChannelEventSink
         121                 : {
         122                 : public:
         123                 :     NS_DECL_ISUPPORTS
         124                 :     NS_DECL_NSIDOMLOADSTATUS
         125                 :     NS_DECL_NSIREQUESTOBSERVER
         126                 :     NS_DECL_NSISTREAMLISTENER
         127                 :     NS_DECL_NSIINTERFACEREQUESTOR
         128                 :     NS_DECL_NSICHANNELEVENTSINK
         129                 :
         130                 :     nsPrefetchNode(nsPrefetchService *aPrefetchService,
         131                 :                    nsIURI *aURI,
         132                 :                    nsIURI *aReferrerURI,
         133                 :                    nsIDOMNode *aSource);
         134                 :
         135              10 :     ~nsPrefetchNode() {}
         136                 :
         137                 :     nsresult OpenChannel();
         138                 :     nsresult CancelChannel(nsresult error);
         139                 :
         140                 :     nsPrefetchNode             *mNext;
         141                 :     nsCOMPtr<nsIURI>            mURI;
         142                 :     nsCOMPtr<nsIURI>            mReferrerURI;
         143                 :     nsCOMPtr<nsIWeakReference>  mSource;
         144                 :
         145                 : private:
         146                 :     nsRefPtr<nsPrefetchService> mService;
         147                 :     nsCOMPtr<nsIChannel>        mChannel;
         148                 :     PRUint16                    mState;
         149                 :     PRInt32                     mBytesRead;
         150                 : };
         151                 :
         152                 : #endif // !nsPrefetchService_h__

Generated by: LCOV version 1.7