本文整理汇总了C++中nsTArray::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::IsEmpty方法的具体用法?C++ nsTArray::IsEmpty怎么用?C++ nsTArray::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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());
}
示例2: Flush
void ShmSegmentsWriter::Flush(nsTArray<RefCountedShmem>& aSmallAllocs,
nsTArray<ipc::Shmem>& aLargeAllocs) {
MOZ_ASSERT(aSmallAllocs.IsEmpty());
MOZ_ASSERT(aLargeAllocs.IsEmpty());
mSmallAllocs.SwapElements(aSmallAllocs);
mLargeAllocs.SwapElements(aLargeAllocs);
mCursor = 0;
}
示例3: value
static void
BondStateChangedCallback(bt_status_t aStatus, bt_bdaddr_t* aRemoteBdAddress,
bt_bond_state_t aState)
{
MOZ_ASSERT(!NS_IsMainThread());
nsAutoString remoteAddress;
BdAddressTypeToString(aRemoteBdAddress, remoteAddress);
// We don't need to handle bonding state
NS_ENSURE_TRUE_VOID(aState != BT_BOND_STATE_BONDING);
NS_ENSURE_FALSE_VOID(aState == BT_BOND_STATE_BONDED &&
sAdapterBondedAddressArray.Contains(remoteAddress));
bool bonded;
if (aState == BT_BOND_STATE_NONE) {
bonded = false;
sAdapterBondedAddressArray.RemoveElement(remoteAddress);
} else if (aState == BT_BOND_STATE_BONDED) {
bonded = true;
sAdapterBondedAddressArray.AppendElement(remoteAddress);
}
// Update bonded address list to BluetoothAdapter
InfallibleTArray<BluetoothNamedValue> propertiesChangeArray;
propertiesChangeArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("Devices"),
sAdapterBondedAddressArray));
BluetoothValue value(propertiesChangeArray);
BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"),
NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(propertiesChangeArray));
NS_DispatchToMainThread(new DistributeBluetoothSignalTask(signal));
// Update bonding status to gaia
InfallibleTArray<BluetoothNamedValue> propertiesArray;
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("address"), remoteAddress));
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("status"), bonded));
BluetoothSignal newSignal(NS_LITERAL_STRING(PAIRED_STATUS_CHANGED_ID),
NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(propertiesArray));
NS_DispatchToMainThread(new DistributeBluetoothSignalTask(newSignal));
if (bonded && !sBondingRunnableArray.IsEmpty()) {
DispatchBluetoothReply(sBondingRunnableArray[0],
BluetoothValue(true), EmptyString());
sBondingRunnableArray.RemoveElementAt(0);
} else if (!bonded && !sUnbondingRunnableArray.IsEmpty()) {
DispatchBluetoothReply(sUnbondingRunnableArray[0],
BluetoothValue(true), EmptyString());
sUnbondingRunnableArray.RemoveElementAt(0);
}
}
示例4: SetCurrentFramesLocked
void VideoFrameContainer::SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicSize,
const nsTArray<ImageContainer::NonOwningImage>& aImages)
{
mMutex.AssertCurrentThreadOwns();
if (aIntrinsicSize != mIntrinsicSize) {
mIntrinsicSize = aIntrinsicSize;
mIntrinsicSizeChanged = true;
}
gfx::IntSize oldFrameSize = mImageContainer->GetCurrentSize();
// When using the OMX decoder, destruction of the current image can indirectly
// block on main thread I/O. If we let this happen while holding onto
// |mImageContainer|'s lock, then when the main thread then tries to
// composite it can then block on |mImageContainer|'s lock, causing a
// deadlock. We use this hack to defer the destruction of the current image
// until it is safe.
nsTArray<ImageContainer::OwningImage> oldImages;
mImageContainer->GetCurrentImages(&oldImages);
ImageContainer::FrameID lastFrameIDForOldPrincipalHandle =
mFrameIDForPendingPrincipalHandle - 1;
if (mPendingPrincipalHandle != PRINCIPAL_HANDLE_NONE &&
((!oldImages.IsEmpty() &&
oldImages.LastElement().mFrameID >= lastFrameIDForOldPrincipalHandle) ||
(!aImages.IsEmpty() &&
aImages[0].mFrameID > lastFrameIDForOldPrincipalHandle))) {
// We are releasing the last FrameID prior to `lastFrameIDForOldPrincipalHandle`
// OR
// there are no FrameIDs prior to `lastFrameIDForOldPrincipalHandle` in the new
// set of images.
// This means that the old principal handle has been flushed out and we can
// notify our video element about this change.
RefPtr<VideoFrameContainer> self = this;
PrincipalHandle principalHandle = mPendingPrincipalHandle;
mLastPrincipalHandle = mPendingPrincipalHandle;
mPendingPrincipalHandle = PRINCIPAL_HANDLE_NONE;
mFrameIDForPendingPrincipalHandle = 0;
NS_DispatchToMainThread(NS_NewRunnableFunction([self, principalHandle]() {
if (self->mElement) {
self->mElement->PrincipalHandleChangedForVideoFrameContainer(self, principalHandle);
}
}));
}
if (aImages.IsEmpty()) {
mImageContainer->ClearAllImages();
} else {
mImageContainer->SetCurrentImages(aImages);
}
gfx::IntSize newFrameSize = mImageContainer->GetCurrentSize();
if (oldFrameSize != newFrameSize) {
mImageSizeChanged = true;
}
}
示例5:
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());
}
示例6:
static void
NextBluetoothProfileController()
{
MOZ_ASSERT(NS_IsMainThread());
// First, remove the task at the front which has been already done.
NS_ENSURE_FALSE_VOID(sControllerArray.IsEmpty());
sControllerArray.RemoveElementAt(0);
// Re-check if the task array is empty, if it's not, the next task will begin.
NS_ENSURE_FALSE_VOID(sControllerArray.IsEmpty());
sControllerArray[0]->StartSession();
}
示例7:
void
BluetoothServiceBluedroid::NextBluetoothProfileController()
{
MOZ_ASSERT(NS_IsMainThread());
// Remove the completed task at the head
NS_ENSURE_FALSE_VOID(sControllerArray.IsEmpty());
sControllerArray.RemoveElementAt(0);
// Start the next task if task array is not empty
if (!sControllerArray.IsEmpty()) {
sControllerArray[0]->StartSession();
}
}
示例8: data
void
GMPDecryptorParent::Decrypt(uint32_t aId,
const CryptoSample& aCrypto,
const nsTArray<uint8_t>& aBuffer)
{
LOGV(("GMPDecryptorParent[%p]::Decrypt(id=%d)", this, aId));
if (!mIsOpen) {
NS_WARNING("Trying to use a dead GMP decrypter!");
return;
}
// Caller should ensure parameters passed in are valid.
MOZ_ASSERT(!aBuffer.IsEmpty());
if (aCrypto.mValid) {
GMPDecryptionData data(aCrypto.mKeyId,
aCrypto.mIV,
aCrypto.mPlainSizes,
aCrypto.mEncryptedSizes,
aCrypto.mSessionIds);
Unused << SendDecrypt(aId, aBuffer, data);
} else {
GMPDecryptionData data;
Unused << SendDecrypt(aId, aBuffer, data);
}
}
示例9: autoLock
void
nsHtml5TreeOpStage::MoveOpsAndSpeculativeLoadsTo(nsTArray<nsHtml5TreeOperation>& aOpQueue,
nsTArray<nsHtml5SpeculativeLoad>& aSpeculativeLoadQueue)
{
mozilla::MutexAutoLock autoLock(mMutex);
if (aOpQueue.IsEmpty()) {
mOpQueue.SwapElements(aOpQueue);
} else {
aOpQueue.MoveElementsFrom(mOpQueue);
}
if (aSpeculativeLoadQueue.IsEmpty()) {
mSpeculativeLoadQueue.SwapElements(aSpeculativeLoadQueue);
} else {
aSpeculativeLoadQueue.MoveElementsFrom(mSpeculativeLoadQueue);
}
}
示例10: GetSessionInfo
NS_IMETHODIMP
PresentationService::ReconnectSession(const nsTArray<nsString>& aUrls,
const nsAString& aSessionId,
uint8_t aRole,
nsIPresentationServiceCallback* aCallback)
{
PRES_DEBUG("%s:id[%s]\n", __func__, NS_ConvertUTF16toUTF8(aSessionId).get());
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aSessionId.IsEmpty());
MOZ_ASSERT(aCallback);
MOZ_ASSERT(!aUrls.IsEmpty());
if (aRole != nsIPresentationService::ROLE_CONTROLLER) {
MOZ_ASSERT(false, "Only controller can call ReconnectSession.");
return NS_ERROR_INVALID_ARG;
}
if (NS_WARN_IF(!aCallback)) {
return NS_ERROR_INVALID_ARG;
}
RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
if (NS_WARN_IF(!info)) {
return aCallback->NotifyError(NS_ERROR_DOM_NOT_FOUND_ERR);
}
if (NS_WARN_IF(!aUrls.Contains(info->GetUrl()))) {
return aCallback->NotifyError(NS_ERROR_DOM_NOT_FOUND_ERR);
}
return static_cast<PresentationControllingInfo*>(info.get())->Reconnect(aCallback);
}
示例11:
/* static */ void
SharedMessagePortMessage::FromSharedToMessagesChild(
MessagePortChild* aActor,
const nsTArray<nsRefPtr<SharedMessagePortMessage>>& aData,
nsTArray<MessagePortMessage>& aArray)
{
MOZ_ASSERT(aActor);
MOZ_ASSERT(aArray.IsEmpty());
aArray.SetCapacity(aData.Length());
PBackgroundChild* backgroundManager = aActor->Manager();
MOZ_ASSERT(backgroundManager);
for (auto& data : aData) {
MessagePortMessage* message = aArray.AppendElement();
message->data().SwapElements(data->mData);
const nsTArray<nsRefPtr<BlobImpl>>& blobImpls = data->BlobImpls();
if (!blobImpls.IsEmpty()) {
message->blobsChild().SetCapacity(blobImpls.Length());
for (uint32_t i = 0, len = blobImpls.Length(); i < len; ++i) {
PBlobChild* blobChild =
BackgroundChild::GetOrCreateActorForBlobImpl(backgroundManager,
blobImpls[i]);
message->blobsChild().AppendElement(blobChild);
}
}
message->transferredPorts().AppendElements(data->PortIdentifiers());
}
}
示例12: GetFeatureStatusImpl
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
int32_t *aStatus,
nsAString & aSuggestedDriverVersion,
const nsTArray<GfxDriverInfo>& aDriverInfo,
OperatingSystem* aOS /* = nullptr */)
{
NS_ENSURE_ARG_POINTER(aStatus);
aSuggestedDriverVersion.SetIsVoid(true);
*aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
OperatingSystem os = DRIVER_OS_ANDROID;
if (aOS)
*aOS = os;
EnsureInitializedFromGfxInfoData();
if (!mError.IsEmpty()) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
return NS_OK;
}
// Don't evaluate special cases when evaluating the downloaded blocklist.
if (aDriverInfo.IsEmpty()) {
if (aFeature == FEATURE_WEBGL_OPENGL) {
if (mRenderer.Find("Adreno 200") != -1 ||
mRenderer.Find("Adreno 205") != -1)
{
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
return NS_OK;
}
}
}
return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
}
示例13:
void
FilePickerParent::SendFilesOrDirectories(const nsTArray<BlobImplOrString>& aData)
{
if (mMode == nsIFilePicker::modeGetFolder) {
MOZ_ASSERT(aData.Length() <= 1);
if (aData.IsEmpty()) {
Unused << Send__delete__(this, void_t(), mResult);
return;
}
MOZ_ASSERT(aData[0].mType == BlobImplOrString::eDirectoryPath);
InputDirectory input;
input.directoryPath() = aData[0].mDirectoryPath;
Unused << Send__delete__(this, input, mResult);
return;
}
nsIContentParent* parent = TabParent::GetFrom(Manager())->Manager();
InfallibleTArray<PBlobParent*> blobs;
for (unsigned i = 0; i < aData.Length(); i++) {
MOZ_ASSERT(aData[i].mType == BlobImplOrString::eBlobImpl);
BlobParent* blobParent = parent->GetOrCreateActorForBlobImpl(aData[i].mBlobImpl);
if (blobParent) {
blobs.AppendElement(blobParent);
}
}
InputBlobs inblobs;
inblobs.blobsParent().SwapElements(blobs);
Unused << Send__delete__(this, inblobs, mResult);
}
示例14: if
/**
* AdapterPropertiesNotification will be called after enable() but
* before AdapterStateChangeNotification is called. At that moment,
* BluetoothManager and BluetoothAdapter, do not register observer
* yet.
*/
void
BluetoothServiceBluedroid::AdapterPropertiesNotification(
BluetoothStatus aStatus, int aNumProperties,
const BluetoothProperty* aProperties)
{
MOZ_ASSERT(NS_IsMainThread());
InfallibleTArray<BluetoothNamedValue> propertiesArray;
for (int i = 0; i < aNumProperties; i++) {
const BluetoothProperty& p = aProperties[i];
if (p.mType == PROPERTY_BDADDR) {
sAdapterBdAddress = p.mString;
BT_APPEND_NAMED_VALUE(propertiesArray, "Address", sAdapterBdAddress);
} else if (p.mType == PROPERTY_BDNAME) {
sAdapterBdName = p.mString;
BT_APPEND_NAMED_VALUE(propertiesArray, "Name", sAdapterBdName);
} else if (p.mType == PROPERTY_ADAPTER_SCAN_MODE) {
sAdapterDiscoverable =
(p.mScanMode == SCAN_MODE_CONNECTABLE_DISCOVERABLE);
BT_APPEND_NAMED_VALUE(propertiesArray, "Discoverable",
sAdapterDiscoverable);
} else if (p.mType == PROPERTY_ADAPTER_BONDED_DEVICES) {
// We have to cache addresses of bonded devices. Unlike BlueZ,
// Bluedroid would not send another PROPERTY_ADAPTER_BONDED_DEVICES
// event after bond completed.
BT_LOGD("Adapter property: BONDED_DEVICES. Count: %d",
p.mStringArray.Length());
// Whenever reloading paired devices, force refresh
sAdapterBondedAddressArray.Clear();
sAdapterBondedAddressArray.AppendElements(p.mStringArray);
BT_APPEND_NAMED_VALUE(propertiesArray, "PairedDevices",
sAdapterBondedAddressArray);
} else if (p.mType == PROPERTY_UNKNOWN) {
/* Bug 1065999: working around unknown properties */
} else {
BT_LOGD("Unhandled adapter property type: %d", p.mType);
continue;
}
}
NS_ENSURE_TRUE_VOID(propertiesArray.Length() > 0);
DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
NS_LITERAL_STRING(KEY_ADAPTER),
BluetoothValue(propertiesArray));
// Send reply for SetProperty
if (!sSetPropertyRunnableArray.IsEmpty()) {
DispatchReplySuccess(sSetPropertyRunnableArray[0]);
sSetPropertyRunnableArray.RemoveElementAt(0);
}
}
示例15: LOG
void
nsWindow::DoDraw(void)
{
if (!hal::GetScreenEnabled()) {
gDrawRequest = true;
return;
}
if (sTopWindows.IsEmpty()) {
LOG(" no window to draw, bailing");
return;
}
nsWindow *targetWindow = (nsWindow *)sTopWindows[0];
while (targetWindow->GetLastChild())
targetWindow = (nsWindow *)targetWindow->GetLastChild();
nsIWidgetListener* listener = targetWindow->GetWidgetListener();
if (listener) {
listener->WillPaintWindow(targetWindow);
}
LayerManager* lm = targetWindow->GetLayerManager();
if (mozilla::layers::LayersBackend::LAYERS_CLIENT == lm->GetBackendType()) {
// No need to do anything, the compositor will handle drawing
} else {
NS_RUNTIMEABORT("Unexpected layer manager type");
}
listener = targetWindow->GetWidgetListener();
if (listener) {
listener->DidPaintWindow();
}
}