Bug 818131 - Volume Manager should create fake volumes. r=dougt, a=blocking-basecamp
authorDave Hylands <dhylands@mozilla.com>
Thu, 06 Dec 2012 09:31:57 -0800
changeset 117406 04cbc663c7747f838313b9529ab96d13fc82187d
parent 117405 e5d5f35b3e823de1d04be33066ef26283d85bb60
child 117407 1f3faeb42ebf5344b1dfcef8aaf92e79375f4799
push id1873
push userryanvm@gmail.com
push dateFri, 07 Dec 2012 22:27:23 +0000
treeherdermozilla-beta@872ec2b322ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt, blocking-basecamp
bugs818131
milestone18.0
Bug 818131 - Volume Manager should create fake volumes. r=dougt, a=blocking-basecamp This allows Updater and Device storage to query free space on a partition even if a real volume doesn't exist.
dom/system/gonk/nsVolumeService.cpp
--- a/dom/system/gonk/nsVolumeService.cpp
+++ b/dom/system/gonk/nsVolumeService.cpp
@@ -96,19 +96,23 @@ NS_IMETHODIMP nsVolumeService::GetVolume
     nsAutoCString volMountPointSlash = NS_ConvertUTF16toUTF8(vol->MountPoint());
     volMountPointSlash.Append(NS_LITERAL_CSTRING("/"));
     nsDependentCSubstring testStr(realPathBuf, volMountPointSlash.Length());
     if (volMountPointSlash.Equals(testStr)) {
       NS_ADDREF(*aResult = vol);
       return NS_OK;
     }
   }
-  ERR("GetVolumeByPath: Unable to find volume by path: '%s'",
-      NS_LossyConvertUTF16toASCII(aPath).get());
-  return NS_ERROR_NOT_AVAILABLE;
+
+  // In order to support queries by DeviceStorage and the updater, we will fabricate
+  // a volume from the pathname, so that the caller can determine the volume size
+  nsRefPtr<nsVolume> vol = new nsVolume(NS_LITERAL_STRING("fake"),
+  aPath, nsIVolume::STATE_MOUNTED);
+  NS_ADDREF(*aResult = vol);
+  return NS_OK;
 }
 
 already_AddRefed<nsVolume> nsVolumeService::FindVolumeByName(const nsAString &aName)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
   MOZ_ASSERT(NS_IsMainThread());
 
   nsVolume::Array::size_type  numVolumes = mVolumeArray.Length();