// -----------------------------------------------------------------------------
// TSIPSecDigestCtxSetup::RequestUserCredentialsL
// -----------------------------------------------------------------------------
//
TBool TSIPSecDigestCtxSetup::RequestUserCredentialsL()
	{
    TSIPSecPluginCtxResponse& parent =
    	static_cast<TSIPSecPluginCtxResponse&>( Parent() );
    CSIPSecDigestObserver* observer =
    	parent.Cache().RegisterObserverL( parent.Observer(), UserData() );
	return UserData().RequestL( *this, *observer );
    }
Beispiel #2
0
void WebConnection::postMessage(const String& messageName, API::Object* messageBody)
{
    if (!hasValidConnection())
        return;

    send(Messages::WebConnection::HandleMessage(messageName, UserData(transformObjectsToHandles(messageBody))));
}
Beispiel #3
0
void Simulation::generateStaticPinField(){
	for(int i=0;i<this->pinBodies.size();i++){
		if(pinBodies[i]){
			world.DestroyBody(pinBodies[i]);
		}
	}

	std::vector<b2Vec2> pins(PIN_COUNT);
	this->pinBodies	= std::vector<b2Body*>(PIN_COUNT);
	this->pinData	= std::vector<UserData>(PIN_COUNT);

	b2BodyDef									pinDef;
	pinDef.type									= b2_staticBody;

	b2CircleShape								pinSphere;
	pinSphere.m_p.Set(0.0f, 0.0f);
	pinSphere.m_radius							= PIN_RADIUS;

	b2FixtureDef								pinFixtureDef;
	pinFixtureDef.shape							= &pinSphere;
	pinFixtureDef.density						= PIN_DENSITY;
	pinFixtureDef.friction						= PIN_FRICTION;
	pinFixtureDef.restitution					= PIN_RESTITUTION;

	for(int i=0;i<staticPlayingField.size();i++){
		pinDef.position.Set(staticPlayingField[i].x, staticPlayingField[i].y);
		this->pinBodies[i] = world.CreateBody(&pinDef);
		this->pinData[i]	= UserData(UserData::PINBALL_PIN, 1.0f, true, 0, 0, 0);
		this->pinBodies[i]->SetUserData(&this->pinData[i]);
		this->pinBodies[i]->CreateFixture(&pinFixtureDef);
	}
}
Beispiel #4
0
void DataKeeper::DoSaveUsers()
{
	ModesExts currdata;

	const user_hash& users = ServerInstance->Users.GetUsers();
	for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i)
	{
		User* const user = i->second;

		// Serialize user modes
		for (size_t j = 0; j < handledmodes[MODETYPE_USER].size(); j++)
		{
			ModeHandler* mh = handledmodes[MODETYPE_USER][j].mh;
			if (user->IsModeSet(mh))
				currdata.modelist.push_back(InstanceData(j, mh->GetUserParameter(user)));
		}

		// Serialize all extensions attached to the User
		SaveExtensions(user, currdata.extlist);

		// Save serializer name if applicable and get an index to it
		size_t serializerindex = SaveSerializer(user);

		// Add to list if the user has any modes or extensions set that we are interested in, otherwise we don't
		// have to do anything with this user when restoring
		if ((!currdata.empty()) || (serializerindex != UserData::UNUSED_INDEX))
		{
			userdatalist.push_back(UserData(user, serializerindex));
			userdatalist.back().swap(currdata);
		}
	}
}
Beispiel #5
0
 GMPErr GetRecordNames(nsTArray<nsCString>& aOutRecordNames) const override
 {
     for (auto iter = mRecords.ConstIter(); !iter.Done(); iter.Next()) {
         aOutRecordNames.AppendElement(iter.UserData()->mRecordName);
     }
     return GMPNoErr;
 }
