Bug 1203428 - E10S for device storage API r=cyu

This commit is contained in:
Fabrice Desré
2015-09-15 11:01:07 -07:00
parent bf85ff8f43
commit d3135a644a
5 changed files with 45 additions and 0 deletions

View File

@@ -5366,6 +5366,17 @@ ContentParent::RecvEndDriverCrashGuard(const uint32_t& aGuardType)
return true;
}
bool
ContentParent::RecvGetDeviceStorageLocation(const nsString& aType,
nsString* aPath) {
#ifdef MOZ_WIDGET_ANDROID
mozilla::AndroidBridge::GetExternalPublicDirectory(aType, *aPath);
return true;
#else
return false;
#endif
}
} // namespace dom
} // namespace mozilla

View File

@@ -898,6 +898,8 @@ private:
virtual bool RecvProfile(const nsCString& aProfile) override;
virtual bool RecvGetGraphicsDeviceInitData(DeviceInitData* aOut) override;
virtual bool RecvGetDeviceStorageLocation(const nsString& aType,
nsString* aPath) override;
// If you add strong pointers to cycle collected objects here, be sure to
// release these objects in ShutDownProcess. See the comment there for more
// details.

View File

@@ -1086,6 +1086,9 @@ parent:
sync GetGraphicsDeviceInitData()
returns (DeviceInitData aData);
sync GetDeviceStorageLocation(nsString type)
returns (nsString path);
both:
AsyncMessage(nsString aMessage, ClonedMessageData aData,
CpowEntry[] aCpows, Principal aPrincipal);

View File

@@ -47,6 +47,8 @@
#include "SurfaceTexture.h"
#include "GLContextProvider.h"
#include "mozilla/dom/ContentChild.h"
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::jni;
@@ -55,6 +57,7 @@ using namespace mozilla::widget;
AndroidBridge* AndroidBridge::sBridge = nullptr;
pthread_t AndroidBridge::sJavaUiThread;
static jobject sGlobalContext = nullptr;
nsDataHashtable<nsStringHashKey, nsString> AndroidBridge::sStoragePaths;
// This is a dummy class that can be used in the template for android::sp
class AndroidRefable {
@@ -2121,6 +2124,30 @@ nsresult AndroidBridge::InputStreamRead(Object::Param obj, char *aBuf, uint32_t
}
nsresult AndroidBridge::GetExternalPublicDirectory(const nsAString& aType, nsAString& aPath) {
if (XRE_IsContentProcess()) {
nsString key(aType);
nsAutoString path;
if (AndroidBridge::sStoragePaths.Get(key, &path)) {
aPath = path;
return NS_OK;
}
// Lazily get the value from the parent.
dom::ContentChild* child = dom::ContentChild::GetSingleton();
if (child) {
nsAutoString type(aType);
child->SendGetDeviceStorageLocation(type, &path);
if (!path.IsEmpty()) {
AndroidBridge::sStoragePaths.Put(key, path);
return NS_OK;
}
}
ALOG_BRIDGE("AndroidBridge::GetExternalPublicDirectory no cache for %s",
NS_ConvertUTF16toUTF8(aType).get());
return NS_ERROR_NOT_AVAILABLE;
}
auto path = GeckoAppShell::GetExternalPublicDirectory(aType);
if (!path) {
return NS_ERROR_NOT_AVAILABLE;

View File

@@ -309,6 +309,8 @@ public:
static nsresult GetExternalPublicDirectory(const nsAString& aType, nsAString& aPath);
protected:
static nsDataHashtable<nsStringHashKey, nsString> sStoragePaths;
static pthread_t sJavaUiThread;
static AndroidBridge* sBridge;
nsTArray<nsCOMPtr<nsIMobileMessageCallback> > mSmsRequests;