Bug 1112989 - Part 2. Forward device-storage volumes info to ContentChild before app startup. r=dhylands

This commit is contained in:
Kan-Ru Chen (陳侃如) 2015-01-28 13:54:10 +08:00
parent 1043dea8b9
commit 0c55d69367
6 changed files with 46 additions and 7 deletions

View File

@ -2136,6 +2136,18 @@ ContentChild::RecvLastPrivateDocShellDestroyed()
return true;
}
bool
ContentChild::RecvVolumes(nsTArray<VolumeInfo>&& aVolumes)
{
#ifdef MOZ_WIDGET_GONK
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
if (vs) {
vs->RecvVolumesFromParent(aVolumes);
}
#endif
return true;
}
bool
ContentChild::RecvFilePathUpdate(const nsString& aStorageType,
const nsString& aStorageName,

View File

@ -332,6 +332,7 @@ public:
virtual bool RecvLastPrivateDocShellDestroyed() MOZ_OVERRIDE;
virtual bool RecvVolumes(InfallibleTArray<VolumeInfo>&& aVolumes) MOZ_OVERRIDE;
virtual bool RecvFilePathUpdate(const nsString& aStorageType,
const nsString& aStorageName,
const nsString& aPath,

View File

@ -1319,6 +1319,14 @@ ContentParent::ForwardKnownInfo()
if (!mMetamorphosed) {
return;
}
#ifdef MOZ_WIDGET_GONK
InfallibleTArray<VolumeInfo> volumeInfo;
nsRefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
if (vs) {
vs->GetVolumesForIPC(&volumeInfo);
unused << SendVolumes(volumeInfo);
}
#endif /* MOZ_WIDGET_GONK */
}
namespace {

View File

@ -471,6 +471,8 @@ child:
ScreenSizeChanged(gfxIntSize size);
Volumes(VolumeInfo[] volumes);
FlushMemory(nsString reason);
GarbageCollect();

View File

@ -280,7 +280,7 @@ nsVolumeService::GetVolumesForIPC(nsTArray<VolumeInfo>* aResult)
}
void
nsVolumeService::GetVolumesFromParent()
nsVolumeService::RecvVolumesFromParent(const nsTArray<VolumeInfo>& aVolumes)
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// We are the parent. Therefore our volumes are already correct.
@ -290,12 +290,8 @@ nsVolumeService::GetVolumesFromParent()
// We've already done this, no need to do it again.
return;
}
mGotVolumesFromParent = true;
nsTArray<VolumeInfo> result;
ContentChild::GetSingleton()->SendGetVolumes(&result);
for (uint32_t i = 0; i < result.Length(); i++) {
const VolumeInfo& volInfo(result[i]);
for (uint32_t i = 0; i < aVolumes.Length(); i++) {
const VolumeInfo& volInfo(aVolumes[i]);
nsRefPtr<nsVolume> vol = new nsVolume(volInfo.name(),
volInfo.mountPoint(),
volInfo.volState(),
@ -311,6 +307,25 @@ nsVolumeService::GetVolumesFromParent()
}
}
void
nsVolumeService::GetVolumesFromParent()
{
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// We are the parent. Therefore our volumes are already correct.
return;
}
if (mGotVolumesFromParent) {
// We've already done this, no need to do it again.
return;
}
nsTArray<VolumeInfo> result;
ContentChild::GetSingleton()->SendGetVolumes(&result);
RecvVolumesFromParent(result);
mGotVolumesFromParent = true;
}
NS_IMETHODIMP
nsVolumeService::CreateMountLock(const nsAString& aVolumeName, nsIVolumeMountLock **aResult)
{

View File

@ -48,6 +48,7 @@ public:
void UpdateVolume(nsIVolume* aVolume, bool aNotifyObservers = true);
void UpdateVolumeIOThread(const Volume* aVolume);
void RecvVolumesFromParent(const nsTArray<dom::VolumeInfo>& aVolumes);
void GetVolumesForIPC(nsTArray<dom::VolumeInfo>* aResult);
private: