本文整理汇总了C++中InfallibleTArray::AppendElement方法的典型用法代码示例。如果您正苦于以下问题:C++ InfallibleTArray::AppendElement方法的具体用法?C++ InfallibleTArray::AppendElement怎么用?C++ InfallibleTArray::AppendElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InfallibleTArray
的用法示例。
在下文中一共展示了InfallibleTArray::AppendElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fail
void
TestDataStructuresChild::Test14()
{
InfallibleTArray<int> ai;
ai.AppendElement(1); ai.AppendElement(2); ai.AppendElement(3);
SActors ia;
ia.i() = 42;
ia.ai() = ai;
ia.apChild() = mKids;
InfallibleTArray<SActors> aa; aa.AppendElement(ia);
Structs i;
i.i() = 42;
i.ai() = ai;
i.apChild() = mKids;
i.aa() = aa;
Structs o;
if (!SendTest14(i, &o))
fail("can't send Test14");
test_assert(42 == o.i(), "wrong value");
assert_arrays_equal(ai, o.ai());
assert_arrays_equal(mKids, o.apChild());
const SActors& os = o.aa()[0];
test_assert(42 == os.i(), "wrong value");
assert_arrays_equal(ai, os.ai());
assert_arrays_equal(mKids, os.apChild());
printf(" passed %s\n", __FUNCTION__);
}
示例2:
bool TestDataStructuresParent::RecvTest16(
const WithUnions& i,
WithUnions* o)
{
test_assert(i.i() == 42, "wrong value");
InfallibleTArray<int> ai;
ai.AppendElement(1); ai.AppendElement(2); ai.AppendElement(3);
assert_arrays_equal(ai, i.ai());
assert_arrays_equal(i.apParent(), mKids);
assert_arrays_equal(mKids, i.aa()[0].get_ArrayOfPTestDataStructuresSubParent());
const InfallibleTArray<Unions>& iau = i.au();
test_assert(iau[0] == 42, "wrong value");
assert_arrays_equal(ai, iau[1].get_ArrayOfint());
assert_arrays_equal(mKids, iau[2].get_ArrayOfPTestDataStructuresSubParent());
assert_arrays_equal(mKids,
iau[3].get_ArrayOfActors()[0]
.get_ArrayOfPTestDataStructuresSubParent());
*o = i;
return true;
}
示例3: signal
static void
SspRequestCallback(bt_bdaddr_t* aRemoteBdAddress, bt_bdname_t* aRemoteBdName,
uint32_t aRemoteClass, bt_ssp_variant_t aPairingVariant,
uint32_t aPasskey)
{
MOZ_ASSERT(!NS_IsMainThread());
InfallibleTArray<BluetoothNamedValue> propertiesArray;
nsAutoString remoteAddress;
BdAddressTypeToString(aRemoteBdAddress, remoteAddress);
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("address"), remoteAddress));
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("method"),
NS_LITERAL_STRING("confirmation")));
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("name"),
NS_ConvertUTF8toUTF16(
(const char*)aRemoteBdName->name)));
propertiesArray.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("passkey"), aPasskey));
BluetoothValue value = propertiesArray;
BluetoothSignal signal(NS_LITERAL_STRING("RequestConfirmation"),
NS_LITERAL_STRING(KEY_LOCAL_AGENT), value);
nsRefPtr<DistributeBluetoothSignalTask>
t = new DistributeBluetoothSignalTask(signal);
if (NS_FAILED(NS_DispatchToMainThread(t))) {
BT_WARNING("Failed to dispatch to main thread!");
}
}
示例4:
static void
Array123(InfallibleTArray<JSONVariant>& a123)
{
a123.AppendElement(1); a123.AppendElement(2); a123.AppendElement(3);
test_assert(a123 == a123, "operator== is broken");
}
示例5: CrashReporter
bool
PluginModuleParent::ShouldContinueFromReplyTimeout()
{
#ifdef MOZ_CRASHREPORTER
CrashReporterParent* crashReporter = CrashReporter();
crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("PluginHang"),
NS_LITERAL_CSTRING("1"));
if (crashReporter->GeneratePairedMinidump(this)) {
mPluginDumpID = crashReporter->ChildDumpID();
PLUGIN_LOG_DEBUG(
("generated paired browser/plugin minidumps: %s)",
NS_ConvertUTF16toUTF8(mPluginDumpID).get()));
crashReporter->AnnotateCrashReport(
NS_LITERAL_CSTRING("additional_minidumps"),
NS_LITERAL_CSTRING("browser"));
// TODO: collect Flash minidumps here
} else {
NS_WARNING("failed to capture paired minidumps from hang");
}
#endif
#ifdef XP_WIN
// collect cpu usage for plugin processes
InfallibleTArray<base::ProcessHandle> processHandles;
base::ProcessHandle handle;
processHandles.AppendElement(OtherProcess());
#ifdef MOZ_CRASHREPORTER_INJECTOR
if (mFlashProcess1 && base::OpenProcessHandle(mFlashProcess1, &handle)) {
processHandles.AppendElement(handle);
}
if (mFlashProcess2 && base::OpenProcessHandle(mFlashProcess2, &handle)) {
processHandles.AppendElement(handle);
}
#endif
if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) {
mPluginCpuUsageOnHang.Clear();
}
#endif
// this must run before the error notification from the channel,
// or not at all
MessageLoop::current()->PostTask(
FROM_HERE,
mTaskFactory.NewRunnableMethod(
&PluginModuleParent::CleanupFromTimeout));
if (!KillProcess(OtherProcess(), 1, false))
NS_WARNING("failed to kill subprocess!");
return false;
}
示例6: 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);
}
}
示例7: PluginInstanceParent
nsresult
PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
uint16_t mode, int16_t argc, char* argn[],
char* argv[], NPSavedData* saved,
NPError* error)
{
PLUGIN_LOG_DEBUG_METHOD;
if (mShutdown) {
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
// create the instance on the other side
InfallibleTArray<nsCString> names;
InfallibleTArray<nsCString> values;
for (int i = 0; i < argc; ++i) {
names.AppendElement(NullableString(argn[i]));
values.AppendElement(NullableString(argv[i]));
}
PluginInstanceParent* parentInstance =
new PluginInstanceParent(this, instance,
nsDependentCString(pluginType), mNPNIface);
if (!parentInstance->Init()) {
delete parentInstance;
return NS_ERROR_FAILURE;
}
instance->pdata = parentInstance;
if (!CallPPluginInstanceConstructor(parentInstance,
nsDependentCString(pluginType), mode,
names, values, error)) {
// |parentInstance| is automatically deleted.
instance->pdata = nsnull;
// if IPC is down, we'll get an immediate "failed" return, but
// without *error being set. So make sure that the error
// condition is signaled to nsNPAPIPluginInstance
if (NPERR_NO_ERROR == *error)
*error = NPERR_GENERIC_ERROR;
return NS_ERROR_FAILURE;
}
if (*error != NPERR_NO_ERROR) {
NPP_Destroy(instance, 0);
return NS_ERROR_FAILURE;
}
TimeoutChanged(kParentTimeoutPref, this);
return NS_OK;
}
示例8: WithStructs
void
TestDataStructuresChild::Test15()
{
InfallibleTArray<int> ai;
ai.AppendElement(1); ai.AppendElement(2); ai.AppendElement(3);
SActors ia;
ia.i() = 42;
ia.ai() = ai;
ia.apChild() = mKids;
InfallibleTArray<SActors> iaa; iaa.AppendElement(ia);
Structs is;
is.i() = 42;
is.ai() = ai;
is.apChild() = mKids;
is.aa() = iaa;
InfallibleTArray<Structs> isa; isa.AppendElement(is);
WithStructs o1, o2, o3, o4, o5;
if (!SendTest15(WithStructs(42),
WithStructs(ai),
WithStructs(mKids),
WithStructs(iaa),
WithStructs(isa),
&o1, &o2, &o3, &o4, &o5))
fail("sending Test15");
test_assert(o1 == int(42), "wrong value");
assert_arrays_equal(o2.get_ArrayOfint(), ai);
assert_arrays_equal(o3.get_ArrayOfPTestDataStructuresSubChild(), mKids);
const SActors& oa = o4.get_ArrayOfSActors()[0];
test_assert(42 == oa.i(), "wrong value");
assert_arrays_equal(ai, oa.ai());
assert_arrays_equal(mKids, oa.apChild());
const Structs& os = o5.get_ArrayOfStructs()[0];
test_assert(42 == os.i(), "wrong value");
assert_arrays_equal(ai, os.ai());
assert_arrays_equal(mKids, os.apChild());
const SActors& osa = os.aa()[0];
test_assert(42 == osa.i(), "wrong value");
assert_arrays_equal(ai, osa.ai());
assert_arrays_equal(mKids, osa.apChild());
printf(" passed %s\n", __FUNCTION__);
}
示例9:
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);
}
示例10: dsvf
nsresult
DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIRunnable> r;
bool check = false;
mFile->mFile->Exists(&check);
if (!check) {
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
NS_DispatchToMainThread(r);
return NS_OK;
}
nsTArray<nsRefPtr<DeviceStorageFile> > files;
mFile->CollectFiles(files, mSince);
InfallibleTArray<DeviceStorageFileValue> values;
PRUint32 count = files.Length();
for (PRUint32 i = 0; i < count; i++) {
nsString fullpath;
files[i]->mFile->GetPath(fullpath);
DeviceStorageFileValue dsvf(files[i]->mPath, fullpath);
values.AppendElement(dsvf);
}
r = new PostEnumerationSuccessEvent(mParent, values);
NS_DispatchToMainThread(r);
return NS_OK;
}
示例11: switch
bool
LayerTransactionChild::RecvParentAsyncMessage(const mozilla::layers::AsyncParentMessageData& aMessage)
{
switch (aMessage.type()) {
case AsyncParentMessageData::TOpDeliverFence: {
const OpDeliverFence& op = aMessage.get_OpDeliverFence();
FenceHandle fence = op.fence();
PTextureChild* child = op.textureChild();
RefPtr<TextureClient> texture = TextureClient::AsTextureClient(child);
if (texture) {
texture->SetReleaseFenceHandle(fence);
}
if (mForwarder) {
mForwarder->HoldTransactionsToRespond(op.transactionId());
} else {
// Send back a response.
InfallibleTArray<AsyncChildMessageData> replies;
replies.AppendElement(OpReplyDeliverFence(op.transactionId()));
SendChildAsyncMessages(replies);
}
break;
}
default:
NS_ERROR("unknown AsyncParentMessageData type");
return false;
}
return true;
}
示例12: defined
void
CompositableParentManager::SendPendingAsyncMessges()
{
if (mPendingAsyncMessage.empty()) {
return;
}
// Some type of AsyncParentMessageData message could have
// one file descriptor (e.g. OpDeliverFence).
// A number of file descriptors per gecko ipc message have a limitation
// on OS_POSIX (MACOSX or LINUX).
#if defined(OS_POSIX)
static const uint32_t kMaxMessageNumber = FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE;
#else
// default number that works everywhere else
static const uint32_t kMaxMessageNumber = 250;
#endif
InfallibleTArray<AsyncParentMessageData> messages;
messages.SetCapacity(mPendingAsyncMessage.size());
for (size_t i = 0; i < mPendingAsyncMessage.size(); i++) {
messages.AppendElement(mPendingAsyncMessage[i]);
// Limit maximum number of messages.
if (messages.Length() >= kMaxMessageNumber) {
SendAsyncMessage(messages);
// Initialize Messages.
messages.Clear();
}
}
if (messages.Length() > 0) {
SendAsyncMessage(messages);
}
mPendingAsyncMessage.clear();
}
示例13: SendParentAsyncMessages
void
ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply)
{
InfallibleTArray<AsyncParentMessageData> messages;
messages.AppendElement(aReply);
mozilla::unused << SendParentAsyncMessages(messages);
}
示例14: NS_DispatchToMainThread
nsresult
DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
{
MOZ_ASSERT(!NS_IsMainThread());
if (mFile->mFile) {
bool check = false;
mFile->mFile->Exists(&check);
if (!check) {
return NS_DispatchToMainThread(
new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST));
}
}
nsTArray<RefPtr<DeviceStorageFile> > files;
mFile->CollectFiles(files, mSince);
InfallibleTArray<DeviceStorageFileValue> values;
uint32_t count = files.Length();
for (uint32_t i = 0; i < count; i++) {
DeviceStorageFileValue dsvf(files[i]->mStorageName, files[i]->mPath);
values.AppendElement(dsvf);
}
return NS_DispatchToMainThread(
new PostEnumerationSuccessEvent(mParent, mFile->mStorageType,
mFile->mRootDir, values));
}
示例15: signal
static void
A2dpAudioStateCallback(btav_audio_state_t aState,
bt_bdaddr_t* aBdAddress)
{
MOZ_ASSERT(!NS_IsMainThread());
nsString remoteDeviceBdAddress;
BdAddressTypeToString(aBdAddress, remoteDeviceBdAddress);
nsString a2dpState;
if (aState == BTAV_AUDIO_STATE_STARTED) {
a2dpState = NS_LITERAL_STRING("playing");
} else if (aState == BTAV_AUDIO_STATE_STOPPED) {
// for avdtp state stop stream
a2dpState = NS_LITERAL_STRING("connected");
} else if (aState == BTAV_AUDIO_STATE_REMOTE_SUSPEND) {
// for avdtp state suspend stream from remote side
a2dpState = NS_LITERAL_STRING("connected");
}
InfallibleTArray<BluetoothNamedValue> props;
props.AppendElement(
BluetoothNamedValue(NS_LITERAL_STRING("State"), a2dpState));
BluetoothSignal signal(NS_LITERAL_STRING("AudioSink"),
remoteDeviceBdAddress, props);
NS_DispatchToMainThread(new SinkPropertyChangedHandler(signal));
}