Example #1
0
void
IDBIndex::GetKeyPath(JSContext* aCx,
                     JS::MutableHandle<JS::Value> aResult,
                     ErrorResult& aRv)
{
  AssertIsOnOwningThread();

  if (!mCachedKeyPath.isUndefined()) {
    MOZ_ASSERT(mRooted);
    JS::ExposeValueToActiveJS(mCachedKeyPath);
    aResult.set(mCachedKeyPath);
    return;
  }

  MOZ_ASSERT(!mRooted);

  aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  if (mCachedKeyPath.isGCThing()) {
    mozilla::HoldJSObjects(this);
    mRooted = true;
  }

  JS::ExposeValueToActiveJS(mCachedKeyPath);
  aResult.set(mCachedKeyPath);
}
Example #2
0
BOOL CAPNSClient::ConnectFeedback()
{
    BOOL bRet = FALSE;
    m_pFeedbackClient->DoConnect.connect(&m_feedbackhandler, &CAPNSFeedBackHandler::OnConnect);
    m_pFeedbackClient->DoClose.connect(&m_feedbackhandler, &CAPNSFeedBackHandler::OnClose);
    m_pFeedbackClient->DoException.connect(&m_feedbackhandler, &CAPNSFeedBackHandler::OnException);
    m_pFeedbackClient->DoRecv.connect((CBaseHandler*)&m_feedbackhandler, &CAPNSFeedBackHandler::OnRecv);
    m_pFeedbackClient->DoSSLConnect.connect(&m_feedbackhandler, &CAPNSFeedBackHandler::OnSSLConnect);
    
    if (m_pFeedbackClient->InitSSL(GetCertPath().c_str(), GetKeyPath().c_str(), GetKeyPassword().c_str()) == FALSE)
    {
        PUSH_SERVER_ERROR("feedback client init ssl failed.");
        return bRet;
    }
    
    if (_GetAPNSServerAddress())
    {
        m_pFeedbackClient->ConnectAsync(GetFeedbackIP().c_str(), GetFeedbackPort());
        bRet = TRUE;
    }
    return bRet;
}