1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef nsDownloader_h__
6 #define nsDownloader_h__
7 
8 #include "nsIDownloader.h"
9 #include "nsCOMPtr.h"
10 
11 class nsIFile;
12 class nsIOutputStream;
13 
14 class nsDownloader : public nsIDownloader {
15  public:
16   NS_DECL_ISUPPORTS
17   NS_DECL_NSIDOWNLOADER
18   NS_DECL_NSIREQUESTOBSERVER
19   NS_DECL_NSISTREAMLISTENER
20 
nsDownloader()21   nsDownloader() : mLocationIsTemp(false) {}
22 
23  protected:
24   virtual ~nsDownloader();
25 
26   static nsresult ConsumeData(nsIInputStream *in, void *closure,
27                               const char *fromRawSegment, uint32_t toOffset,
28                               uint32_t count, uint32_t *writeCount);
29 
30   nsCOMPtr<nsIDownloadObserver> mObserver;
31   nsCOMPtr<nsIFile> mLocation;
32   nsCOMPtr<nsIOutputStream> mSink;
33   bool mLocationIsTemp;
34 };
35 
36 #endif  // nsDownloader_h__
37