NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen2(nsIStreamListener *aListener)
{
  nsCOMPtr<nsIStreamListener> listener = aListener;
  nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener);
  NS_ENSURE_SUCCESS(rv, rv);
  return AsyncOpen(listener, nullptr);
}
NS_IMETHODIMP nsExtProtocolChannel::CompleteRedirectSetup(nsIStreamListener *listener,
                                                          nsISupports *context)
{
  // For redirects to external protocols we AsyncOpen on the child
  // (not the parent) because child channel has the right docshell
  // (which is needed for the select dialog).
  return AsyncOpen(listener, context);
}
NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen2(nsIStreamListener *aListener)
{
  nsCOMPtr<nsIStreamListener> listener = aListener;
  nsresult rv = nsContentSecurityManager::doContentSecurityCheck(this, listener);
  if (NS_FAILED(rv)) {
    mCallbacks = nullptr;
    return rv;
  }
  return AsyncOpen(listener, nullptr);
}
NS_IMETHODIMP
nsViewSourceChannel::AsyncOpen2(nsIStreamListener *aListener)
{
  nsCOMPtr<nsILoadInfo> loadInfo = mChannel->GetLoadInfo();
  if(!loadInfo) {
    MOZ_ASSERT(loadInfo, "can not enforce security without loadInfo");
    return NS_ERROR_UNEXPECTED;
  }
  // setting the flag on the loadInfo indicates that the underlying
  // channel will be openend using AsyncOpen2() and hence performs
  // the necessary security checks.
  loadInfo->SetEnforceSecurity(true);
  return AsyncOpen(aListener, nullptr);
}
    return E_SUCCESS;
}

DWORD WINAPI UART_Listener(LPVOID Param_p)
{
    HANDLE Comm_h;
    char COM[10];
    FILE *cfPtr;
    uint8 *ReceiveData_p = NULL;
    uint8 *TransmitData_p = NULL;
    UART_Handles_t *UART_p = NULL;
    uint32 i = 0;

    if ((cfPtr = fopen("com_port_settings.txt", "rb+")) == NULL) {
        A_(printf("emul_threads.c(%d) Missing comport settings file!\n", __LINE__);)
        Comm_h = AsyncOpen("COM1");
    } else {
        memset(COM, 0x00, 10);

        while (!feof(cfPtr)) {
            fread(&COM, 5, 1, cfPtr);
        }

        Comm_h = AsyncOpen(COM);
    }

    ReceiveData_p = malloc(MAX_SIZE_OF_RECEIVE_BUFFER);
    assert(NULL != ReceiveData_p);
    TransmitData_p = malloc(MAX_SIZE_OF_TRANSMIT_BUFFER);
    assert(NULL != TransmitData_p);