2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-03-25 07:14:33 +03:00
|
|
|
|
|
|
|
#ifndef nsTransferable_h__
|
|
|
|
#define nsTransferable_h__
|
|
|
|
|
2015-08-10 22:56:47 +03:00
|
|
|
#include "nsIContentPolicyBase.h"
|
1999-04-02 22:22:36 +04:00
|
|
|
#include "nsIFormatConverter.h"
|
1999-03-25 07:14:33 +03:00
|
|
|
#include "nsITransferable.h"
|
1999-04-02 22:22:36 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2009-03-11 05:26:03 +03:00
|
|
|
#include "nsString.h"
|
2009-02-23 04:05:24 +03:00
|
|
|
#include "nsTArray.h"
|
2016-07-01 11:01:11 +03:00
|
|
|
#include "nsIPrincipal.h"
|
1999-04-02 22:22:36 +04:00
|
|
|
|
1999-05-14 01:53:57 +04:00
|
|
|
class nsString;
|
2009-03-11 05:26:03 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// DataStruct
|
|
|
|
//
|
|
|
|
// Holds a flavor (a mime type) that describes the data and the associated data.
|
|
|
|
//
|
|
|
|
struct DataStruct
|
|
|
|
{
|
2014-09-01 07:33:13 +04:00
|
|
|
explicit DataStruct ( const char* aFlavor )
|
2012-07-30 18:20:58 +04:00
|
|
|
: mDataLen(0), mFlavor(aFlavor), mCacheFileName(nullptr) { }
|
2009-03-11 05:26:03 +03:00
|
|
|
~DataStruct();
|
|
|
|
|
|
|
|
const nsCString& GetFlavor() const { return mFlavor; }
|
2015-02-18 14:52:00 +03:00
|
|
|
void SetData( nsISupports* inData, uint32_t inDataLen, bool aIsPrivateData );
|
2012-08-22 19:56:38 +04:00
|
|
|
void GetData( nsISupports** outData, uint32_t *outDataLen );
|
2013-07-10 13:56:21 +04:00
|
|
|
already_AddRefed<nsIFile> GetFileSpec(const char* aFileName);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsDataAvailable() const { return (mData && mDataLen > 0) || (!mData && mCacheFileName); }
|
2009-03-11 05:26:03 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// The size of data over which we write the data to disk rather than
|
|
|
|
// keep it around in memory.
|
|
|
|
kLargeDatasetSize = 1000000 // 1 million bytes
|
|
|
|
};
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult WriteCache(nsISupports* aData, uint32_t aDataLen );
|
|
|
|
nsresult ReadCache(nsISupports** aData, uint32_t* aDataLen );
|
2009-03-11 05:26:03 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mDataLen;
|
2009-03-11 05:26:03 +03:00
|
|
|
const nsCString mFlavor;
|
|
|
|
char * mCacheFileName;
|
|
|
|
|
|
|
|
};
|
1999-03-25 07:14:33 +03:00
|
|
|
|
|
|
|
/**
|
1999-04-02 07:57:31 +04:00
|
|
|
* XP Transferable wrapper
|
1999-03-25 07:14:33 +03:00
|
|
|
*/
|
|
|
|
|
1999-05-14 01:53:57 +04:00
|
|
|
class nsTransferable : public nsITransferable
|
1999-03-25 07:14:33 +03:00
|
|
|
{
|
|
|
|
public:
|
1999-08-25 12:35:06 +04:00
|
|
|
|
1999-03-25 07:14:33 +03:00
|
|
|
nsTransferable();
|
|
|
|
|
1999-08-25 12:35:06 +04:00
|
|
|
// nsISupports
|
1999-03-25 07:14:33 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2003-04-19 00:20:04 +04:00
|
|
|
NS_DECL_NSITRANSFERABLE
|
1999-04-02 22:22:36 +04:00
|
|
|
|
1999-03-25 07:14:33 +03:00
|
|
|
protected:
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~nsTransferable();
|
1999-03-25 07:14:33 +03:00
|
|
|
|
1999-08-25 12:35:06 +04:00
|
|
|
// get flavors w/out converter
|
2003-04-19 00:20:04 +04:00
|
|
|
nsresult GetTransferDataFlavors(nsISupportsArray** aDataFlavorList);
|
1999-08-25 12:35:06 +04:00
|
|
|
|
2009-03-11 05:26:03 +03:00
|
|
|
nsTArray<DataStruct> mDataArray;
|
1999-04-02 22:22:36 +04:00
|
|
|
nsCOMPtr<nsIFormatConverter> mFormatConv;
|
2012-04-17 06:14:01 +04:00
|
|
|
bool mPrivateData;
|
2016-07-01 11:01:11 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mRequestingPrincipal;
|
2015-08-10 22:56:47 +03:00
|
|
|
nsContentPolicyType mContentPolicyType;
|
2012-04-17 06:14:01 +04:00
|
|
|
#if DEBUG
|
|
|
|
bool mInitialized;
|
|
|
|
#endif
|
1999-03-25 07:14:33 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTransferable_h__
|