2008-08-28 02:11:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 sts=2 expandtab
|
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/. */
|
2008-08-28 02:11:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This wraps nsSimpleURI so that all calls to it are done on the main thread.
|
|
|
|
*/
|
|
|
|
|
2018-07-17 22:37:48 +03:00
|
|
|
#ifndef mozilla_NullPrincipalURI_h
|
|
|
|
#define mozilla_NullPrincipalURI_h
|
2008-08-28 02:11:02 +04:00
|
|
|
|
|
|
|
#include "nsIURI.h"
|
2012-02-20 07:51:48 +04:00
|
|
|
#include "nsISizeOf.h"
|
2008-08-28 02:11:02 +04:00
|
|
|
#include "nsString.h"
|
2012-06-13 07:58:27 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2017-03-22 13:38:40 +03:00
|
|
|
#include "NullPrincipal.h"
|
2015-03-31 20:11:00 +03:00
|
|
|
#include "nsID.h"
|
2017-11-20 19:11:30 +03:00
|
|
|
#include "nsIURIMutator.h"
|
2008-08-28 02:11:02 +04:00
|
|
|
|
|
|
|
// {51fcd543-3b52-41f7-b91b-6b54102236e6}
|
|
|
|
#define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2008-08-28 02:11:02 +04:00
|
|
|
0x51fcd543, 0x3b52, 0x41f7, { \
|
|
|
|
0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6 \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
namespace mozilla {
|
2018-07-17 22:37:48 +03:00
|
|
|
|
2018-02-27 02:07:48 +03:00
|
|
|
class Encoding;
|
|
|
|
|
2019-01-25 16:32:36 +03:00
|
|
|
class NullPrincipalURI final : public nsIURI, public nsISizeOf {
|
2008-08-28 02:11:02 +04:00
|
|
|
public:
|
2013-07-17 07:51:48 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_DECL_NSIURI
|
|
|
|
|
2012-02-20 07:51:48 +04:00
|
|
|
// nsISizeOf
|
2018-07-17 22:37:48 +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
|
|
|
|
2015-03-31 20:11:00 +03:00
|
|
|
// Returns null on failure.
|
2017-03-22 13:38:40 +03:00
|
|
|
static already_AddRefed<NullPrincipalURI> Create();
|
2015-02-24 23:54:40 +03:00
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
private:
|
2017-11-20 19:11:30 +03:00
|
|
|
NullPrincipalURI();
|
2019-05-01 11:47:10 +03:00
|
|
|
NullPrincipalURI(const NullPrincipalURI& aOther);
|
2015-03-31 20:11:00 +03:00
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
~NullPrincipalURI() {}
|
2014-06-24 02:40:03 +04:00
|
|
|
|
2015-03-31 20:11:00 +03:00
|
|
|
nsresult Init();
|
2015-02-24 23:54:40 +03:00
|
|
|
|
2017-08-09 13:41:40 +03:00
|
|
|
nsAutoCStringN<NSID_LENGTH> mPath;
|
2017-11-20 19:11:30 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult Clone(nsIURI** aURI);
|
|
|
|
nsresult SetSpecInternal(const nsACString& input);
|
|
|
|
nsresult SetScheme(const nsACString& input);
|
|
|
|
nsresult SetUserPass(const nsACString& input);
|
|
|
|
nsresult SetUsername(const nsACString& input);
|
|
|
|
nsresult SetPassword(const nsACString& input);
|
|
|
|
nsresult SetHostPort(const nsACString& aValue);
|
|
|
|
nsresult SetHost(const nsACString& input);
|
2018-02-27 02:07:48 +03:00
|
|
|
nsresult SetPort(int32_t port);
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult SetPathQueryRef(const nsACString& input);
|
|
|
|
nsresult SetRef(const nsACString& input);
|
|
|
|
nsresult SetFilePath(const nsACString& input);
|
|
|
|
nsresult SetQuery(const nsACString& input);
|
|
|
|
nsresult SetQueryWithEncoding(const nsACString& input,
|
|
|
|
const Encoding* encoding);
|
|
|
|
bool Deserialize(const mozilla::ipc::URIParams&);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
public:
|
|
|
|
class Mutator final : public nsIURIMutator,
|
|
|
|
public BaseURIMutator<NullPrincipalURI> {
|
|
|
|
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
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD Deserialize(const mozilla::ipc::URIParams& aParams) override {
|
2017-11-20 19:11:30 +03:00
|
|
|
return InitFromIPCParams(aParams);
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD Finalize(nsIURI** aURI) override {
|
2017-11-20 19:11:30 +03:00
|
|
|
mURI.forget(aURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD SetSpec(const nsACString& aSpec,
|
|
|
|
nsIURIMutator** aMutator) override {
|
2018-01-19 17:26:03 +03:00
|
|
|
if (aMutator) {
|
|
|
|
nsCOMPtr<nsIURIMutator> mutator = this;
|
|
|
|
mutator.forget(aMutator);
|
|
|
|
}
|
2017-11-20 19:11:30 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Mutator() {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
private:
|
|
|
|
virtual ~Mutator() {}
|
|
|
|
|
|
|
|
friend class NullPrincipalURI;
|
|
|
|
};
|
|
|
|
|
|
|
|
friend class BaseURIMutator<NullPrincipalURI>;
|
2008-08-28 02:11:02 +04:00
|
|
|
};
|
|
|
|
|
2018-07-17 22:37:48 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_NullPrincipalURI_h
|