本文整理汇总了C++中SetDOMStringToNull函数的典型用法代码示例。如果您正苦于以下问题:C++ SetDOMStringToNull函数的具体用法?C++ SetDOMStringToNull怎么用?C++ SetDOMStringToNull使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetDOMStringToNull函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NS_ASSERTION
NS_IMETHODIMP
SmsRequest::GetError(nsAString& aError)
{
if (!mDone) {
NS_ASSERTION(mError == eNoError,
"There should be no error if the request is still processing!");
SetDOMStringToNull(aError);
return NS_OK;
}
NS_ASSERTION(mError == eNoError || mResult == JSVAL_VOID,
"mResult should be void when there is an error!");
switch (mError) {
case eNoError:
SetDOMStringToNull(aError);
break;
case eNoSignalError:
aError.AssignLiteral("NoSignalError");
break;
case eNotFoundError:
aError.AssignLiteral("NotFoundError");
break;
case eUnknownError:
aError.AssignLiteral("UnknownError");
break;
case eInternalError:
aError.AssignLiteral("InternalError");
break;
}
return NS_OK;
}
示例2: WaitForPreload
nsresult
DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey,
nsString& aOld)
{
Telemetry::AutoTimer<Telemetry::LOCALDOMSTORAGE_REMOVEKEY_MS> autoTimer;
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Recalculate the cached data size
const int64_t delta = -(static_cast<int64_t>(aOld.Length()));
unused << ProcessUsageDelta(aStorage, delta);
data.mKeys.Remove(aKey);
if (Persist(aStorage)) {
return sDatabase->AsyncRemoveItem(this, aKey);
}
return NS_OK;
}
示例3: DOMEventTargetHelper
FileReader::FileReader(nsIGlobalObject* aGlobal,
WeakWorkerRef* aWorkerRef)
: DOMEventTargetHelper(aGlobal)
, mFileData(nullptr)
, mDataLen(0)
, mDataFormat(FILE_AS_BINARY)
, mResultArrayBuffer(nullptr)
, mProgressEventWasDelayed(false)
, mTimerIsActive(false)
, mReadyState(EMPTY)
, mTotal(0)
, mTransferred(0)
, mBusyCount(0)
, mWeakWorkerRef(aWorkerRef)
{
MOZ_ASSERT(aGlobal);
MOZ_ASSERT_IF(NS_IsMainThread(), !mWeakWorkerRef);
if (NS_IsMainThread()) {
mTarget = aGlobal->EventTargetFor(TaskCategory::Other);
} else {
mTarget = GetCurrentThreadSerialEventTarget();
}
SetDOMStringToNull(mResult);
}
示例4: MOZ_ASSERT
void
FileReader::Abort()
{
if (mReadyState == EMPTY || mReadyState == DONE) {
return;
}
MOZ_ASSERT(mReadyState == LOADING);
ClearProgressEventTimer();
mReadyState = DONE;
// XXX The spec doesn't say this
mError = DOMException::Create(NS_ERROR_DOM_ABORT_ERR);
// Revert status and result attributes
SetDOMStringToNull(mResult);
mResultArrayBuffer = nullptr;
mAsyncStream = nullptr;
mBlob = nullptr;
//Clean up memory buffer
FreeFileData();
// Dispatch the events
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
}
示例5: GetItem
nsresult
nsDOMStorage::GetItem(const nsAString& aKey, nsAString &aData)
{
nsresult rv;
// IMPORTANT:
// CacheStoragePermissions() is called inside of
// GetItem(nsAString, nsIDOMStorageItem)
// To call it particularly in this method would just duplicate
// the call. If the code changes, make sure that call to
// CacheStoragePermissions() is put here!
nsCOMPtr<nsIDOMStorageItem> item;
rv = GetItem(aKey, getter_AddRefs(item));
if (NS_FAILED(rv))
return rv;
if (item) {
rv = item->GetValue(aData);
NS_ENSURE_SUCCESS(rv, rv);
}
else
SetDOMStringToNull(aData);
return NS_OK;
}
示例6: InitDB
nsresult
nsDOMStorage::GetDBValue(const nsAString& aKey, nsAString& aValue,
PRBool* aSecure)
{
aValue.Truncate();
#ifdef MOZ_STORAGE
if (!UseDB())
return NS_OK;
nsresult rv = InitDB();
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString value;
rv = gStorageDB->GetKeyValue(this, aKey, value, aSecure);
if (rv == NS_ERROR_DOM_NOT_FOUND_ERR && mLocalStorage) {
SetDOMStringToNull(aValue);
}
if (NS_FAILED(rv))
return rv;
if (!IsCallerSecure() && *aSecure) {
return NS_ERROR_DOM_SECURITY_ERR;
}
aValue.Assign(value);
#endif
return NS_OK;
}
示例7: Set
nsresult
SessionStorageCache::SetItem(DataSetType aDataSetType, const nsAString& aKey,
const nsAString& aValue, nsString& aOldValue)
{
int64_t delta = 0;
DataSet* dataSet = Set(aDataSetType);
if (!dataSet->mKeys.Get(aKey, &aOldValue)) {
SetDOMStringToNull(aOldValue);
// We only consider key size if the key doesn't exist before.
delta = static_cast<int64_t>(aKey.Length());
}
delta += static_cast<int64_t>(aValue.Length()) -
static_cast<int64_t>(aOldValue.Length());
if (aValue == aOldValue &&
DOMStringIsNull(aValue) == DOMStringIsNull(aOldValue)) {
return NS_SUCCESS_DOM_NO_OPERATION;
}
if (!dataSet->ProcessUsageDelta(delta)) {
return NS_ERROR_DOM_QUOTA_REACHED;
}
dataSet->mKeys.Put(aKey, nsString(aValue));
return NS_OK;
}
示例8: WaitForPreload
nsresult
DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey,
nsString& aOld)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS);
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
}
Data& data = DataSet(aStorage);
if (!data.mKeys.Get(aKey, &aOld)) {
SetDOMStringToNull(aOld);
return NS_SUCCESS_DOM_NO_OPERATION;
}
// Recalculate the cached data size
const int64_t delta = -(static_cast<int64_t>(aOld.Length()) +
static_cast<int64_t>(aKey.Length()));
Unused << ProcessUsageDelta(aStorage, delta);
data.mKeys.Remove(aKey);
if (Persist(aStorage)) {
if (!sDatabase) {
NS_ERROR("Writing to localStorage after the database has been shut down"
", data lose!");
return NS_ERROR_NOT_INITIALIZED;
}
return sDatabase->AsyncRemoveItem(this, aKey);
}
return NS_OK;
}
示例9: SetDOMStringToNull
NS_IMETHODIMP
nsDOMDocumentType::GetNodeValue(nsAString& aNodeValue)
{
SetDOMStringToNull(aNodeValue);
return NS_OK;
}
示例10: ClearProgressEventTimer
void
FileReader::Abort(ErrorResult& aRv)
{
if (mReadyState != LOADING) {
// XXX The spec doesn't say this
aRv.Throw(NS_ERROR_DOM_FILE_ABORT_ERR);
return;
}
ClearProgressEventTimer();
mReadyState = DONE;
// XXX The spec doesn't say this
mError = new DOMError(GetOwner(), NS_LITERAL_STRING("AbortError"));
// Revert status and result attributes
SetDOMStringToNull(mResult);
mResultArrayBuffer = nullptr;
mAsyncStream = nullptr;
mBlob = nullptr;
//Clean up memory buffer
FreeFileData();
// Dispatch the events
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
}
示例11: SetDOMStringToNull
void
MouseEvent::GetRegion(nsAString& aRegion)
{
SetDOMStringToNull(aRegion);
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
if (mouseEventBase) {
aRegion = mouseEventBase->region;
}
}
示例12: SetDOMStringToNull
NS_IMETHODIMP
nsXFormsAccessors::GetValue(nsAString &aValue)
{
if (mDelegate) {
mDelegate->GetValue(aValue);
} else {
SetDOMStringToNull(aValue);
}
return NS_OK;
}
示例13: SetDOMStringToNull
NS_IMETHODIMP
nsAccessibleDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
{
if (aIndex >= mNames.Length())
SetDOMStringToNull(aResult);
else
aResult = mNames.ElementAt(aIndex);
return NS_OK;
}
示例14: SetDOMStringToNull
void
SessionStorageCache::GetItem(DataSetType aDataSetType, const nsAString& aKey,
nsAString& aResult)
{
// not using AutoString since we don't want to copy buffer to result
nsString value;
if (!Set(aDataSetType)->mKeys.Get(aKey, &value)) {
SetDOMStringToNull(value);
}
aResult = value;
}
示例15: AssertIsOnOwningThread
void
IDBIndex::GetLocale(nsString& aLocale) const
{
AssertIsOnOwningThread();
MOZ_ASSERT(mMetadata);
if (mMetadata->locale().IsEmpty()) {
SetDOMStringToNull(aLocale);
} else {
CopyASCIItoUTF16(mMetadata->locale(), aLocale);
}
}