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__
|
|
|
|
|
2020-11-11 14:14:07 +03:00
|
|
|
#include "nsICookieJarSettings.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"
|
2017-09-03 03:29:10 +03:00
|
|
|
#include "prio.h"
|
2018-10-25 13:04:43 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
1999-04-02 22:22:36 +04:00
|
|
|
|
2016-10-16 22:43:56 +03:00
|
|
|
class nsIMutableArray;
|
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)
|
2018-11-20 20:01:42 +03:00
|
|
|
: mCacheFD(nullptr), mFlavor(aFlavor) {}
|
2018-02-25 19:36:08 +03:00
|
|
|
DataStruct(DataStruct&& aRHS);
|
2009-03-11 05:26:03 +03:00
|
|
|
~DataStruct();
|
2018-11-20 20:01:42 +03:00
|
|
|
|
2009-03-11 05:26:03 +03:00
|
|
|
const nsCString& GetFlavor() const { return mFlavor; }
|
2018-11-20 20:01:42 +03:00
|
|
|
void SetData(nsISupports* aData, bool aIsPrivateData);
|
|
|
|
void GetData(nsISupports** aData);
|
|
|
|
bool IsDataAvailable() const { return mData || mCacheFD; }
|
|
|
|
|
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
|
|
|
|
};
|
2018-11-20 20:01:42 +03:00
|
|
|
|
2018-11-20 19:59:39 +03:00
|
|
|
nsresult WriteCache(void* aData, uint32_t aDataLen);
|
2018-11-20 20:01:42 +03:00
|
|
|
nsresult ReadCache(nsISupports** aData);
|
|
|
|
|
|
|
|
// mData OR mCacheFD should be used, not both.
|
2009-03-11 05:26:03 +03:00
|
|
|
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
2017-09-03 03:29:10 +03:00
|
|
|
PRFileDesc* mCacheFD;
|
2009-03-11 05:26:03 +03:00
|
|
|
const nsCString mFlavor;
|
|
|
|
|
2018-02-25 19:36:08 +03:00
|
|
|
private:
|
|
|
|
DataStruct(const DataStruct&) = delete;
|
|
|
|
DataStruct& operator=(const DataStruct&) = delete;
|
2009-03-11 05:26:03 +03:00
|
|
|
};
|
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:
|
|
|
|
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
|
|
|
|
2018-10-25 13:04:43 +03:00
|
|
|
// Get flavors w/out converter
|
2018-10-10 23:25:54 +03:00
|
|
|
void GetTransferDataFlavors(nsTArray<nsCString>& aFlavors);
|
2018-10-25 13:04:43 +03:00
|
|
|
|
|
|
|
// Find index for data with the matching flavor in mDataArray.
|
|
|
|
mozilla::Maybe<size_t> FindDataFlavor(const char* aFlavor);
|
|
|
|
|
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;
|
2020-11-11 14:14:07 +03:00
|
|
|
nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
|
2012-04-17 06:14:01 +04:00
|
|
|
#if DEBUG
|
|
|
|
bool mInitialized;
|
|
|
|
#endif
|
1999-03-25 07:14:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsTransferable_h__
|