2013-03-26 11:13:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 19:32:37 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-26 11:13:17 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_quota_originorpatternstring_h__
|
|
|
|
#define mozilla_dom_quota_originorpatternstring_h__
|
|
|
|
|
|
|
|
#include "mozilla/dom/quota/QuotaCommon.h"
|
|
|
|
|
|
|
|
BEGIN_QUOTA_NAMESPACE
|
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
class OriginScope : public nsCString
|
2013-03-26 11:13:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-06-30 12:59:27 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
eOrigin,
|
|
|
|
ePattern,
|
|
|
|
eNull
|
|
|
|
};
|
|
|
|
|
|
|
|
static OriginScope
|
2013-03-26 11:13:17 +00:00
|
|
|
FromOrigin(const nsACString& aOrigin)
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return OriginScope(aOrigin, eOrigin);
|
2013-03-26 11:13:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
static OriginScope
|
2013-03-26 11:13:17 +00:00
|
|
|
FromPattern(const nsACString& aPattern)
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return OriginScope(aPattern, ePattern);
|
2013-03-26 11:13:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
static OriginScope
|
2013-09-11 04:18:36 +00:00
|
|
|
FromNull()
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return OriginScope(NullCString(), eNull);
|
2013-09-11 04:18:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-26 11:13:17 +00:00
|
|
|
bool
|
|
|
|
IsOrigin() const
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return mType == eOrigin;
|
2013-03-26 11:13:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsPattern() const
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return mType == ePattern;
|
2013-09-11 04:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsNull() const
|
|
|
|
{
|
2015-06-30 12:59:27 +00:00
|
|
|
return mType == eNull;
|
2013-03-26 11:13:17 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
Type
|
|
|
|
GetType() const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
2013-09-11 04:18:36 +00:00
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
private:
|
|
|
|
OriginScope(const nsACString& aString, Type aType)
|
|
|
|
: nsCString(aString), mType(aType)
|
2013-03-26 11:13:17 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
bool
|
2015-06-30 12:59:27 +00:00
|
|
|
operator==(const OriginScope& aOther) = delete;
|
2013-03-26 11:13:17 +00:00
|
|
|
|
2015-06-30 12:59:27 +00:00
|
|
|
const Type mType;
|
2013-03-26 11:13:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_QUOTA_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_quota_originorpatternstring_h__
|