2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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 04:14:33 +00:00
|
|
|
|
|
|
|
#ifndef nsTransferable_h__
|
|
|
|
#define nsTransferable_h__
|
|
|
|
|
2020-11-11 11:14:07 +00:00
|
|
|
#include "nsICookieJarSettings.h"
|
1999-04-02 18:22:36 +00:00
|
|
|
#include "nsIFormatConverter.h"
|
1999-03-25 04:14:33 +00:00
|
|
|
#include "nsITransferable.h"
|
1999-04-02 18:22:36 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2009-03-11 02:26:03 +00:00
|
|
|
#include "nsString.h"
|
2009-02-23 01:05:24 +00:00
|
|
|
#include "nsTArray.h"
|
2016-07-01 08:01:11 +00:00
|
|
|
#include "nsIPrincipal.h"
|
2017-09-03 00:29:10 +00:00
|
|
|
#include "prio.h"
|
2018-10-25 10:04:43 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
1999-04-02 18:22:36 +00:00
|
|
|
|
2016-10-16 19:43:56 +00:00
|
|
|
class nsIMutableArray;
|
2009-03-11 02:26:03 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// DataStruct
|
|
|
|
//
|
|
|
|
// Holds a flavor (a mime type) that describes the data and the associated data.
|
|
|
|
//
|
|
|
|
struct DataStruct {
|
2014-09-01 03:33:13 +00:00
|
|
|
explicit DataStruct(const char* aFlavor)
|
2018-11-20 17:01:42 +00:00
|
|
|
: mCacheFD(nullptr), mFlavor(aFlavor) {}
|
2018-02-25 16:36:08 +00:00
|
|
|
DataStruct(DataStruct&& aRHS);
|
2009-03-11 02:26:03 +00:00
|
|
|
~DataStruct();
|
2018-11-20 17:01:42 +00:00
|
|
|
|
2009-03-11 02:26:03 +00:00
|
|
|
const nsCString& GetFlavor() const { return mFlavor; }
|
2018-11-20 17:01:42 +00:00
|
|
|
void SetData(nsISupports* aData, bool aIsPrivateData);
|
|
|
|
void GetData(nsISupports** aData);
|
|
|
|
bool IsDataAvailable() const { return mData || mCacheFD; }
|
|
|
|
|
2009-03-11 02:26:03 +00: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
|
|
|
|
};
|
2018-11-20 17:01:42 +00:00
|
|
|
|
2018-11-20 16:59:39 +00:00
|
|
|
nsresult WriteCache(void* aData, uint32_t aDataLen);
|
2018-11-20 17:01:42 +00:00
|
|
|
nsresult ReadCache(nsISupports** aData);
|
|
|
|
|
|
|
|
// mData OR mCacheFD should be used, not both.
|
2009-03-11 02:26:03 +00:00
|
|
|
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
2017-09-03 00:29:10 +00:00
|
|
|
PRFileDesc* mCacheFD;
|
2009-03-11 02:26:03 +00:00
|
|
|
const nsCString mFlavor;
|
|
|
|
|
2018-02-25 16:36:08 +00:00
|
|
|
private:
|
|
|
|
DataStruct(const DataStruct&) = delete;
|
|
|
|
DataStruct& operator=(const DataStruct&) = delete;
|
2009-03-11 02:26:03 +00:00
|
|
|
};
|
1999-03-25 04:14:33 +00:00
|
|
|
|
|
|
|
/**
|
1999-04-02 03:57:31 +00:00
|
|
|
* XP Transferable wrapper
|
1999-03-25 04:14:33 +00:00
|
|
|
*/
|
|
|
|
|
1999-05-13 21:53:57 +00:00
|
|
|
class nsTransferable : public nsITransferable {
|
1999-03-25 04:14:33 +00:00
|
|
|
public:
|
|
|
|
nsTransferable();
|
|
|
|
|
1999-08-25 08:35:06 +00:00
|
|
|
// nsISupports
|
1999-03-25 04:14:33 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2003-04-18 20:20:04 +00:00
|
|
|
NS_DECL_NSITRANSFERABLE
|
1999-04-02 18:22:36 +00:00
|
|
|
|
1999-03-25 04:14:33 +00:00
|
|
|
protected:
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~nsTransferable();
|
1999-03-25 04:14:33 +00:00
|
|
|
|
2018-10-25 10:04:43 +00:00
|
|
|
// Get flavors w/out converter
|
2018-10-10 20:25:54 +00:00
|
|
|
void GetTransferDataFlavors(nsTArray<nsCString>& aFlavors);
|
2018-10-25 10:04:43 +00:00
|
|
|
|
|
|
|
// Find index for data with the matching flavor in mDataArray.
|
|
|
|
mozilla::Maybe<size_t> FindDataFlavor(const char* aFlavor);
|
|
|
|
|
2009-03-11 02:26:03 +00:00
|
|
|
nsTArray<DataStruct> mDataArray;
|
1999-04-02 18:22:36 +00:00
|
|
|
nsCOMPtr<nsIFormatConverter> mFormatConv;
|
2012-04-17 02:14:01 +00:00
|
|
|
bool mPrivateData;
|
2016-07-01 08:01:11 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> mRequestingPrincipal;
|
2015-08-10 19:56:47 +00:00
|
|
|
nsContentPolicyType mContentPolicyType;
|
2020-11-11 11:14:07 +00:00
|
|
|
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
|
2012-04-17 02:14:01 +00:00
|
|
|
#if DEBUG
|
|
|
|
bool mInitialized;
|
|
|
|
#endif
|
1999-03-25 04:14:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTransferable_h__
|