зеркало из https://github.com/mozilla/pjs.git
Bug 619670 - onLowMemory may not work on android. Need to forward event. r=dougt/blassey. a=blocking-fennec
--HG-- extra : rebase_source : eca6be2a6b82f2e2d2dd71870b036878afbbafa8
This commit is contained in:
Родитель
95c5b36d08
Коммит
80d1845b88
|
@ -92,9 +92,11 @@ Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobjec
|
|||
NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_onLowMemory(JNIEnv *jenv, jclass jc)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(nsnull, "memory-pressure", NS_LITERAL_STRING("low-memory").get());
|
||||
if (nsAppShell::gAppShell) {
|
||||
nsAppShell::gAppShell->NotifyObservers(nsnull,
|
||||
"memory-pressure",
|
||||
NS_LITERAL_STRING("low-memory").get());
|
||||
}
|
||||
}
|
||||
|
||||
NS_EXPORT void JNICALL
|
||||
|
|
|
@ -425,6 +425,40 @@ nsAppShell::RemoveObserver(const nsAString &aObserverKey)
|
|||
mObserversHash.Remove(aObserverKey);
|
||||
}
|
||||
|
||||
// NotifyObservers support. NotifyObservers only works on main thread.
|
||||
|
||||
class NotifyObserversCaller : public nsRunnable {
|
||||
public:
|
||||
NotifyObserversCaller(nsISupports *aSupports,
|
||||
const char *aTopic, const PRUnichar *aData) :
|
||||
mSupports(aSupports), mTopic(aTopic), mData(aData) {
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (os)
|
||||
os->NotifyObservers(mSupports, mTopic.get(), mData.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mSupports;
|
||||
nsCString mTopic;
|
||||
nsString mData;
|
||||
};
|
||||
|
||||
void
|
||||
nsAppShell::NotifyObservers(nsISupports *aSupports,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
// This isn't main thread, so post this to main thread
|
||||
nsCOMPtr<nsIRunnable> caller =
|
||||
new NotifyObserversCaller(aSupports, aTopic, aData);
|
||||
NS_DispatchToMainThread(caller);
|
||||
}
|
||||
|
||||
// Used by IPC code
|
||||
namespace mozilla {
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
nsresult AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver);
|
||||
void CallObserver(const nsAString &aObserverKey, const nsAString &aTopic, const nsAString &aData);
|
||||
void RemoveObserver(const nsAString &aObserverKey);
|
||||
void NotifyObservers(nsISupports *aSupports, const char *aTopic, const PRUnichar *aData);
|
||||
|
||||
protected:
|
||||
virtual void ScheduleNativeEventCallback();
|
||||
|
|
Загрузка…
Ссылка в новой задаче