Ejemplo n.º 1
0
void nsVolume::Set(const nsVolume* aVolume)
{
    MOZ_ASSERT(NS_IsMainThread());

    mName = aVolume->mName;
    mMountPoint = aVolume->mMountPoint;
    mState = aVolume->mState;

    if (mState != nsIVolume::STATE_MOUNTED) {
        // Since we're not in the mounted state, we need to
        // forgot whatever mount generation we may have had.
        mMountGeneration = -1;
        return;
    }
    if (mMountGeneration == aVolume->mMountGeneration) {
        // No change in mount generation, nothing else to do
        return;
    }

    mMountGeneration = aVolume->mMountGeneration;

    // Notify the Volume on IOThread whether the volume is locked or not.
    nsCOMPtr<nsIPowerManagerService> pmService =
        do_GetService(POWERMANAGERSERVICE_CONTRACTID);
    if (!pmService) {
        return;
    }
    nsString mountLockName;
    GetMountLockName(mountLockName);
    nsString mountLockState;
    pmService->GetWakeLockState(mountLockName, mountLockState);
    UpdateMountLock(mountLockState);
}
Ejemplo n.º 2
0
void
nsVolume::UpdateMountLock(const nsAString& aMountLockState)
{
    MOZ_ASSERT(NS_IsMainThread());

    // There are 3 states, unlocked, locked-background, and locked-foreground
    // I figured it was easier to use negtive logic and compare for unlocked.
    UpdateMountLock(!aMountLockState.EqualsLiteral("unlocked"));
}
Ejemplo n.º 3
0
void nsVolume::Set(nsIVolume* aVolume)
{
  MOZ_ASSERT(NS_IsMainThread());

  aVolume->GetName(mName);
  aVolume->GetMountPoint(mMountPoint);
  aVolume->GetState(&mState);
  aVolume->GetIsFake(&mIsFake);
  aVolume->GetIsMediaPresent(&mIsMediaPresent);
  aVolume->GetIsSharing(&mIsSharing);
  aVolume->GetIsFormatting(&mIsFormatting);
  aVolume->GetIsUnmounting(&mIsUnmounting);
  aVolume->GetIsRemovable(&mIsRemovable);
  aVolume->GetIsHotSwappable(&mIsHotSwappable);

  int32_t volMountGeneration;
  aVolume->GetMountGeneration(&volMountGeneration);

  if (mState != nsIVolume::STATE_MOUNTED) {
    // Since we're not in the mounted state, we need to
    // forgot whatever mount generation we may have had.
    mMountGeneration = -1;
    return;
  }
  if (mMountGeneration == volMountGeneration) {
    // No change in mount generation, nothing else to do
    return;
  }

  mMountGeneration = volMountGeneration;

  if (!XRE_IsParentProcess()) {
    // Child processes just track the state, not maintain it.
    aVolume->GetIsMountLocked(&mMountLocked);
    return;
  }

  // Notify the Volume on IOThread whether the volume is locked or not.
  nsCOMPtr<nsIPowerManagerService> pmService =
    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
  if (!pmService) {
    return;
  }
  nsString mountLockName;
  GetMountLockName(mountLockName);
  nsString mountLockState;
  pmService->GetWakeLockState(mountLockName, mountLockState);
  UpdateMountLock(mountLockState);
}
Ejemplo n.º 4
0
void nsVolume::UpdateMountLock(nsVolume* aOldVolume)
{
  MOZ_ASSERT(NS_IsMainThread());

  bool oldMountLocked = aOldVolume ? aOldVolume->mMountLocked : false;
  if (mState != nsIVolume::STATE_MOUNTED) {
    // Since we're not in the mounted state, we need to
    // forgot whatever mount generation we may have had.
    mMountGeneration = -1;
    mMountLocked = oldMountLocked;
    return;
  }

  int32_t oldMountGeneration = aOldVolume ? aOldVolume->mMountGeneration : -1;
  if (mMountGeneration == oldMountGeneration) {
    // No change in mount generation, nothing else to do
    mMountLocked = oldMountLocked;
    return;
  }

  if (!XRE_IsParentProcess()) {
    // Child processes just track the state, not maintain it.
    return;
  }

  // Notify the Volume on IOThread whether the volume is locked or not.
  nsCOMPtr<nsIPowerManagerService> pmService =
    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
  if (!pmService) {
    return;
  }
  nsString mountLockName;
  GetMountLockName(mountLockName);
  nsString mountLockState;
  pmService->GetWakeLockState(mountLockName, mountLockState);
  UpdateMountLock(mountLockState);
}