void
HTMLPropertiesCollection::EnsureFresh()
{
  if (mDoc && !mIsDirty) {
    return;
  }
  mIsDirty = false;

  mProperties.Clear();
  mNames->Clear();
  // We don't clear NamedItemEntries because the PropertyNodeLists must be live.
  for (auto iter = mNamedItemEntries.Iter(); !iter.Done(); iter.Next()) {
    iter.UserData()->SetDirty();
  }
  if (!mRoot->HasAttr(kNameSpaceID_None, nsGkAtoms::itemscope)) {
    return;
  }

  CrawlProperties();
  TreeOrderComparator comparator;
  mProperties.Sort(comparator);

  // Create the names DOMStringList
  uint32_t count = mProperties.Length();
  for (uint32_t i = 0; i < count; ++i) {
    const nsAttrValue* attr = mProperties.ElementAt(i)->GetParsedAttr(nsGkAtoms::itemprop); 
    for (uint32_t i = 0; i < attr->GetAtomCount(); i++) {
      nsDependentAtomString propName(attr->AtomAt(i));
      bool contains = mNames->ContainsInternal(propName);
      if (!contains) {
        mNames->Add(propName);
      }
    }
  }
}
Beispiel #7
0
void WebProcessPool::postMessageToInjectedBundle(const String& messageName, API::Object* messageBody)
{
    for (auto& process : m_processes) {
        // FIXME: Return early if the message body contains any references to WKPageRefs/WKFrameRefs etc. since they're local to a process.
        process->send(Messages::WebProcess::HandleInjectedBundleMessage(messageName, UserData(process->transformObjectsToHandles(messageBody).get())), 0);
    }
}
Beispiel #8
0
void
VRManager::GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo)
{
  aControllerInfo.Clear();
  for (auto iter = mVRControllers.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRControllerHost* controller = iter.UserData();
    aControllerInfo.AppendElement(VRControllerInfo(controller->GetControllerInfo()));
  }
}
Beispiel #9
0
/**
 * Get any VR displays that have already been enumerated without
 * activating any new devices.
 */
