2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsAsyncStreamCopier_h__
|
|
|
|
#define nsAsyncStreamCopier_h__
|
|
|
|
|
|
|
|
#include "nsIAsyncStreamCopier.h"
|
|
|
|
#include "nsIAsyncInputStream.h"
|
|
|
|
#include "nsIAsyncOutputStream.h"
|
|
|
|
#include "nsIRequestObserver.h"
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsStreamUtils.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class nsAsyncStreamCopier : public nsIAsyncStreamCopier
|
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:24:13 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIREQUEST
|
|
|
|
NS_DECL_NSIASYNCSTREAMCOPIER
|
|
|
|
|
|
|
|
nsAsyncStreamCopier();
|
|
|
|
virtual ~nsAsyncStreamCopier();
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// these methods may be called on any thread
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
bool IsComplete(nsresult *status = nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
void Complete(nsresult status);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
static void OnAsyncCopyComplete(void *, nsresult);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> mSource;
|
|
|
|
nsCOMPtr<nsIOutputStream> mSink;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRequestObserver> mObserver;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventTarget> mTarget;
|
|
|
|
|
2009-03-30 12:10:13 -07:00
|
|
|
nsCOMPtr<nsISupports> mCopierCtx;
|
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-03-31 21:29:02 -07:00
|
|
|
mozilla::Mutex mLock;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsAsyncCopyMode mMode;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mChunkSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult mStatus;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsPending;
|
|
|
|
bool mCloseSource;
|
|
|
|
bool mCloseSink;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // !nsAsyncStreamCopier_h__
|