dom/system/gonk/nsVolume.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/system/gonk/nsVolume.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,111 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_system_nsvolume_h__
     1.9 +#define mozilla_system_nsvolume_h__
    1.10 +
    1.11 +#include "nsCOMPtr.h"
    1.12 +#include "nsIVolume.h"
    1.13 +#include "nsString.h"
    1.14 +#include "nsTArray.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace system {
    1.18 +
    1.19 +class Volume;
    1.20 +class VolumeMountLock;
    1.21 +
    1.22 +class nsVolume : public nsIVolume
    1.23 +{
    1.24 +public:
    1.25 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.26 +  NS_DECL_NSIVOLUME
    1.27 +
    1.28 +  // This constructor is used by the UpdateVolumeRunnable constructor
    1.29 +  nsVolume(const Volume* aVolume);
    1.30 +
    1.31 +  // This constructor is used by ContentChild::RecvFileSystemUpdate which is
    1.32 +  // used to update the volume cache maintained in the child process.
    1.33 +  nsVolume(const nsAString& aName, const nsAString& aMountPoint,
    1.34 +           const int32_t& aState, const int32_t& aMountGeneration,
    1.35 +           const bool& aIsMediaPresent, const bool& aIsSharing,
    1.36 +           const bool& aIsFormatting)
    1.37 +    : mName(aName),
    1.38 +      mMountPoint(aMountPoint),
    1.39 +      mState(aState),
    1.40 +      mMountGeneration(aMountGeneration),
    1.41 +      mMountLocked(false),
    1.42 +      mIsFake(false),
    1.43 +      mIsMediaPresent(aIsMediaPresent),
    1.44 +      mIsSharing(aIsSharing),
    1.45 +      mIsFormatting(aIsFormatting)
    1.46 +  {
    1.47 +  }
    1.48 +
    1.49 +  // This constructor is used by nsVolumeService::FindAddVolumeByName, and
    1.50 +  // will be followed shortly by a Set call.
    1.51 +  nsVolume(const nsAString& aName)
    1.52 +    : mName(aName),
    1.53 +      mState(STATE_INIT),
    1.54 +      mMountGeneration(-1),
    1.55 +      mMountLocked(true),  // Needs to agree with Volume::Volume
    1.56 +      mIsFake(false),
    1.57 +      mIsMediaPresent(false),
    1.58 +      mIsSharing(false),
    1.59 +      mIsFormatting(false)
    1.60 +  {
    1.61 +  }
    1.62 +
    1.63 +  bool Equals(nsIVolume* aVolume);
    1.64 +  void Set(nsIVolume* aVolume);
    1.65 +
    1.66 +  void LogState() const;
    1.67 +
    1.68 +  const nsString& Name() const        { return mName; }
    1.69 +  nsCString NameStr() const           { return NS_LossyConvertUTF16toASCII(mName); }
    1.70 +
    1.71 +  int32_t MountGeneration() const     { return mMountGeneration; }
    1.72 +  bool IsMountLocked() const          { return mMountLocked; }
    1.73 +
    1.74 +  const nsString& MountPoint() const  { return mMountPoint; }
    1.75 +  nsCString MountPointStr() const     { return NS_LossyConvertUTF16toASCII(mMountPoint); }
    1.76 +
    1.77 +  int32_t State() const               { return mState; }
    1.78 +  const char* StateStr() const        { return NS_VolumeStateStr(mState); }
    1.79 +
    1.80 +  bool IsFake() const                 { return mIsFake; }
    1.81 +  bool IsMediaPresent() const         { return mIsMediaPresent; }
    1.82 +  bool IsSharing() const              { return mIsSharing; }
    1.83 +  bool IsFormatting() const           { return mIsFormatting; }
    1.84 +
    1.85 +  typedef nsTArray<nsRefPtr<nsVolume> > Array;
    1.86 +
    1.87 +private:
    1.88 +  ~nsVolume() {}
    1.89 +
    1.90 +  friend class nsVolumeService; // Calls the following XxxMountLock functions
    1.91 +  void UpdateMountLock(const nsAString& aMountLockState);
    1.92 +  void UpdateMountLock(bool aMountLocked);
    1.93 +
    1.94 +  void SetIsFake(bool aIsFake);
    1.95 +  void SetState(int32_t aState);
    1.96 +  static void FormatVolumeIOThread(const nsCString& aVolume);
    1.97 +  static void MountVolumeIOThread(const nsCString& aVolume);
    1.98 +  static void UnmountVolumeIOThread(const nsCString& aVolume);
    1.99 +
   1.100 +  nsString mName;
   1.101 +  nsString mMountPoint;
   1.102 +  int32_t  mState;
   1.103 +  int32_t  mMountGeneration;
   1.104 +  bool     mMountLocked;
   1.105 +  bool     mIsFake;
   1.106 +  bool     mIsMediaPresent;
   1.107 +  bool     mIsSharing;
   1.108 +  bool     mIsFormatting;
   1.109 +};
   1.110 +
   1.111 +} // system
   1.112 +} // mozilla
   1.113 +
   1.114 +#endif  // mozilla_system_nsvolume_h__

mercurial