本文整理汇总了C++中nsTArray::Elements方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::Elements方法的具体用法?C++ nsTArray::Elements怎么用?C++ nsTArray::Elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::Elements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slot
// IsRegistered determines if the provided key handle is usable by this token.
nsresult
U2FSoftTokenManager::IsRegistered(nsTArray<uint8_t>& aKeyHandle,
nsTArray<uint8_t>& aAppParam,
bool& aResult)
{
nsNSSShutDownPreventionLock locker;
if (NS_WARN_IF(isAlreadyShutDown())) {
return NS_ERROR_FAILURE;
}
if (!mInitialized) {
nsresult rv = Init();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
UniquePK11SlotInfo slot(PK11_GetInternalSlot());
MOZ_ASSERT(slot.get());
// Decode the key handle
UniqueSECKEYPrivateKey privKey = PrivateKeyFromKeyHandle(slot, mWrappingKey,
aKeyHandle.Elements(),
aKeyHandle.Length(),
aAppParam.Elements(),
aAppParam.Length(),
locker);
aResult = privKey.get() != nullptr;
return NS_OK;
}
示例2:
void
WebRenderAPI::GenerateFrame(const nsTArray<WrOpacityProperty>& aOpacityArray,
const nsTArray<WrTransformProperty>& aTransformArray)
{
wr_api_generate_frame_with_properties(mWrApi,
aOpacityArray.IsEmpty() ?
nullptr : aOpacityArray.Elements(),
aOpacityArray.Length(),
aTransformArray.IsEmpty() ?
nullptr : aTransformArray.Elements(),
aTransformArray.Length());
}
示例3: memcmp
bool
nsBaseWidget::StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects)
{
if (mClipRects && mClipRectCount == aRects.Length() &&
memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0)
return false;
mClipRectCount = aRects.Length();
mClipRects = new nsIntRect[mClipRectCount];
if (mClipRects) {
memcpy(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount);
}
return true;
}
示例4: Initialize
bool DWriteFontFileStream::Initialize(uint8_t* aData, uint32_t aSize) {
if (!mData.SetLength(aSize, fallible)) {
return false;
}
memcpy(mData.Elements(), aData, aSize);
return true;
}
示例5: font
nsresult
GDIFontEntry::CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer)
{
if (!IsTrueType()) {
return NS_ERROR_FAILURE;
}
AutoDC dc;
AutoSelectFont font(dc.GetDC(), &mLogFont);
if (font.IsValid()) {
uint32_t tableSize =
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag),
0, nullptr, 0);
if (tableSize != GDI_ERROR) {
if (aBuffer.SetLength(tableSize, fallible)) {
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag), 0,
aBuffer.Elements(), tableSize);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
}
}
return NS_ERROR_FAILURE;
}
示例6: str
void
CDMProxy::gmp_Decrypted(uint32_t aId,
GMPErr aResult,
const nsTArray<uint8_t>& aDecryptedData)
{
MOZ_ASSERT(IsOnGMPThread());
for (size_t i = 0; i < mDecryptionJobs.Length(); i++) {
DecryptJob* job = mDecryptionJobs[i];
if (job->mId == aId) {
if (aDecryptedData.Length() != job->mSample->size) {
NS_WARNING("CDM returned incorrect number of decrypted bytes");
}
if (GMP_SUCCEEDED(aResult)) {
PodCopy(job->mSample->data,
aDecryptedData.Elements(),
std::min<size_t>(aDecryptedData.Length(), job->mSample->size));
job->mClient->Decrypted(GMPNoErr, job->mSample.forget());
} else if (aResult == GMPNoKeyErr) {
NS_WARNING("CDM returned GMPNoKeyErr");
// We still have the encrypted sample, so we can re-enqueue it to be
// decrypted again once the key is usable again.
job->mClient->Decrypted(GMPNoKeyErr, job->mSample.forget());
} else {
nsAutoCString str("CDM returned decode failure GMPErr=");
str.AppendInt(aResult);
NS_WARNING(str.get());
job->mClient->Decrypted(aResult, nullptr);
}
mDecryptionJobs.RemoveElementAt(i);
return;
}
}
NS_WARNING("GMPDecryptorChild returned incorrect job ID");
}
示例7: sizeof
void
BluetoothGattClientHALInterface::WriteCharacteristic(
int aConnId, const BluetoothGattServiceId& aServiceId,
const BluetoothGattId& aCharId, BluetoothGattWriteType aWriteType,
BluetoothGattAuthReq aAuthReq, const nsTArray<uint8_t>& aValue,
BluetoothGattClientResultHandler* aRes)
{
bt_status_t status;
#if ANDROID_VERSION >= 19
btgatt_srvc_id_t serviceId;
btgatt_gatt_id_t charId;
int writeType;
int authReq;
if (NS_SUCCEEDED(Convert(aServiceId, serviceId)) &&
NS_SUCCEEDED(Convert(aCharId, charId)) &&
NS_SUCCEEDED(Convert(aWriteType, writeType)) &&
NS_SUCCEEDED(Convert(aAuthReq, authReq))) {
status = mInterface->write_characteristic(
aConnId, &serviceId, &charId, writeType,
aValue.Length() * sizeof(uint8_t), authReq,
reinterpret_cast<char*>(const_cast<uint8_t*>(aValue.Elements())));
} else {
status = BT_STATUS_PARM_INVALID;
}
#else
status = BT_STATUS_UNSUPPORTED;
#endif
if (aRes) {
DispatchBluetoothGattClientHALResult(
aRes, &BluetoothGattClientResultHandler::WriteCharacteristic,
ConvertDefault(status, STATUS_FAIL));
}
}
示例8: return
bool
ReadIntoArray(nsIFile* aFile,
nsTArray<uint8_t>& aOutDst,
size_t aMaxLength)
{
if (!FileExists(aFile)) {
return false;
}
PRFileDesc* fd = nullptr;
nsresult rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd);
if (NS_FAILED(rv)) {
return false;
}
int32_t length = PR_Seek(fd, 0, PR_SEEK_END);
PR_Seek(fd, 0, PR_SEEK_SET);
if (length < 0 || (size_t)length > aMaxLength) {
NS_WARNING("EME file is longer than maximum allowed length");
PR_Close(fd);
return false;
}
aOutDst.SetLength(length);
int32_t bytesRead = PR_Read(fd, aOutDst.Elements(), length);
PR_Close(fd);
return (bytesRead == length);
}
示例9:
static void
ReportToConsole(nsIDocument* aDocument,
const char* aConsoleStringId,
nsTArray<const char16_t*>& aParams)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aDocument);
DD_DEBUG("DecoderDoctorDiagnostics.cpp:ReportToConsole(doc=%p) ReportToConsole"
" - aMsg='%s' params={%s%s%s%s}",
aDocument, aConsoleStringId,
aParams.IsEmpty()
? "<no params>"
: NS_ConvertUTF16toUTF8(aParams[0]).get(),
(aParams.Length() < 1 || !aParams[1]) ? "" : ", ",
(aParams.Length() < 1 || !aParams[1])
? ""
: NS_ConvertUTF16toUTF8(aParams[1]).get(),
aParams.Length() < 2 ? "" : ", ...");
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Media"),
aDocument,
nsContentUtils::eDOM_PROPERTIES,
aConsoleStringId,
aParams.IsEmpty()
? nullptr
: aParams.Elements(),
aParams.Length());
}
示例10: InitInputBuffer
void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
int64_t aTimestamp,
const uint8_t* aData,
size_t aDataSize,
cdm::InputBuffer &aInputBuffer,
nsTArray<cdm::SubsampleEntry> &aSubsamples)
{
if (aCrypto) {
aInputBuffer.key_id = aCrypto->KeyId();
aInputBuffer.key_id_size = aCrypto->KeyIdSize();
aInputBuffer.iv = aCrypto->IV();
aInputBuffer.iv_size = aCrypto->IVSize();
aInputBuffer.num_subsamples = aCrypto->NumSubsamples();
aSubsamples.SetCapacity(aInputBuffer.num_subsamples);
const uint16_t* clear = aCrypto->ClearBytes();
const uint32_t* cipher = aCrypto->CipherBytes();
for (size_t i = 0; i < aCrypto->NumSubsamples(); i++) {
aSubsamples.AppendElement(cdm::SubsampleEntry(clear[i], cipher[i]));
}
}
aInputBuffer.data = aData;
aInputBuffer.data_size = aDataSize;
aInputBuffer.subsamples = aSubsamples.Elements();
aInputBuffer.timestamp = aTimestamp;
}
示例11: data
// Synchronously consume the given input stream and validate the resulting data
// against the given array of expected values.
void
ConsumeAndValidateStream(nsIInputStream* aStream,
const nsTArray<char>& aExpectedData)
{
nsDependentCSubstring data(aExpectedData.Elements(), aExpectedData.Length());
ConsumeAndValidateStream(aStream, data);
}
示例12: LOG
void
DBusThread::EventLoop()
{
dbus_connection_set_watch_functions(mConnection, AddWatch,
RemoveWatch, ToggleWatch, this, NULL);
dbus_connection_set_wakeup_main_function(mConnection, DBusWakeup, this, NULL);
#ifdef DEBUG
LOG("DBus Event Loop Starting\n");
#endif
while (1) {
poll(mPollData.Elements(), mPollData.Length(), -1);
for (uint32_t i = 0; i < mPollData.Length(); i++) {
if (!mPollData[i].revents) {
continue;
}
if (mPollData[i].fd == mControlFdR.get()) {
char data;
while (recv(mControlFdR.get(), &data, sizeof(char), MSG_DONTWAIT)
!= -1) {
switch (data) {
case DBUS_EVENT_LOOP_EXIT:
#ifdef DEBUG
LOG("DBus Event Loop Exiting\n");
#endif
dbus_connection_set_watch_functions(mConnection,
NULL, NULL, NULL, NULL, NULL);
return;
case DBUS_EVENT_LOOP_ADD:
HandleWatchAdd(this);
break;
case DBUS_EVENT_LOOP_REMOVE:
HandleWatchRemove(this);
break;
case DBUS_EVENT_LOOP_WAKEUP:
// noop
break;
}
}
} else {
short events = mPollData[i].revents;
unsigned int flags = UnixEventsToDBusFlags(events);
dbus_watch_handle(mWatchData[i], flags);
mPollData[i].revents = 0;
// Break at this point since we don't know if the operation
// was destructive
break;
}
}
while (dbus_connection_dispatch(mConnection) ==
DBUS_DISPATCH_DATA_REMAINS)
{}
}
}
示例13:
bool
GMPVideoEncoderChild::RecvEncode(const GMPVideoi420FrameData& aInputFrame,
const nsTArray<uint8_t>& aCodecSpecificInfo,
const nsTArray<GMPVideoFrameType>& aFrameTypes)
{
if (!mVideoEncoder) {
return false;
}
auto f = new GMPVideoi420FrameImpl(aInputFrame, &mVideoHost);
// Ignore any return code. It is OK for this to fail without killing the process.
mVideoEncoder->Encode(f,
aCodecSpecificInfo.Elements(),
aCodecSpecificInfo.Length(),
aFrameTypes.Elements(),
aFrameTypes.Length());
return true;
}
示例14: GetRawInputDeviceInfo
bool
GetPreparsedData(HANDLE handle, nsTArray<uint8_t>& data)
{
UINT size;
if (GetRawInputDeviceInfo(handle, RIDI_PREPARSEDDATA, nullptr, &size) == kRawInputError) {
return false;
}
data.SetLength(size);
return GetRawInputDeviceInfo(handle, RIDI_PREPARSEDDATA,
data.Elements(), &size) > 0;
}
示例15: wr_dp_push_clip_region
WrClipRegionToken
DisplayListBuilder::PushClipRegion(const WrRect& aMain,
const nsTArray<WrComplexClipRegion>& aComplex,
const WrImageMask* aMask)
{
WRDL_LOG("PushClipRegion r=%s cl=%d m=%p\n", Stringify(aMain).c_str(),
(int)aComplex.Length(), aMask);
return wr_dp_push_clip_region(mWrState,
aMain,
aComplex.Elements(), aComplex.Length(),
aMask);
}