コード例 #1
0
ファイル: EventSource.cpp プロジェクト: Manishearth/gecko-dev
void
EventSource::FailConnection()
{
  if (mReadyState == CLOSED) {
    return;
  }

  nsresult rv = ConsoleError();
  if (NS_FAILED(rv)) {
    NS_WARNING("Failed to print to the console error");
  }

  // When a user agent is to fail the connection, the user agent must set the
  // readyState attribute to CLOSED and queue a task to fire a simple event
  // named error at the EventSource  object.

  Close(); // it sets mReadyState to CLOSED

  rv = CheckInnerWindowCorrectness();
  if (NS_FAILED(rv)) {
    return;
  }

  RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);

  // it doesn't bubble, and it isn't cancelable
  event->InitEvent(NS_LITERAL_STRING("error"), false, false);
  event->SetTrusted(true);

  rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
  if (NS_FAILED(rv)) {
    NS_WARNING("Failed to dispatch the error event!!!");
    return;
  }
}
コード例 #2
0
ファイル: WebSocket.cpp プロジェクト: LyeSS/mozilla-central
nsresult
WebSocket::ScheduleConnectionCloseEvents(nsISupports* aContext,
                                         nsresult aStatusCode,
                                         bool sync)
{
  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");

  // no-op if some other code has already initiated close event
  if (!mOnCloseScheduled) {
    mCloseEventWasClean = NS_SUCCEEDED(aStatusCode);

    if (aStatusCode == NS_BASE_STREAM_CLOSED) {
      // don't generate an error event just because of an unclean close
      aStatusCode = NS_OK;
    }

    if (NS_FAILED(aStatusCode)) {
      ConsoleError();
      mFailed = true;
    }

    mOnCloseScheduled = true;

    if (sync) {
      DispatchConnectionCloseEvents();
    } else {
      NS_DispatchToMainThread(new CallDispatchConnectionCloseEvents(this),
                              NS_DISPATCH_NORMAL);
    }
  }

  return NS_OK;
}
コード例 #3
0
ファイル: WebSocket.cpp プロジェクト: aeddi/gecko-dev
void
WebSocket::FailConnection(uint16_t aReasonCode,
                          const nsACString& aReasonString)
{
  NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");

  ConsoleError();
  mFailed = true;
  CloseConnection(aReasonCode, aReasonString);
}
コード例 #4
0
ファイル: enma_config.c プロジェクト: mrmt/enma
/**
 * EnmaConfig オブジェクトの構築
 *
 * @return 各設定情報を記憶した EnmaConfig オブジェクト
 */
EnmaConfig *
EnmaConfig_new(void)
{
    EnmaConfig *self = (EnmaConfig *) malloc(sizeof(EnmaConfig));
    if (NULL == self) {
        ConsoleError("memory allocation failed: error=%s", strerror(errno));
        return NULL;
    }
    // 初期化するのみ
    ConfigLoader_init(ConfigEntry_table, self);

    return self;
}