Example #1
0
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__);
}
Example #2
0
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;
}
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!");
  }
}
Example #4
0
static void
Array123(InfallibleTArray<JSONVariant>& a123)
{
    a123.AppendElement(1);  a123.AppendElement(2);  a123.AppendElement(3);

    test_assert(a123 == a123, "operator== is broken");
}
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;
}
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);
  }
}
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;
}
Example #8
0
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__);
}
Example #9
0
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
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);
}
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;
}
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;
}
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();
}
void
ImageBridgeParent::ReplyRemoveTexture(const OpReplyRemoveTexture& aReply)
{
  InfallibleTArray<AsyncParentMessageData> messages;
  messages.AppendElement(aReply);
  mozilla::unused << SendParentAsyncMessages(messages);
}
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));
}
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));
}
static void
DeviceFoundCallback(int aNumProperties, bt_property_t *aProperties)
{
  MOZ_ASSERT(!NS_IsMainThread());

  BluetoothValue propertyValue;
  InfallibleTArray<BluetoothNamedValue> propertiesArray;

  for (int i = 0; i < aNumProperties; i++) {
    bt_property_t p = aProperties[i];

    if (p.type == BT_PROPERTY_BDADDR) {
      nsString remoteDeviceBdAddress;
      BdAddressTypeToString((bt_bdaddr_t*)p.val, remoteDeviceBdAddress);
      propertyValue = remoteDeviceBdAddress;
      propertiesArray.AppendElement(
          BluetoothNamedValue(NS_LITERAL_STRING("Address"), propertyValue));
    } else if (p.type == BT_PROPERTY_BDNAME) {
      propertyValue = NS_ConvertUTF8toUTF16((char*)p.val);
      propertiesArray.AppendElement(
        BluetoothNamedValue(NS_LITERAL_STRING("Name"), propertyValue));
    } else if (p.type == BT_PROPERTY_CLASS_OF_DEVICE) {
      uint32_t cod = *(uint32_t*)p.val;
      propertyValue = cod;
      propertiesArray.AppendElement(
        BluetoothNamedValue(NS_LITERAL_STRING("Class"), propertyValue));
      nsString icon;
      ClassToIcon(cod, icon);
      propertyValue = icon;
      propertiesArray.AppendElement(
        BluetoothNamedValue(NS_LITERAL_STRING("Icon"), propertyValue));
    } else {
      BT_LOGD("Not handled remote device property: %d", p.type);
    }
  }

  BluetoothValue value = propertiesArray;
  BluetoothSignal signal(NS_LITERAL_STRING("DeviceFound"),
                         NS_LITERAL_STRING(KEY_ADAPTER), value);
  nsRefPtr<DistributeBluetoothSignalTask>
    t = new DistributeBluetoothSignalTask(signal);
  if (NS_FAILED(NS_DispatchToMainThread(t))) {
    BT_WARNING("Failed to dispatch to main thread!");
  }
}
void
AppendNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
                 const char* aName, const BluetoothValue& aValue)
{
  nsString name;
  name.AssignASCII(aName);

  aArray.AppendElement(BluetoothNamedValue(name, aValue));
}
Example #19
0
void
TabChild::ParamsToArrays(nsIDialogParamBlock* aParams,
                         InfallibleTArray<int>& aIntParams,
                         InfallibleTArray<nsString>& aStringParams)
{
  if (aParams) {
    for (PRInt32 i = 0; i < 8; ++i) {
      PRInt32 val = 0;
      aParams->GetInt(i, &val);
      aIntParams.AppendElement(val);
    }
    PRInt32 j = 0;
    nsXPIDLString strVal;
    while (NS_SUCCEEDED(aParams->GetString(j, getter_Copies(strVal)))) {
      aStringParams.AppendElement(strVal);
      ++j;
    }
  }
}
Example #20
0
void
DispatchStatusChangedEvent(const nsAString& aType,
                           const nsAString& aAddress,
                           bool aStatus)
{
  MOZ_ASSERT(NS_IsMainThread());

  InfallibleTArray<BluetoothNamedValue> data;
  data.AppendElement(
    BluetoothNamedValue(NS_LITERAL_STRING("address"), nsString(aAddress)));
  data.AppendElement(
    BluetoothNamedValue(NS_LITERAL_STRING("status"), aStatus));

  BluetoothSignal signal(nsString(aType), NS_LITERAL_STRING(KEY_ADAPTER), data);

  BluetoothService* bs = BluetoothService::Get();
  NS_ENSURE_TRUE_VOID(bs);
  bs->DistributeSignal(signal);
}
Example #21
0
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;
}
Example #22
0
bool TestDataStructuresParent::RecvTest15(
            const WithStructs& i1,
            const WithStructs& i2,
            const WithStructs& i3,
            const WithStructs& i4,
            const WithStructs& i5,
            WithStructs* o1,
            WithStructs* o2,
            WithStructs* o3,
            WithStructs* o4,
            WithStructs* o5)
{
    InfallibleTArray<int> ai;
    ai.AppendElement(1);  ai.AppendElement(2);  ai.AppendElement(3);

    test_assert(i1 == int(42), "wrong value");
    assert_arrays_equal(i2.get_ArrayOfint(), ai);
    assert_arrays_equal(i3.get_ArrayOfPTestDataStructuresSubParent(), mKids);

    const SActors& ia = i4.get_ArrayOfSActors()[0];
    test_assert(42 == ia.i(), "wrong value");
    assert_arrays_equal(ai, ia.ai());
    assert_arrays_equal(mKids, ia.apParent());

    const Structs& is = i5.get_ArrayOfStructs()[0];
    test_assert(42 == is.i(), "wrong value");
    assert_arrays_equal(ai, is.ai());
    assert_arrays_equal(mKids, is.apParent());   

    const SActors& isa = is.aa()[0];
    test_assert(42 == isa.i(), "wrong value");
    assert_arrays_equal(ai, isa.ai());
    assert_arrays_equal(mKids, isa.apParent());

    *o1 = i1;
    *o2 = i2;
    *o3 = i3;
    *o4 = i4;
    *o5 = i5;

    return true;
}
void
BluetoothHidManager::NotifyStatusChanged()
{
  MOZ_ASSERT(NS_IsMainThread());

  NS_NAMED_LITERAL_STRING(type, BLUETOOTH_HID_STATUS_CHANGED_ID);
  InfallibleTArray<BluetoothNamedValue> parameters;

  BluetoothValue v = mConnected;
  parameters.AppendElement(
    BluetoothNamedValue(NS_LITERAL_STRING("connected"), v));

  v = mDeviceAddress;
  parameters.AppendElement(
    BluetoothNamedValue(NS_LITERAL_STRING("address"), v));

  if (!BroadcastSystemMessage(type, parameters)) {
    BT_WARNING("Failed to broadcast system message to settings");
    return;
  }
}
Example #24
0
void
TestDataStructuresChild::Test13()
{
    InfallibleTArray<int> ai;
    ai.AppendElement(1);  ai.AppendElement(2);  ai.AppendElement(3);

    SActors i;
    i.i() = 42;
    i.ai() = ai;
    i.apChild() = mKids;

    SActors o;
    if (!SendTest13(i, &o))
        fail("can't send Test13");

    test_assert(42 == o.i(), "wrong value");
    assert_arrays_equal(ai, o.ai());
    assert_arrays_equal(mKids, o.apChild());

    printf("  passed %s\n", __FUNCTION__);
}
Example #25
0
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);
}
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);
}
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);
}
Example #29
0
bool TestDataStructuresParent::RecvTest12(
            const SIntDoubleArrays& i,
            SIntDoubleArrays* o)
{
    InfallibleTArray<int> ai;
    ai.AppendElement(1);
    ai.AppendElement(2);
    ai.AppendElement(3);

    InfallibleTArray<double> ad;
    ad.AppendElement(.5);
    ad.AppendElement(1.0);
    ad.AppendElement(2.0);

    test_assert(42 == i.i(), "wrong value");
    assert_arrays_equal(ai, i.ai());
    assert_arrays_equal(ad, i.ad());

    *o = i;

    return true;
}
void
SubstitutingProtocolHandler::CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aMappings)
{
  for (auto iter = mSubstitutions.ConstIter(); !iter.Done(); iter.Next()) {
    nsCOMPtr<nsIURI> uri = iter.Data();
    SerializedURI serialized;
    if (uri) {
      uri->GetSpec(serialized.spec);
      uri->GetOriginCharset(serialized.charset);
    }
    SubstitutionMapping substitution = { mScheme, nsCString(iter.Key()), serialized };
    aMappings.AppendElement(substitution);
  }
}