LCOV - app.info - content/base/src/FileIOObject.h

LCOV - code coverage report
| Current view: | directory - content/base/src - FileIOObject.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 5 | 2 | 40.0 %
| Date: | 2012-07-07 | Functions: | 10 | 3 | 30.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; 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 mozila.org code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is the Mozilla Foundation
          18                 :  * Portions created by the Initial Developer are Copyright (C) 2011
          19                 :  * the Initial Developer. All Rights Reserved.
          20                 :  *
          21                 :  * Contributor(s):
          22                 :  *   Kyle Huey <me@kylehuey.com>
          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 FileIOObject_h__
          39                 : #define FileIOObject_h__
          40                 :
          41                 : #include "nsIDOMEventTarget.h"
          42                 : #include "nsDOMEventTargetHelper.h"
          43                 : #include "nsIChannel.h"
          44                 : #include "nsIFile.h"
          45                 : #include "nsIDOMFile.h"
          46                 : #include "nsIStreamListener.h"
          47                 : #include "nsITimer.h"
          48                 : #include "nsCOMPtr.h"
          49                 :
          50                 : #include "mozilla/dom/DOMError.h"
          51                 :
          52                 : #define NS_PROGRESS_EVENT_INTERVAL 50
          53                 :
          54                 : namespace mozilla {
          55                 : namespace dom {
          56                 :
          57                 : extern const PRUint64 kUnknownSize;
          58                 :
          59                 : // A common base class for FileReader and FileSaver
          60                 :
          61                 : class FileIOObject : public nsDOMEventTargetHelper,
          62                 :                      public nsIStreamListener,
          63                 :                      public nsITimerCallback
          64               4 : {
          65                 : public:
          66                 :   FileIOObject();
          67                 :
          68                 :   NS_DECL_ISUPPORTS_INHERITED
          69                 :
          70                 :   // Common methods
          71                 :   NS_METHOD Abort();
          72                 :   NS_METHOD GetReadyState(PRUint16* aReadyState);
          73                 :   NS_METHOD GetError(nsIDOMDOMError** aError);
          74                 :
          75               0 :   NS_DECL_AND_IMPL_EVENT_HANDLER(abort);
          76               0 :   NS_DECL_AND_IMPL_EVENT_HANDLER(error);
          77               0 :   NS_DECL_AND_IMPL_EVENT_HANDLER(progress);
          78                 :
          79                 :   NS_DECL_NSITIMERCALLBACK
          80                 :
          81                 :   NS_DECL_NSISTREAMLISTENER
          82                 :
          83                 :   NS_DECL_NSIREQUESTOBSERVER
          84                 :
          85            2956 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FileIOObject,
          86                 :                                            nsDOMEventTargetHelper)
          87                 :
          88                 : protected:
          89                 :   // Implemented by the derived class to do whatever it needs to do for abort
          90                 :   NS_IMETHOD DoAbort(nsAString& aEvent) = 0;
          91                 :   // for onStartRequest (this has a default impl since FileReader doesn't need
          92                 :   // special handling
          93                 :   NS_IMETHOD DoOnStartRequest(nsIRequest *aRequest, nsISupports *aContext);
          94                 :   // for onStopRequest
          95                 :   NS_IMETHOD DoOnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
          96                 :                              nsresult aStatus, nsAString& aSuccessEvent,
          97                 :                              nsAString& aTerminationEvent) = 0;
          98                 :   // and for onDataAvailable
          99                 :   NS_IMETHOD DoOnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
         100                 :                                nsIInputStream *aInputStream, PRUint32 aOffset,
         101                 :                                PRUint32 aCount) = 0;
         102                 :
         103                 :   void StartProgressEventTimer();
         104                 :   void ClearProgressEventTimer();
         105                 :   void DispatchError(nsresult rv, nsAString& finalEvent);
         106                 :   nsresult DispatchProgressEvent(const nsAString& aType);
         107                 :
         108                 :   nsCOMPtr<nsITimer> mProgressNotifier;
         109                 :   bool mProgressEventWasDelayed;
         110                 :   bool mTimerIsActive;
         111                 :
         112                 :   nsCOMPtr<nsIDOMDOMError> mError;
         113                 :   nsCOMPtr<nsIChannel> mChannel;
         114                 :
         115                 :   PRUint16 mReadyState;
         116                 :
         117                 :   PRUint64 mTotal;
         118                 :   PRUint64 mTransferred;
         119                 : };
         120                 :
         121                 : } // namespace dom
         122                 : } // namespace mozilla
         123                 :
         124                 : #endif

Generated by: LCOV version 1.7