1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsTransferable_h__
7 #define nsTransferable_h__
9 #include "nsIFormatConverter.h"
10 #include "nsITransferable.h"
14 #include "nsWeakPtr.h"
22 // Holds a flavor (a mime type) that describes the data and the associated data.
26 explicit DataStruct ( const char* aFlavor
)
27 : mDataLen(0), mFlavor(aFlavor
), mCacheFileName(nullptr) { }
30 const nsCString
& GetFlavor() const { return mFlavor
; }
31 void SetData( nsISupports
* inData
, uint32_t inDataLen
);
32 void GetData( nsISupports
** outData
, uint32_t *outDataLen
);
33 already_AddRefed
<nsIFile
> GetFileSpec(const char* aFileName
);
34 bool IsDataAvailable() const { return (mData
&& mDataLen
> 0) || (!mData
&& mCacheFileName
); }
39 // The size of data over which we write the data to disk rather than
40 // keep it around in memory.
41 kLargeDatasetSize
= 1000000 // 1 million bytes
44 nsresult
WriteCache(nsISupports
* aData
, uint32_t aDataLen
);
45 nsresult
ReadCache(nsISupports
** aData
, uint32_t* aDataLen
);
47 nsCOMPtr
<nsISupports
> mData
; // OWNER - some varient of primitive wrapper
49 const nsCString mFlavor
;
50 char * mCacheFileName
;
55 * XP Transferable wrapper
58 class nsTransferable
: public nsITransferable
66 NS_DECL_NSITRANSFERABLE
69 virtual ~nsTransferable();
71 // get flavors w/out converter
72 nsresult
GetTransferDataFlavors(nsISupportsArray
** aDataFlavorList
);
74 nsTArray
<DataStruct
> mDataArray
;
75 nsCOMPtr
<nsIFormatConverter
> mFormatConv
;
77 nsWeakPtr mRequestingNode
;
84 #endif // nsTransferable_h__