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; }
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); } }
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 } }
bool ContentChild::Init(MessageLoop* aIOLoop, base::ProcessHandle aParentHandle, IPC::Channel* aChannel) { #ifdef MOZ_WIDGET_GTK // sigh gtk_init(NULL, NULL); #endif #ifdef MOZ_WIDGET_QT // sigh, seriously nsQAppInstance::AddRef(); #endif #ifdef MOZ_X11 // Do this after initializing GDK, or GDK will install its own handler. XRE_InstallX11ErrorHandler(); #endif NS_ASSERTION(!sSingleton, "only one ContentChild per child"); Open(aChannel, aParentHandle, aIOLoop); sSingleton = this; #ifdef MOZ_CRASHREPORTER SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(), XRE_GetProcessType()); #if defined(MOZ_WIDGET_ANDROID) PCrashReporterChild* crashreporter = ManagedPCrashReporterChild()[0]; InfallibleTArray<Mapping> mappings; const struct mapping_info *info = getLibraryMapping(); while (info && info->name) { mappings.AppendElement(Mapping(nsDependentCString(info->name), nsDependentCString(info->file_id), info->base, info->len, info->offset)); info++; } crashreporter->SendAddLibraryMappings(mappings); #endif #endif SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser); if (mIsForApp && !mIsForBrowser) { SetProcessName(NS_LITERAL_STRING("(Preallocated app)")); } else { SetProcessName(NS_LITERAL_STRING("Browser")); } return true; }
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); }
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); }
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; }
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); }
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); }
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; }
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(); }
bool ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child) { nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); InfallibleTArray<MemoryReport> reports; static const int maxLength = 31; // big enough; pid is only a few chars nsPrintfCString process(maxLength, "Content (%d)", getpid()); // First do the vanilla memory reporters. nsCOMPtr<nsISimpleEnumerator> e; mgr->EnumerateReporters(getter_AddRefs(e)); bool more; while (NS_SUCCEEDED(e->HasMoreElements(&more)) && more) { nsCOMPtr<nsIMemoryReporter> r; e->GetNext(getter_AddRefs(r)); nsCString path; PRInt32 kind; PRInt32 units; PRInt64 amount; nsCString desc; r->GetPath(path); r->GetKind(&kind); r->GetUnits(&units); r->GetAmount(&amount); r->GetDescription(desc); MemoryReport memreport(process, path, kind, units, amount, desc); reports.AppendElement(memreport); } // Then do the memory multi-reporters, by calling CollectReports on each // one, whereupon the callback will turn each measurement into a // MemoryReport. mgr->EnumerateMultiReporters(getter_AddRefs(e)); nsRefPtr<MemoryReportsWrapper> wrappedReports = new MemoryReportsWrapper(&reports); nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process); while (NS_SUCCEEDED(e->HasMoreElements(&more)) && more) { nsCOMPtr<nsIMemoryMultiReporter> r; e->GetNext(getter_AddRefs(r)); r->CollectReports(cb, wrappedReports); } child->Send__delete__(child, reports); return true; }
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()); } } }
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; }
bool ImageBridgeParent::RecvStop() { // If there is any texture still alive we have to force it to deallocate the // device data (GL textures, etc.) now because shortly after SenStop() returns // on the child side the widget will be destroyed along with it's associated // GL context. InfallibleTArray<PTextureParent*> textures; ManagedPTextureParent(textures); for (unsigned int i = 0; i < textures.Length(); ++i) { RefPtr<TextureHost> tex = TextureHost::AsTextureHost(textures[i]); tex->DeallocateDeviceData(); } return true; }
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 } }
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; }
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__); }
bool TestDataStructuresParent::RecvTest13( const SActors& i, SActors* o) { InfallibleTArray<int> ai; ai.AppendElement(1); ai.AppendElement(2); ai.AppendElement(3); test_assert(42 == i.i(), "wrong value"); assert_arrays_equal(ai, i.ai()); assert_arrays_equal(mKids, i.apParent()); *o = i; return true; }
void ContentParent::SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report) { nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); for (PRInt32 i = 0; i < mMemoryReporters.Count(); i++) mgr->UnregisterReporter(mMemoryReporters[i]); for (PRUint32 i = 0; i < report.Length(); i++) { nsCString process = report[i].process(); nsCString path = report[i].path(); PRInt32 kind = report[i].kind(); PRInt32 units = report[i].units(); PRInt64 amount = report[i].amount(); nsCString desc = report[i].desc(); nsRefPtr<nsMemoryReporter> r = new nsMemoryReporter(process, path, kind, units, amount, desc); mMemoryReporters.AppendObject(r); mgr->RegisterReporter(r); } nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1"); if (obs) obs->NotifyObservers(nsnull, "child-memory-reporter-update", nsnull); }
bool FilePickerParent::RecvOpen(const int16_t& aSelectedType, const bool& aAddToRecentDocs, const nsString& aDefaultFile, const nsString& aDefaultExtension, const InfallibleTArray<nsString>& aFilters, const InfallibleTArray<nsString>& aFilterNames) { if (!CreateFilePicker()) { unused << Send__delete__(this, void_t(), nsIFilePicker::returnCancel); return true; } mFilePicker->SetAddToRecentDocs(aAddToRecentDocs); for (uint32_t i = 0; i < aFilters.Length(); ++i) { mFilePicker->AppendFilter(aFilterNames[i], aFilters[i]); } mFilePicker->SetDefaultString(aDefaultFile); mFilePicker->SetDefaultExtension(aDefaultExtension); mFilePicker->SetFilterIndex(aSelectedType); mCallback = new FilePickerShownCallback(this); mFilePicker->Open(mCallback); return true; }
bool TestDataStructuresParent::RecvTest6( const InfallibleTArray<IntDoubleArrays>& i1, InfallibleTArray<IntDoubleArrays>* o1) { test_assert(3 == i1.Length(), "wrong length"); IntDoubleArrays id1(i1[0]); test_assert(42 == id1.get_int(), "wrong value"); InfallibleTArray<int> i2a(i1[1].get_ArrayOfint()); test_assert(3 == i2a.Length(), "wrong length"); test_assert(1 == i2a[0], "wrong value"); test_assert(2 == i2a[1], "wrong value"); test_assert(3 == i2a[2], "wrong value"); InfallibleTArray<double> i3a(i1[2].get_ArrayOfdouble()); test_assert(3 == i3a.Length(), "wrong length"); test_assert(1.0 == i3a[0], "wrong value"); test_assert(2.0 == i3a[1], "wrong value"); test_assert(3.0 == i3a[2], "wrong value"); o1->AppendElement(id1); o1->AppendElement(IntDoubleArrays(i2a)); o1->AppendElement(IntDoubleArrays(i3a)); return true; }
void TestDataStructuresChild::Test1() { InfallibleTArray<int> ia; for (int i = 0; i < 5; ++i) ia.AppendElement(i); InfallibleTArray<int> oa; if (!SendTest1(ia, &oa)) fail("can't send Test1"); assert_arrays_equal(ia, oa); printf(" passed %s\n", __FUNCTION__); }
bool SetJsObject(JSContext* aContext, JSObject* aObj, const InfallibleTArray<BluetoothNamedValue>& aData) { for (int i = 0; i < aData.Length(); i++) { jsval v; if (aData[i].value().type() == BluetoothValue::TnsString) { nsString data = aData[i].value().get_nsString(); JSString* JsData = JS_NewStringCopyN(aContext, NS_ConvertUTF16toUTF8(data).get(), data.Length()); NS_ENSURE_TRUE(JsData, NS_ERROR_OUT_OF_MEMORY); v = STRING_TO_JSVAL(JsData); } else if (aData[i].value().type() == BluetoothValue::Tuint32_t) { int data = aData[i].value().get_uint32_t(); v = INT_TO_JSVAL(data); } else if (aData[i].value().type() == BluetoothValue::Tbool) { bool data = aData[i].value().get_bool(); v = BOOLEAN_TO_JSVAL(data); } else { NS_WARNING("SetJsObject: Parameter is not handled"); } if (!JS_SetProperty(aContext, aObj, NS_ConvertUTF16toUTF8(aData[i].name()).get(), &v)) { return false; } } return true; }
void BluetoothHfpManager::NotifyDialer(const nsAString& aCommand) { nsString type, name, command; command = aCommand; InfallibleTArray<BluetoothNamedValue> parameters; type.AssignLiteral("bluetooth-dialer-command"); BluetoothValue v(command); parameters.AppendElement(BluetoothNamedValue(type, v)); if (!BroadcastSystemMessage(type, parameters)) { NS_WARNING("Failed to broadcast system message to dialer"); return; } }
bool GMPStorageChild::RecvReadComplete(const nsCString& aRecordName, const GMPErr& aStatus, const InfallibleTArray<uint8_t>& aBytes) { if (mShutdown) { return true; } nsRefPtr<GMPRecordImpl> record = GetRecord(aRecordName); if (!record) { // Not fatal. return true; } record->ReadComplete(aStatus, aBytes.Elements(), aBytes.Length()); return true; }
void ShadowLayerForwarder::SendPendingAsyncMessge() { if (!HasShadowManager() || !mShadowManager->IPCOpen() || mTransactionsToRespond.empty()) { return; } // Send OpReplyDeliverFence messages InfallibleTArray<AsyncChildMessageData> replies; replies.SetCapacity(mTransactionsToRespond.size()); for (size_t i = 0; i < mTransactionsToRespond.size(); i++) { replies.AppendElement(OpReplyDeliverFence(mTransactionsToRespond[i])); } mTransactionsToRespond.clear(); mShadowManager->SendChildAsyncMessages(replies); }
void FilePickerParent::SendFiles(const nsTArray<RefPtr<BlobImpl>>& aBlobs) { nsIContentParent* parent = TabParent::GetFrom(Manager())->Manager(); InfallibleTArray<PBlobParent*> blobs; for (unsigned i = 0; i < aBlobs.Length(); i++) { BlobParent* blobParent = parent->GetOrCreateActorForBlobImpl(aBlobs[i]); if (blobParent) { blobs.AppendElement(blobParent); } } InputFiles inblobs; inblobs.blobsParent().SwapElements(blobs); Unused << Send__delete__(this, inblobs, mResult); }
FileSystemResponseValue GetDirectoryListingTask::GetSuccessRequestResult() const { MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); InfallibleTArray<PBlobParent*> blobs; for (unsigned i = 0; i < mTargetBlobImpls.Length(); i++) { BlobParent* blobParent = GetBlobParent(mTargetBlobImpls[i]); if (blobParent) { blobs.AppendElement(blobParent); } } FileSystemDirectoryListingResponse response; response.blobsParent().SwapElements(blobs); return response; }
void LayerTransactionParent::Destroy() { const ManagedContainer<PLayerParent>& layers = ManagedPLayerParent(); for (auto iter = layers.ConstIter(); !iter.Done(); iter.Next()) { ShadowLayerParent* slp = static_cast<ShadowLayerParent*>(iter.Get()->GetKey()); slp->Destroy(); } InfallibleTArray<PTextureParent*> textures; ManagedPTextureParent(textures); for (unsigned int i = 0; i < textures.Length(); ++i) { RefPtr<TextureHost> tex = TextureHost::AsTextureHost(textures[i]); tex->DeallocateDeviceData(); } mDestroyed = true; }