michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_file_asynchelper_h__ michael@0: #define mozilla_dom_file_asynchelper_h__ michael@0: michael@0: #include "FileCommon.h" michael@0: michael@0: #include "nsIRequest.h" michael@0: #include "nsIRunnable.h" michael@0: michael@0: class nsIRequestObserver; michael@0: michael@0: BEGIN_FILE_NAMESPACE michael@0: michael@0: /** michael@0: * Must be subclassed. The subclass must implement DoStreamWork. michael@0: * Async operations that are not supported in necko (truncate, flush, etc.) michael@0: * should use this helper. Call AsyncWork to invoke the operation. michael@0: */ michael@0: class AsyncHelper : public nsIRunnable, michael@0: public nsIRequest michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIRUNNABLE michael@0: NS_DECL_NSIREQUEST michael@0: michael@0: nsresult michael@0: AsyncWork(nsIRequestObserver* aObserver, nsISupports* aCtxt); michael@0: michael@0: protected: michael@0: AsyncHelper(nsISupports* aStream) michael@0: : mStream(aStream), michael@0: mStatus(NS_OK) michael@0: { } michael@0: michael@0: virtual ~AsyncHelper() michael@0: { } michael@0: michael@0: virtual nsresult michael@0: DoStreamWork(nsISupports* aStream) = 0; michael@0: michael@0: private: michael@0: nsCOMPtr mStream; michael@0: nsCOMPtr mObserver; michael@0: michael@0: nsresult mStatus; michael@0: }; michael@0: michael@0: END_FILE_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_file_asynchelper_h__