2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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-07-01 11:52:52 +04:00
|
|
|
|
|
|
|
#ifndef nsSimpleURI_h__
|
|
|
|
#define nsSimpleURI_h__
|
|
|
|
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-09-22 07:04:57 +04:00
|
|
|
#include "nsIURI.h"
|
2001-07-31 23:05:34 +04:00
|
|
|
#include "nsISerializable.h"
|
2002-03-06 10:48:55 +03:00
|
|
|
#include "nsString.h"
|
2006-03-15 07:59:42 +03:00
|
|
|
#include "nsIClassInfo.h"
|
2012-02-20 07:51:48 +04:00
|
|
|
#include "nsISizeOf.h"
|
2012-08-23 23:33:46 +04:00
|
|
|
#include "nsIIPCSerializableURI.h"
|
2017-11-20 19:11:30 +03:00
|
|
|
#include "nsIURIMutator.h"
|
1999-07-01 11:52:52 +04:00
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
1999-07-01 11:52:52 +04:00
|
|
|
#define NS_THIS_SIMPLEURI_IMPLEMENTATION_CID \
|
2011-05-22 05:12:45 +04:00
|
|
|
{ /* 0b9bb0c2-fee6-470b-b9b9-9fd9462b5e19 */ \
|
|
|
|
0x0b9bb0c2, \
|
|
|
|
0xfee6, \
|
|
|
|
0x470b, \
|
|
|
|
{0xb9, 0xb9, 0x9f, 0xd9, 0x46, 0x2b, 0x5e, 0x19} \
|
1999-07-01 11:52:52 +04:00
|
|
|
}
|
|
|
|
|
2016-11-14 15:04:33 +03:00
|
|
|
class nsSimpleURI
|
2016-12-28 14:40:21 +03:00
|
|
|
: public nsIURI
|
2016-11-14 15:04:33 +03:00
|
|
|
, public nsISerializable
|
|
|
|
, public nsIClassInfo
|
|
|
|
, public nsISizeOf
|
|
|
|
, public nsIIPCSerializableURI
|
1999-07-01 11:52:52 +04:00
|
|
|
{
|
2014-06-24 20:36:44 +04:00
|
|
|
protected:
|
2018-03-21 01:23:31 +03:00
|
|
|
nsSimpleURI();
|
2018-04-30 19:46:04 +03:00
|
|
|
virtual ~nsSimpleURI() = default;
|
2014-06-24 20:36:44 +04:00
|
|
|
|
1999-07-01 11:52:52 +04:00
|
|
|
public:
|
2018-03-20 17:51:17 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
1999-10-12 05:39:37 +04:00
|
|
|
NS_DECL_NSIURI
|
2001-07-31 23:05:34 +04:00
|
|
|
NS_DECL_NSISERIALIZABLE
|
2005-06-30 01:03:24 +04:00
|
|
|
NS_DECL_NSICLASSINFO
|
2012-08-23 23:33:46 +04:00
|
|
|
NS_DECL_NSIIPCSERIALIZABLEURI
|
1999-07-01 11:52:52 +04:00
|
|
|
|
2017-07-07 12:29:44 +03:00
|
|
|
static already_AddRefed<nsSimpleURI> From(nsIURI* aURI);
|
|
|
|
|
1999-07-01 11:52:52 +04:00
|
|
|
// nsSimpleURI methods:
|
|
|
|
|
2017-07-07 12:29:44 +03:00
|
|
|
bool Equals(nsSimpleURI* aOther)
|
|
|
|
{
|
|
|
|
return EqualsInternal(aOther, eHonorRef);
|
|
|
|
}
|
|
|
|
|
2012-02-20 07:51:48 +04:00
|
|
|
// nsISizeOf
|
|
|
|
// Among the sub-classes that inherit (directly or indirectly) from
|
|
|
|
// nsSimpleURI, measurement of the following members may be added later if
|
|
|
|
// DMD finds it is worthwhile:
|
|
|
|
// - nsJSURI: mBaseURI
|
|
|
|
// - nsSimpleNestedURI: mInnerURI
|
|
|
|
// - nsBlobURI: mPrincipal
|
2016-05-19 05:02:57 +03:00
|
|
|
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
|
|
|
|
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
|
2012-02-20 07:51:48 +04:00
|
|
|
|
1999-07-01 11:52:52 +04:00
|
|
|
protected:
|
2011-05-22 05:12:45 +04:00
|
|
|
// enum used in a few places to specify how .ref attribute should be handled
|
|
|
|
enum RefHandlingEnum {
|
|
|
|
eIgnoreRef,
|
2016-07-27 01:38:46 +03:00
|
|
|
eHonorRef,
|
|
|
|
eReplaceRef
|
2011-05-22 05:12:45 +04:00
|
|
|
};
|
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
virtual nsresult SetSpecInternal(const nsACString &input);
|
|
|
|
virtual nsresult SetScheme(const nsACString &input);
|
|
|
|
virtual nsresult SetUserPass(const nsACString &input);
|
2018-03-09 17:37:18 +03:00
|
|
|
nsresult SetUsername(const nsACString &input);
|
2018-02-27 02:07:48 +03:00
|
|
|
virtual nsresult SetPassword(const nsACString &input);
|
|
|
|
virtual nsresult SetHostPort(const nsACString &aValue);
|
|
|
|
virtual nsresult SetHost(const nsACString &input);
|
|
|
|
virtual nsresult SetPort(int32_t port);
|
|
|
|
virtual nsresult SetPathQueryRef(const nsACString &input);
|
|
|
|
virtual nsresult SetRef(const nsACString &input);
|
|
|
|
virtual nsresult SetFilePath(const nsACString &input);
|
|
|
|
virtual nsresult SetQuery(const nsACString &input);
|
|
|
|
virtual nsresult SetQueryWithEncoding(const nsACString &input, const Encoding* encoding);
|
2018-03-19 22:22:32 +03:00
|
|
|
nsresult ReadPrivate(nsIObjectInputStream *stream);
|
2018-02-27 02:07:48 +03:00
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
// Helper to share code between Equals methods.
|
2011-05-22 05:12:45 +04:00
|
|
|
virtual nsresult EqualsInternal(nsIURI* other,
|
|
|
|
RefHandlingEnum refHandlingMode,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* result);
|
2011-05-22 05:12:45 +04:00
|
|
|
|
2011-05-26 00:23:07 +04:00
|
|
|
// Helper to be used by inherited classes who want to test
|
2011-05-26 12:20:06 +04:00
|
|
|
// equality given an assumed nsSimpleURI. This must NOT check
|
2011-05-26 00:23:07 +04:00
|
|
|
// the passed-in other for QI to our CID.
|
|
|
|
bool EqualsInternal(nsSimpleURI* otherUri, RefHandlingEnum refHandlingMode);
|
|
|
|
|
2016-07-27 01:38:46 +03:00
|
|
|
// Used by StartClone (and versions of StartClone in subclasses) to
|
|
|
|
// handle the ref in the right way for clones.
|
|
|
|
void SetRefOnClone(nsSimpleURI* url, RefHandlingEnum refHandlingMode,
|
|
|
|
const nsACString& newRef);
|
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
// NOTE: This takes the refHandlingMode as an argument because
|
|
|
|
// nsSimpleNestedURI's specialized version needs to know how to clone
|
|
|
|
// its inner URI.
|
2016-07-27 01:38:46 +03:00
|
|
|
virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
|
|
|
|
const nsACString& newRef);
|
2006-05-02 22:54:19 +04:00
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
// Helper to share code between Clone methods.
|
|
|
|
virtual nsresult CloneInternal(RefHandlingEnum refHandlingMode,
|
2016-07-27 01:38:46 +03:00
|
|
|
const nsACString &newRef,
|
2011-05-22 05:12:45 +04:00
|
|
|
nsIURI** clone);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-08-13 11:03:28 +03:00
|
|
|
nsresult SetPathQueryRefEscaped(const nsACString &aPath, bool aNeedsEscape);
|
|
|
|
|
2018-03-05 06:14:44 +03:00
|
|
|
bool Deserialize(const mozilla::ipc::URIParams&);
|
|
|
|
|
2002-03-06 10:48:55 +03:00
|
|
|
nsCString mScheme;
|
2011-05-22 05:12:45 +04:00
|
|
|
nsCString mPath; // NOTE: mPath does not include ref, as an optimization
|
|
|
|
nsCString mRef; // so that URIs with different refs can share string data.
|
2016-11-14 15:04:33 +03:00
|
|
|
nsCString mQuery; // so that URLs with different querys can share string data.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mMutable;
|
|
|
|
bool mIsRefValid; // To distinguish between empty-ref and no-ref.
|
2016-11-14 15:04:33 +03:00
|
|
|
bool mIsQueryValid; // To distinguish between empty-query and no-query.
|
2017-11-20 19:11:30 +03:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
2018-02-28 04:13:57 +03:00
|
|
|
class Mutator final
|
2017-11-20 19:11:30 +03:00
|
|
|
: public nsIURIMutator
|
|
|
|
, public BaseURIMutator<nsSimpleURI>
|
2018-03-19 22:22:32 +03:00
|
|
|
, public nsISerializable
|
2017-11-20 19:11:30 +03:00
|
|
|
{
|
|
|
|
NS_DECL_ISUPPORTS
|
2017-12-05 04:35:21 +03:00
|
|
|
NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
|
2017-11-20 19:11:30 +03:00
|
|
|
NS_DEFINE_NSIMUTATOR_COMMON
|
|
|
|
|
2018-03-19 22:22:32 +03:00
|
|
|
NS_IMETHOD
|
|
|
|
Write(nsIObjectOutputStream *aOutputStream) override
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_MUST_USE NS_IMETHOD
|
|
|
|
Read(nsIObjectInputStream* aStream) override
|
|
|
|
{
|
|
|
|
return InitFromInputStream(aStream);
|
|
|
|
}
|
|
|
|
|
2018-04-30 19:46:04 +03:00
|
|
|
explicit Mutator() = default;
|
2017-11-20 19:11:30 +03:00
|
|
|
private:
|
2018-04-30 19:46:04 +03:00
|
|
|
virtual ~Mutator() = default;
|
2017-11-20 19:11:30 +03:00
|
|
|
|
|
|
|
friend class nsSimpleURI;
|
|
|
|
};
|
2018-02-27 02:07:48 +03:00
|
|
|
|
|
|
|
friend BaseURIMutator<nsSimpleURI>;
|
1999-07-01 11:52:52 +04:00
|
|
|
};
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
1999-07-01 11:52:52 +04:00
|
|
|
#endif // nsSimpleURI_h__
|