2014-09-08 20:41:22 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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/. */
|
2004-11-25 02:21:14 +03:00
|
|
|
|
|
|
|
#ifndef nsHashPropertyBag_h___
|
|
|
|
#define nsHashPropertyBag_h___
|
|
|
|
|
2005-06-05 22:55:41 +04:00
|
|
|
#include "nsIVariant.h"
|
2005-03-22 21:16:53 +03:00
|
|
|
#include "nsIWritablePropertyBag.h"
|
|
|
|
#include "nsIWritablePropertyBag2.h"
|
2014-09-08 20:41:32 +04:00
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2004-11-25 02:21:14 +03:00
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
|
2014-07-09 19:15:21 +04:00
|
|
|
class nsHashPropertyBagBase : public nsIWritablePropertyBag,
|
|
|
|
public nsIWritablePropertyBag2 {
|
2004-11-25 02:21:14 +03:00
|
|
|
public:
|
2019-11-26 04:49:28 +03:00
|
|
|
nsHashPropertyBagBase() = default;
|
|
|
|
|
|
|
|
void CopyFrom(const nsHashPropertyBagBase* aOther);
|
|
|
|
void CopyFrom(nsIPropertyBag* aOther);
|
|
|
|
static void CopyFrom(nsIWritablePropertyBag* aTo, nsIPropertyBag* aFrom);
|
2004-11-25 02:21:14 +03:00
|
|
|
|
2014-07-09 19:15:21 +04:00
|
|
|
NS_DECL_NSIPROPERTYBAG
|
|
|
|
NS_DECL_NSIPROPERTYBAG2
|
2004-11-25 02:21:14 +03:00
|
|
|
|
2014-07-09 19:15:21 +04:00
|
|
|
NS_DECL_NSIWRITABLEPROPERTYBAG
|
|
|
|
NS_DECL_NSIWRITABLEPROPERTYBAG2
|
2005-03-22 21:16:53 +03:00
|
|
|
|
2004-11-25 02:21:14 +03:00
|
|
|
protected:
|
2014-07-09 19:15:21 +04:00
|
|
|
// a hash table of string -> nsIVariant
|
|
|
|
nsInterfaceHashtable<nsStringHashKey, nsIVariant> mPropertyHash;
|
2014-09-08 20:41:22 +04:00
|
|
|
};
|
2014-07-01 02:11:53 +04:00
|
|
|
|
2014-09-08 20:41:22 +04:00
|
|
|
class nsHashPropertyBag : public nsHashPropertyBagBase {
|
|
|
|
public:
|
2020-02-27 20:39:15 +03:00
|
|
|
nsHashPropertyBag() = default;
|
2014-09-08 20:41:22 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
|
|
|
|
protected:
|
2017-04-05 22:31:20 +03:00
|
|
|
virtual ~nsHashPropertyBag();
|
2004-11-25 02:21:14 +03:00
|
|
|
};
|
|
|
|
|
2021-11-08 15:02:40 +03:00
|
|
|
/*
|
|
|
|
* Off Main Thread variant of nsHashPropertyBag. Instances of this class
|
|
|
|
* should not be created on a main thread, nor should it contain main thread
|
|
|
|
* only objects, such as XPCVariants. The purpose of this class is to provide a
|
|
|
|
* way to use the property bag off main thread.
|
|
|
|
* Note: this class needs to be created and destroyed on the same thread and
|
|
|
|
* should be used single threaded.
|
|
|
|
*/
|
|
|
|
class nsHashPropertyBagOMT final : public nsHashPropertyBagBase {
|
|
|
|
public:
|
|
|
|
nsHashPropertyBagOMT();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Doesn't need to dispatch to main thread because it cannot contain
|
|
|
|
// XPCVariants
|
|
|
|
virtual ~nsHashPropertyBagOMT() = default;
|
|
|
|
};
|
|
|
|
|
2014-09-08 20:41:32 +04:00
|
|
|
/* A cycle collected nsHashPropertyBag for main-thread-only use. */
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsHashPropertyBagCC final : public nsHashPropertyBagBase {
|
2014-09-08 20:41:32 +04:00
|
|
|
public:
|
2019-11-26 04:49:28 +03:00
|
|
|
nsHashPropertyBagCC() = default;
|
2014-09-08 20:41:32 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHashPropertyBagCC,
|
|
|
|
nsIWritablePropertyBag)
|
|
|
|
protected:
|
2019-11-26 04:49:28 +03:00
|
|
|
virtual ~nsHashPropertyBagCC() = default;
|
2014-09-08 20:41:32 +04:00
|
|
|
};
|
|
|
|
|
2019-08-26 05:18:57 +03:00
|
|
|
inline nsISupports* ToSupports(nsHashPropertyBagBase* aPropertyBag) {
|
|
|
|
return static_cast<nsIWritablePropertyBag*>(aPropertyBag);
|
|
|
|
}
|
|
|
|
|
2004-11-25 02:21:14 +03:00
|
|
|
#endif /* nsHashPropertyBag_h___ */
|