本文整理汇总了C++中InfallibleTArray类的典型用法代码示例。如果您正苦于以下问题:C++ InfallibleTArray类的具体用法?C++ InfallibleTArray怎么用?C++ InfallibleTArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InfallibleTArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: BondStateChangedCallback
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;
BT_APPEND_NAMED_VALUE(propertiesChangeArray, "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;
BT_APPEND_NAMED_VALUE(propertiesArray, "address", remoteAddress);
BT_APPEND_NAMED_VALUE(propertiesArray, "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);
}
}
示例3: BT_LOG
void
BluetoothAdapter::Notify(const BluetoothSignal& aData)
{
InfallibleTArray<BluetoothNamedValue> arr;
BT_LOG("[A] %s: %s", __FUNCTION__, NS_ConvertUTF16toUTF8(aData.name()).get());
BluetoothValue v = aData.value();
if (aData.name().EqualsLiteral("DeviceFound")) {
nsRefPtr<BluetoothDevice> device = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothDeviceEvent(getter_AddRefs(event), this, nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
e->InitBluetoothDeviceEvent(NS_LITERAL_STRING("devicefound"),
false, false, device);
DispatchTrustedEvent(event);
} else if (aData.name().EqualsLiteral("PropertyChanged")) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
const InfallibleTArray<BluetoothNamedValue>& arr =
v.get_ArrayOfBluetoothNamedValue();
MOZ_ASSERT(arr.Length() == 1);
SetPropertyByValue(arr[0]);
} else if (aData.name().EqualsLiteral(PAIRED_STATUS_CHANGED_ID) ||
aData.name().EqualsLiteral(HFP_STATUS_CHANGED_ID) ||
aData.name().EqualsLiteral(SCO_STATUS_CHANGED_ID) ||
aData.name().EqualsLiteral(A2DP_STATUS_CHANGED_ID)) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
const InfallibleTArray<BluetoothNamedValue>& arr =
v.get_ArrayOfBluetoothNamedValue();
MOZ_ASSERT(arr.Length() == 2 &&
arr[0].value().type() == BluetoothValue::TnsString &&
arr[1].value().type() == BluetoothValue::Tbool);
nsString address = arr[0].value().get_nsString();
bool status = arr[1].value().get_bool();
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothStatusChangedEvent(
getter_AddRefs(event), this, nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothStatusChangedEvent> e = do_QueryInterface(event);
e->InitBluetoothStatusChangedEvent(aData.name(), false, false,
address, status);
DispatchTrustedEvent(event);
} else {
#ifdef DEBUG
nsCString warningMsg;
warningMsg.AssignLiteral("Not handling adapter signal: ");
warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
NS_WARNING(warningMsg.get());
#endif
}
}
示例4: HoldUntilComplete
void
LayerTransactionParent::SendFenceHandle(AsyncTransactionTracker* aTracker,
PTextureParent* aTexture,
const FenceHandle& aFence)
{
HoldUntilComplete(aTracker);
InfallibleTArray<AsyncParentMessageData> messages;
messages.AppendElement(OpDeliverFence(aTracker->GetId(),
aTexture, nullptr,
aFence));
mozilla::unused << SendParentAsyncMessages(messages);
}
示例5: HoldUntilComplete
void
ImageBridgeChild::SendFenceHandle(AsyncTransactionTracker* aTracker,
PTextureChild* aTexture,
const FenceHandle& aFence)
{
HoldUntilComplete(aTracker);
InfallibleTArray<AsyncChildMessageData> messages;
messages.AppendElement(OpDeliverFenceFromChild(aTracker->GetId(),
nullptr, aTexture,
FenceHandleFromChild(aFence)));
SendChildAsyncMessages(messages);
}
示例6: UDPSOCKET_LOG
NS_IMETHODIMP
UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage)
{
// receiving packet from remote host, forward the message content to child process
if (!mIPCOpen) {
return NS_OK;
}
uint16_t port;
nsCString ip;
nsCOMPtr<nsINetAddr> fromAddr;
aMessage->GetFromAddr(getter_AddRefs(fromAddr));
fromAddr->GetPort(&port);
fromAddr->GetAddress(ip);
nsCString data;
aMessage->GetData(data);
const char* buffer = data.get();
uint32_t len = data.Length();
UDPSOCKET_LOG(("%s: %s:%u, length %u", __FUNCTION__, ip.get(), port, len));
if (mFilter) {
bool allowed;
mozilla::net::NetAddr addr;
fromAddr->GetNetAddr(&addr);
nsresult rv = mFilter->FilterPacket(&addr,
(const uint8_t*)buffer, len,
nsIUDPSocketFilter::SF_INCOMING,
&allowed);
// Receiving unallowed data, drop.
if (NS_WARN_IF(NS_FAILED(rv)) || !allowed) {
if (!allowed) {
UDPSOCKET_LOG(("%s: not allowed", __FUNCTION__));
}
return NS_OK;
}
}
FallibleTArray<uint8_t> fallibleArray;
if (!fallibleArray.InsertElementsAt(0, buffer, len)) {
FireInternalError(__LINE__);
return NS_ERROR_OUT_OF_MEMORY;
}
InfallibleTArray<uint8_t> infallibleArray;
infallibleArray.SwapElements(fallibleArray);
// compose callback
mozilla::unused << SendCallbackReceivedData(UDPAddressInfo(ip, port), infallibleArray);
return NS_OK;
}
示例7: SurfaceDescriptorTiles
SurfaceDescriptorTiles
SimpleTiledLayerBuffer::GetSurfaceDescriptorTiles()
{
InfallibleTArray<TileDescriptor> tiles;
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
tiles.AppendElement(mRetainedTiles[i].GetTileDescriptor());
}
return SurfaceDescriptorTiles(mValidRegion, mPaintedRegion,
tiles, mRetainedWidth, mRetainedHeight,
mResolution, mFrameResolution.scale);
}
示例8: SurfaceDescriptorTiles
SurfaceDescriptorTiles
ClientSingleTiledLayerBuffer::GetSurfaceDescriptorTiles() {
InfallibleTArray<TileDescriptor> tiles;
TileDescriptor tileDesc = mTile.GetTileDescriptor();
tiles.AppendElement(tileDesc);
mTile.mUpdateRect = gfx::IntRect();
return SurfaceDescriptorTiles(mValidRegion, tiles, mTilingOrigin, mSize, 0, 0,
1, 1, 1.0, mFrameResolution.xScale,
mFrameResolution.yScale,
mWasLastPaintProgressive);
}
示例9: CrashReporter
bool
PluginModuleParent::ShouldContinueFromReplyTimeout()
{
#ifdef MOZ_CRASHREPORTER
CrashReporterParent* crashReporter = CrashReporter();
if (crashReporter->GeneratePairedMinidump(this)) {
mBrowserDumpID = crashReporter->ParentDumpID();
mPluginDumpID = crashReporter->ChildDumpID();
PLUGIN_LOG_DEBUG(
("generated paired browser/plugin minidumps: %s/%s (ID=%s)",
NS_ConvertUTF16toUTF8(mBrowserDumpID).get(),
NS_ConvertUTF16toUTF8(mPluginDumpID).get(),
NS_ConvertUTF16toUTF8(crashReporter->HangID()).get()));
} 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;
}
示例10: MOZ_ASSERT
already_AddRefed<Promise>
Directory::CreateFile(const nsAString& aPath, const CreateFileOptions& aOptions,
ErrorResult& aRv)
{
// Only exposed for DeviceStorage.
MOZ_ASSERT(NS_IsMainThread());
RefPtr<Blob> blobData;
InfallibleTArray<uint8_t> arrayData;
bool replace = (aOptions.mIfExists == CreateIfExistsMode::Replace);
// Get the file content.
if (aOptions.mData.WasPassed()) {
auto& data = aOptions.mData.Value();
if (data.IsString()) {
NS_ConvertUTF16toUTF8 str(data.GetAsString());
arrayData.AppendElements(reinterpret_cast<const uint8_t *>(str.get()),
str.Length());
} else if (data.IsArrayBuffer()) {
const ArrayBuffer& buffer = data.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
arrayData.AppendElements(buffer.Data(), buffer.Length());
} else if (data.IsArrayBufferView()){
const ArrayBufferView& view = data.GetAsArrayBufferView();
view.ComputeLengthAndData();
arrayData.AppendElements(view.Data(), view.Length());
} else {
blobData = data.GetAsBlob();
}
}
nsCOMPtr<nsIFile> realPath;
nsresult error = DOMPathToRealPath(aPath, getter_AddRefs(realPath));
RefPtr<FileSystemBase> fs = GetFileSystem(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
RefPtr<CreateFileTaskChild> task =
CreateFileTaskChild::Create(fs, realPath, blobData, arrayData, replace,
aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
task->SetError(error);
FileSystemPermissionRequest::RequestForTask(task);
return task->GetPromise();
}
示例11:
void
TabChild::ArraysToParams(const InfallibleTArray<int>& aIntParams,
const InfallibleTArray<nsString>& aStringParams,
nsIDialogParamBlock* aParams)
{
if (aParams) {
for (PRInt32 i = 0; PRUint32(i) < aIntParams.Length(); ++i) {
aParams->SetInt(i, aIntParams[i]);
}
for (PRInt32 j = 0; PRUint32(j) < aStringParams.Length(); ++j) {
aParams->SetString(j, aStringParams[j].get());
}
}
}
示例12: SampleValue
static void
SampleValue(float aPortion, Animation& aAnimation, StyleAnimationValue& aStart,
StyleAnimationValue& aEnd, Animatable* aValue)
{
StyleAnimationValue interpolatedValue;
NS_ASSERTION(aStart.GetUnit() == aEnd.GetUnit() ||
aStart.GetUnit() == StyleAnimationValue::eUnit_None ||
aEnd.GetUnit() == StyleAnimationValue::eUnit_None,
"Must have same unit");
StyleAnimationValue::Interpolate(aAnimation.property(), aStart, aEnd,
aPortion, interpolatedValue);
if (aAnimation.property() == eCSSProperty_opacity) {
*aValue = interpolatedValue.GetFloatValue();
return;
}
nsCSSValueSharedList* interpolatedList =
interpolatedValue.GetCSSValueSharedListValue();
TransformData& data = aAnimation.data().get_TransformData();
nsPoint origin = data.origin();
// we expect all our transform data to arrive in css pixels, so here we must
// adjust to dev pixels.
double cssPerDev = double(nsDeviceContext::AppUnitsPerCSSPixel())
/ double(data.appUnitsPerDevPixel());
gfxPoint3D transformOrigin = data.transformOrigin();
transformOrigin.x = transformOrigin.x * cssPerDev;
transformOrigin.y = transformOrigin.y * cssPerDev;
gfxPoint3D perspectiveOrigin = data.perspectiveOrigin();
perspectiveOrigin.x = perspectiveOrigin.x * cssPerDev;
perspectiveOrigin.y = perspectiveOrigin.y * cssPerDev;
nsDisplayTransform::FrameTransformProperties props(interpolatedList,
transformOrigin,
perspectiveOrigin,
data.perspective());
gfx3DMatrix transform =
nsDisplayTransform::GetResultingTransformMatrix(props, origin,
data.appUnitsPerDevPixel(),
&data.bounds());
gfxPoint3D scaledOrigin =
gfxPoint3D(NS_round(NSAppUnitsToFloatPixels(origin.x, data.appUnitsPerDevPixel())),
NS_round(NSAppUnitsToFloatPixels(origin.y, data.appUnitsPerDevPixel())),
0.0f);
transform.Translate(scaledOrigin);
InfallibleTArray<TransformFunction> functions;
functions.AppendElement(TransformMatrix(ToMatrix4x4(transform)));
*aValue = functions;
}
示例13: DispatchEvent
void
BluetoothAdapter::Notify(const BluetoothSignal& aData)
{
InfallibleTArray<BluetoothNamedValue> arr;
if (aData.name().EqualsLiteral("DeviceFound")) {
nsRefPtr<BluetoothDevice> device = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothDeviceEvent(getter_AddRefs(event), nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
e->InitBluetoothDeviceEvent(NS_LITERAL_STRING("devicefound"),
false, false, device);
e->SetTrusted(true);
bool dummy;
DispatchEvent(event, &dummy);
} else if (aData.name().EqualsLiteral("DeviceDisappeared")) {
const nsAString& deviceAddress = aData.value().get_nsString();
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothDeviceAddressEvent(getter_AddRefs(event), nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothDeviceAddressEvent> e = do_QueryInterface(event);
e->InitBluetoothDeviceAddressEvent(NS_LITERAL_STRING("devicedisappeared"),
false, false, deviceAddress);
e->SetTrusted(true);
bool dummy;
DispatchEvent(event, &dummy);
} else if (aData.name().EqualsLiteral("PropertyChanged")) {
// Get BluetoothNamedValue, make sure array length is 1
arr = aData.value().get_ArrayOfBluetoothNamedValue();
NS_ASSERTION(arr.Length() == 1, "Got more than one property in a change message!");
NS_ASSERTION(arr[0].value().type() == BluetoothValue::TArrayOfBluetoothNamedValue,
"PropertyChanged: Invalid value type");
BluetoothNamedValue v = arr[0];
SetPropertyByValue(v);
nsRefPtr<BluetoothPropertyEvent> e = BluetoothPropertyEvent::Create(v.name());
e->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("propertychanged"));
} else {
#ifdef DEBUG
nsCString warningMsg;
warningMsg.AssignLiteral("Not handling adapter signal: ");
warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name()));
NS_WARNING(warningMsg.get());
#endif
}
}
示例14: NS_ASSERTION
NS_IMETHODIMP
UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage)
{
// receiving packet from remote host, forward the message content to child process
if (!mIPCOpen) {
return NS_OK;
}
NS_ASSERTION(mFilter, "No packet filter");
uint16_t port;
nsCString ip;
nsCOMPtr<nsINetAddr> fromAddr;
aMessage->GetFromAddr(getter_AddRefs(fromAddr));
fromAddr->GetPort(&port);
fromAddr->GetAddress(ip);
nsCString data;
aMessage->GetData(data);
const char* buffer = data.get();
uint32_t len = data.Length();
bool allowed;
mozilla::net::NetAddr addr;
fromAddr->GetNetAddr(&addr);
nsresult rv = mFilter->FilterPacket(&addr,
(const uint8_t*)buffer, len,
nsIUDPSocketFilter::SF_INCOMING,
&allowed);
// Receiving unallowed data, drop.
NS_ENSURE_SUCCESS(rv, NS_OK);
NS_ENSURE_TRUE(allowed, NS_OK);
FallibleTArray<uint8_t> fallibleArray;
if (!fallibleArray.InsertElementsAt(0, buffer, len)) {
FireInternalError(this, __LINE__);
return NS_ERROR_OUT_OF_MEMORY;
}
InfallibleTArray<uint8_t> infallibleArray;
infallibleArray.SwapElements(fallibleArray);
// compose callback
mozilla::unused <<
PUDPSocketParent::SendCallback(NS_LITERAL_CSTRING("ondata"),
UDPMessage(ip, port, infallibleArray),
NS_LITERAL_CSTRING("connected"));
return NS_OK;
}
示例15: CommonAttrs
void
TestDataStructuresChild::Test17()
{
Attrs attrs;
attrs.common() = CommonAttrs(true);
attrs.specific() = BarAttrs(1.0f);
InfallibleTArray<Op> ops;
ops.AppendElement(SetAttrs(NULL, mKids[0], attrs));
if (!SendTest17(ops))
fail("sending Test17");
printf(" passed %s\n", __FUNCTION__);
}