Bumping manifests a=b2g-bump
[gecko.git] / widget / nsTransferable.h
blob4c34eabe24a89046e5dd9fa621dd18b673fd88c1
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"
11 #include "nsCOMPtr.h"
12 #include "nsString.h"
13 #include "nsTArray.h"
14 #include "nsWeakPtr.h"
16 class nsString;
17 class nsDataObj;
20 // DataStruct
22 // Holds a flavor (a mime type) that describes the data and the associated data.
24 struct DataStruct
26 explicit DataStruct ( const char* aFlavor )
27 : mDataLen(0), mFlavor(aFlavor), mCacheFileName(nullptr) { }
28 ~DataStruct();
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); }
36 protected:
38 enum {
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
48 uint32_t mDataLen;
49 const nsCString mFlavor;
50 char * mCacheFileName;
54 /**
55 * XP Transferable wrapper
58 class nsTransferable : public nsITransferable
60 public:
62 nsTransferable();
64 // nsISupports
65 NS_DECL_ISUPPORTS
66 NS_DECL_NSITRANSFERABLE
68 protected:
69 virtual ~nsTransferable();
71 // get flavors w/out converter
72 nsresult GetTransferDataFlavors(nsISupportsArray** aDataFlavorList);
74 nsTArray<DataStruct> mDataArray;
75 nsCOMPtr<nsIFormatConverter> mFormatConv;
76 bool mPrivateData;
77 nsWeakPtr mRequestingNode;
78 #if DEBUG
79 bool mInitialized;
80 #endif
84 #endif // nsTransferable_h__