void
VRManager::GetVRDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayInfo)
{
  aDisplayInfo.Clear();
  for (auto iter = mVRDisplays.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRDisplayHost* display = iter.UserData();
    aDisplayInfo.AppendElement(VRDisplayInfo(display->GetDisplayInfo()));
  }
}
Beispiel #10
0
void
VRManager::NotifyVsync(const TimeStamp& aVsyncTimestamp)
{
  for (auto iter = mVRDevices.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRHMDInfo* device = iter.UserData();
    device->NotifyVsync(aVsyncTimestamp);
  }
  DispatchVRDeviceSensorUpdate();
}
Beispiel #11
0
void Simulation::generateRandomPinField(){
	std::default_random_engine generator(std::chrono::system_clock::now().time_since_epoch().count());
	std::uniform_real_distribution<float> distribution_X = std::uniform_real_distribution<float>(PIN_BOUNDARY_X_MIN, PIN_BOUNDARY_X_MAX);
	std::uniform_real_distribution<float> distribution_Y = std::uniform_real_distribution<float>(PIN_BOUNDARY_Y_MIN, PIN_BOUNDARY_Y_MAX);

	int pins_generated = 0;
	b2Vec2 v;
	bool add;

	for(int i=0;i<this->pinBodies.size();i++){
		if(pinBodies[i]){
			world.DestroyBody(pinBodies[i]);
		}
	}

	std::vector<b2Vec2> pins(PIN_COUNT);
	this->pinBodies	= std::vector<b2Body*>(PIN_COUNT);
	this->pinData	= std::vector<UserData>(PIN_COUNT);

	b2BodyDef									pinDef;
	pinDef.type									= b2_staticBody;

	b2CircleShape								pinSphere;
	pinSphere.m_p.Set(0.0f, 0.0f);
	pinSphere.m_radius							= PIN_RADIUS;

	b2FixtureDef								pinFixtureDef;
	pinFixtureDef.shape							= &pinSphere;
	pinFixtureDef.density						= PIN_DENSITY;
	pinFixtureDef.friction						= PIN_FRICTION;
	pinFixtureDef.restitution					= PIN_RESTITUTION;

	while(pins_generated < PIN_COUNT){

		v		= b2Vec2(distribution_X(generator), distribution_Y(generator));
		add		= true;

		for(int i=0;i<pins_generated;i++){
			if((pins[i] - v).Length() <= 6 * PIN_RADIUS){
				add = false;
				break;
			}
		}

		if(add){
			//if it's the last one and is still valid add it
			pinDef.position.Set(v.x, v.y);
			this->pinBodies[pins_generated] = world.CreateBody(&pinDef);
			this->pinData[pins_generated]	= UserData(UserData::PINBALL_PIN, 1.0f, true, 0, 0, 0);
			this->pinBodies[pins_generated]->SetUserData(&this->pinData[pins_generated]);
			this->pinBodies[pins_generated]->CreateFixture(&pinFixtureDef);
			pins_generated++;
		}

	}
}
Beispiel #12
0
void WebChromeClient::didCancelTrackingPotentialLongMousePress()
{
    RefPtr<API::Object> userData;

    // Notify the bundle client.
    m_page->injectedBundleUIClient().didCancelTrackingPotentialLongMousePress(m_page, userData);

    // Notify the UIProcess.
    m_page->send(Messages::WebPageProxy::DidCancelTrackingPotentialLongMousePress(UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
}
Beispiel #13
0
 ~GMPDiskStorage() {
     // Close all open file handles.
     for (auto iter = mRecords.ConstIter(); !iter.Done(); iter.Next()) {
         Record* record = iter.UserData();
         if (record->mFileDesc) {
             PR_Close(record->mFileDesc);
             record->mFileDesc = nullptr;
         }
     }
 }
Beispiel #14
0
void WebProcessPool::handleSynchronousMessage(IPC::Connection& connection, const String& messageName, const UserData& messageBody, UserData& returnUserData)
{
    auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
    if (!webProcessProxy)
        return;

    RefPtr<API::Object> returnData;
    m_injectedBundleClient.didReceiveSynchronousMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get(), returnData);
    returnUserData = UserData(webProcessProxy->transformObjectsToHandles(returnData.get()));
}
Beispiel #15
0
void WebChromeClient::handleAutoFillButtonClick(HTMLInputElement& inputElement)
{
    RefPtr<API::Object> userData;

    // Notify the bundle client.
    auto nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement);
    m_page->injectedBundleUIClient().didClickAutoFillButton(*m_page, nodeHandle.get(), userData);

    // Notify the UIProcess.
    m_page->send(Messages::WebPageProxy::HandleAutoFillButtonClick(UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
}
Beispiel #16
0
void LoginWindow::login(){
    try{
        lError->setHidden(true);
        (new ClientWindow(new LinQedInClient(UserData(teUsername->text(),tePwd->text()))))->showMaximized();
        close();
    }//try
    catch(const NoUserException& exc){
        lError->setHidden(false);
        lError->setText(exc.what());
    }//catch
}//login
Beispiel #17
0
void
MediaEngineWebRTC::Shutdown()
{
  // This is likely paranoia
  MutexAutoLock lock(mMutex);

  if (camera::GetCamerasChildIfExists()) {
    camera::GetChildAndCall(
      &camera::CamerasChild::RemoveDeviceChangeCallback, this);
  }

  LOG(("%s", __FUNCTION__));
  // Shutdown all the sources, since we may have dangling references to the
  // sources in nsDOMUserMediaStreams waiting for GC/CC
  for (auto iter = mVideoSources.Iter(); !iter.Done(); iter.Next()) {
    MediaEngineVideoSource* source = iter.UserData();
    if (source) {
      source->Shutdown();
    }
  }
  for (auto iter = mAudioSources.Iter(); !iter.Done(); iter.Next()) {
    MediaEngineAudioSource* source = iter.UserData();
    if (source) {
      source->Shutdown();
    }
  }
  mVideoSources.Clear();
  mAudioSources.Clear();

  if (mVoiceEngine) {
    mVoiceEngine->SetTraceCallback(nullptr);
    webrtc::VoiceEngine::Delete(mVoiceEngine);
  }

  mVoiceEngine = nullptr;

  mozilla::camera::Shutdown();
  AudioInputCubeb::CleanupGlobalData();
}
Beispiel #18
0
void
VRManager::DispatchVRDeviceInfoUpdate()
{
  nsTArray<VRDeviceUpdate> update;
  for (auto iter = mVRDevices.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRHMDInfo* device = iter.UserData();
    update.AppendElement(VRDeviceUpdate(device->GetDeviceInfo(),
                                        device->GetSensorState()));
  }

  for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
    Unused << iter.Get()->GetKey()->SendUpdateDeviceInfo(update);
  }
}
NS_IMETHODIMP
nsMsgGroupView::CopyDBView(nsMsgDBView *aNewMsgDBView, nsIMessenger *aMessengerInstance, 
                                       nsIMsgWindow *aMsgWindow, nsIMsgDBViewCommandUpdater *aCmdUpdater)
{
  nsMsgDBView::CopyDBView(aNewMsgDBView, aMessengerInstance, aMsgWindow, aCmdUpdater);
  nsMsgGroupView* newMsgDBView = (nsMsgGroupView *) aNewMsgDBView;

  // If grouped, we need to clone the group thread hash table.
  if (m_viewFlags & nsMsgViewFlagsType::kGroupBySort) {
    for (auto iter = m_groupsTable.Iter(); !iter.Done(); iter.Next()) {
      newMsgDBView->m_groupsTable.Put(iter.Key(), iter.UserData());
    }
  }
  return NS_OK;
}
already_AddRefed<mozIStorageError>
AsyncBindingParams::bind(sqlite3_stmt * aStatement)
{
  // We should bind by index using the super-class if there is nothing in our
  // hashtable.
  if (!mNamedParameters.Count())
    return BindingParams::bind(aStatement);

  nsCOMPtr<mozIStorageError> err;

  for (auto iter = mNamedParameters.Iter(); !iter.Done(); iter.Next()) {
    const nsACString &key = iter.Key();

    // We do not accept any forms of names other than ":name", but we need to
    // add the colon for SQLite.
    nsAutoCString name(":");
    name.Append(key);
    int oneIdx = ::sqlite3_bind_parameter_index(aStatement, name.get());

    if (oneIdx == 0) {
      nsAutoCString errMsg(key);
      errMsg.AppendLiteral(" is not a valid named parameter.");
      err = new Error(SQLITE_RANGE, errMsg.get());
      break;
    }

    // XPCVariant's AddRef and Release are not thread-safe and so we must not
    // do anything that would invoke them here on the async thread.  As such we
    // can't cram aValue into mParameters using ReplaceObjectAt so that
    // we can freeload off of the BindingParams::Bind implementation.
    int rc = variantToSQLiteT(BindingColumnData(aStatement, oneIdx - 1),
                              iter.UserData());
    if (rc != SQLITE_OK) {
      // We had an error while trying to bind.  Now we need to create an error
      // object with the right message.  Note that we special case
      // SQLITE_MISMATCH, but otherwise get the message from SQLite.
      const char *msg = "Could not covert nsIVariant to SQLite type.";
      if (rc != SQLITE_MISMATCH) {
        msg = ::sqlite3_errmsg(::sqlite3_db_handle(aStatement));
      }
      err = new Error(rc, msg);
      break;
    }
  }

  return err.forget();
}
Beispiel #21
0
void
VRManager::DispatchVRDeviceSensorUpdate()
{
  nsTArray<VRSensorUpdate> update;

  for (auto iter = mVRDevices.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRHMDInfo* device = iter.UserData();
    if (!device->GetDeviceInfo().GetUseMainThreadOrientation()) {
      update.AppendElement(VRSensorUpdate(device->GetDeviceInfo().GetDeviceID(),
                                          device->GetSensorState()));
    }
  }
  if (update.Length() > 0) {
    for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
      Unused << iter.Get()->GetKey()->SendUpdateDeviceSensors(update);
    }
  }
}
Beispiel #22
0
CBomb::CBomb(Ogre::SceneNode *pParentNode, CObjectManager &objectManager, const Ogre::Vector3 &vPosition)
: CLiftableObject(pParentNode, objectManager, NULL, LOT_BOMB, false, UserData()), m_pListener(NULL) {
    m_pSceneNode = pParentNode->createChildSceneNode();
    m_pSceneNode->attachObject(pParentNode->getCreator()->createEntity(BOMB_MESH));
    m_pSceneNode->setScale(Ogre::Vector3::UNIT_SCALE * CPerson::PERSON_SCALE);
    m_fTimer = BOMB_TIMER;

    btCollisionShape *pShape = new btSphereShape(BOMB_COL_RADIUS);
    btRigidBody::btRigidBodyConstructionInfo ci(BOMB_MASS, new BtOgre::RigidBodyState(m_pSceneNode), pShape);
    btRigidBody *pRB = new btRigidBody(ci);

    objectManager.getMap().getPhysicsManager()->getWorld()->addRigidBody(pRB, COL_INTERACTIVE, MASK_STATIC_COLLIDES_WITH | COL_STATIC);
    m_pCollisionObject = pRB;

    setAsUserPointer(m_pCollisionObject);

    pRB->getWorldTransform().setOrigin(BtOgre::Convert::toBullet(vPosition + Ogre::Vector3::UNIT_Y * BOMB_COL_RADIUS));
}
NS_IMETHODIMP
nsFontFaceList::Item(uint32_t index, nsIDOMFontFace **_retval)
{
  NS_ENSURE_TRUE(index < mFontFaces.Count(), NS_ERROR_INVALID_ARG);

  uint32_t current = 0;
  nsIDOMFontFace* result = nullptr;
  for (auto iter = mFontFaces.Iter(); !iter.Done(); iter.Next()) {
    if (current == index) {
      result = iter.UserData();
      break;
    }
    current++;
  }
  NS_ASSERTION(result != nullptr, "null entry in nsFontFaceList?");
  NS_IF_ADDREF(*_retval = result);
  return NS_OK;
}
Beispiel #24
0
void
VRManager::NotifyVsync(const TimeStamp& aVsyncTimestamp)
{
  const double kVRDisplayRefreshMaxDuration = 5000; // milliseconds

  bool bHaveEventListener = false;

  for (auto iter = mVRManagerParents.Iter(); !iter.Done(); iter.Next()) {
    VRManagerParent *vmp = iter.Get()->GetKey();
    if (mVRDisplays.Count()) {
      Unused << vmp->SendNotifyVSync();
    }
    bHaveEventListener |= vmp->HaveEventListener();
  }

  for (auto iter = mVRDisplays.Iter(); !iter.Done(); iter.Next()) {
    gfx::VRDisplayHost* display = iter.UserData();
    display->NotifyVSync();
  }

  if (bHaveEventListener) {
    // If content has set an EventHandler to be notified of VR display events
    // we must continually refresh the VR display enumeration to check
    // for events that we must fire such as Window.onvrdisplayconnect
    // Note that enumeration itself may activate display hardware, such
    // as Oculus, so we only do this when we know we are displaying content
    // that is looking for VR displays.
    if (mLastRefreshTime.IsNull()) {
      // This is the first vsync, must refresh VR displays
      RefreshVRDisplays();
      RefreshVRControllers();
      mLastRefreshTime = TimeStamp::Now();
    } else {
      // We don't have to do this every frame, so check if we
      // have refreshed recently.
      TimeDuration duration = TimeStamp::Now() - mLastRefreshTime;
      if (duration.ToMilliseconds() > kVRDisplayRefreshMaxDuration) {
        RefreshVRDisplays();
        RefreshVRControllers();
        mLastRefreshTime = TimeStamp::Now();
      }
    }
  }
}
Beispiel #25
0
NS_IMETHODIMP
nsGTKRemoteService::Startup(const char* aAppName, const char* aProfileName)
{
  NS_ASSERTION(aAppName, "Don't pass a null appname!");
  sRemoteImplementation = this;

  if (mServerWindow) return NS_ERROR_ALREADY_INITIALIZED;

  XRemoteBaseStartup(aAppName, aProfileName);

  mServerWindow = gtk_invisible_new();
  gtk_widget_realize(mServerWindow);
  HandleCommandsFor(mServerWindow, nullptr);

  for (auto iter = mWindows.Iter(); !iter.Done(); iter.Next()) {
    HandleCommandsFor(iter.Key(), iter.UserData());
  }

  return NS_OK;
}
bool
DOMStorageDBThread::PendingOperations::IsOriginUpdatePending(const nsACString& aOriginSuffix,
                                                             const nsACString& aOriginNoSuffix) const
{
  // Called under the lock

  for (auto iter = mUpdates.ConstIter(); !iter.Done(); iter.Next()) {
    if (FindPendingUpdateForOrigin(aOriginSuffix, aOriginNoSuffix, iter.UserData())) {
      return true;
    }
  }

  for (uint32_t i = 0; i < mExecList.Length(); ++i) {
    if (FindPendingUpdateForOrigin(aOriginSuffix, aOriginNoSuffix, mExecList[i])) {
      return true;
    }
  }

  return false;
}
void
WebRenderBridgeParent::SampleAnimations(nsTArray<wr::WrOpacityProperty>& aOpacityArray,
                                        nsTArray<wr::WrTransformProperty>& aTransformArray)
{
  AdvanceAnimations();

  // return the animated data if has
  if (mAnimStorage->AnimatedValueCount()) {
    for(auto iter = mAnimStorage->ConstAnimatedValueTableIter();
        !iter.Done(); iter.Next()) {
      AnimatedValue * value = iter.UserData();
      if (value->mType == AnimatedValue::TRANSFORM) {
        aTransformArray.AppendElement(
          wr::ToWrTransformProperty(iter.Key(), value->mTransform.mTransformInDevSpace));
      } else if (value->mType == AnimatedValue::OPACITY) {
        aOpacityArray.AppendElement(
          wr::ToWrOpacityProperty(iter.Key(), value->mOpacity));
      }
    }
  }
}
Beispiel #28
0
void
DOMStorageCache::CloneFrom(const DOMStorageCache* aThat)
{
  // This will never be called on anything else than SessionStorage.
  // This means mData will never be touched on any other thread than
  // the main thread and it never went through the loading process.
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mPersistent);
  MOZ_ASSERT(!(bool)aThat->mLoaded);

  mLoaded = false;
  mInitialized = aThat->mInitialized;
  mPersistent = false;
  mSessionOnlyDataSetActive = aThat->mSessionOnlyDataSetActive;

  for (uint32_t i = 0; i < kDataSetCount; ++i) {
    for (auto it = aThat->mData[i].mKeys.ConstIter(); !it.Done(); it.Next()) {
      mData[i].mKeys.Put(it.Key(), it.UserData());
    }
    ProcessUsageDelta(i, aThat->mData[i].mOriginQuotaUsage);
  }
}
Beispiel #29
0
void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
{
    RefPtr<API::Object> userData;

    // Notify the bundle client.
    m_page->injectedBundleUIClient().mouseDidMoveOverElement(m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);

    // Notify the UIProcess.
    WebHitTestResultData webHitTestResultData(hitTestResult);
    m_page->send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
}
Beispiel #30
0
nsresult
nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags,
                        bool openNewChannel)
{
  SUSPEND_PUMP_FOR_SCOPE();

  // Transfer properties

  newChannel->SetLoadGroup(mLoadGroup);
  newChannel->SetNotificationCallbacks(mCallbacks);
  newChannel->SetLoadFlags(mLoadFlags | LOAD_REPLACE);

  // make a copy of the loadinfo, append to the redirectchain
  // and set it on the new channel
  if (mLoadInfo) {
    nsCOMPtr<nsILoadInfo> newLoadInfo =
      static_cast<mozilla::LoadInfo*>(mLoadInfo.get())->Clone();

    nsCOMPtr<nsIPrincipal> uriPrincipal;
    nsIScriptSecurityManager *sm = nsContentUtils::GetSecurityManager();
    sm->GetChannelURIPrincipal(this, getter_AddRefs(uriPrincipal));
    bool isInternalRedirect =
      (redirectFlags & (nsIChannelEventSink::REDIRECT_INTERNAL |
                        nsIChannelEventSink::REDIRECT_STS_UPGRADE));
    newLoadInfo->AppendRedirectedPrincipal(uriPrincipal, isInternalRedirect);
    newChannel->SetLoadInfo(newLoadInfo);
  }
  else {
    // the newChannel was created with a dummy loadInfo, we should clear
    // it in case the original channel does not have a loadInfo
    newChannel->SetLoadInfo(nullptr);
  }

  // Preserve the privacy bit if it has been overridden
  if (mPrivateBrowsingOverriden) {
    nsCOMPtr<nsIPrivateBrowsingChannel> newPBChannel =
      do_QueryInterface(newChannel);
    if (newPBChannel) {
      newPBChannel->SetPrivate(mPrivateBrowsing);
    }
  }

  nsCOMPtr<nsIWritablePropertyBag> bag = ::do_QueryInterface(newChannel);
  if (bag) {
    for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) {
      bag->SetProperty(iter.Key(), iter.UserData());
    }
  }

  // Notify consumer, giving chance to cancel redirect.  For backwards compat,
  // we support nsIHttpEventSink if we are an HTTP channel and if this is not
  // an internal redirect.

  RefPtr<nsAsyncRedirectVerifyHelper> redirectCallbackHelper =
      new nsAsyncRedirectVerifyHelper();

  bool checkRedirectSynchronously = !openNewChannel;

  mRedirectChannel = newChannel;
  mRedirectFlags = redirectFlags;
  mOpenRedirectChannel = openNewChannel;
  nsresult rv = redirectCallbackHelper->Init(this, newChannel, redirectFlags,
                                             checkRedirectSynchronously);
  if (NS_FAILED(rv))
    return rv;

  if (checkRedirectSynchronously && NS_FAILED(mStatus))
    return mStatus;

  return NS_OK;
}