Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2012-05-09 18:09:29 +01:00
commit 1367c1684d
5 changed files with 65 additions and 39 deletions

View File

@ -899,8 +899,8 @@ nsGlobalWindow::~nsGlobalWindow()
// If our outer window's inner window is this window, null out the
// outer window's reference to this window that's being deleted.
nsGlobalWindow *outer = GetOuterWindowInternal();
if (outer && outer->mInnerWindow == this) {
outer->mInnerWindow = nsnull;
if (outer) {
outer->MaybeClearInnerWindow(this);
}
}
@ -1164,18 +1164,6 @@ nsGlobalWindow::FreeInnerObjects()
NotifyWindowIDDestroyed("inner-window-destroyed");
JSObject* obj = FastGetGlobalJSObject();
if (obj) {
if (!cx) {
cx = nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
}
JSAutoRequest ar(cx);
js::NukeChromeCrossCompartmentWrappersForGlobal(cx, obj,
js::DontNukeForGlobalObject);
}
CleanupCachedXBLHandlers(this);
#ifdef DEBUG
@ -1315,7 +1303,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mArgumentsLast)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mInnerWindowHolder)
if (tmp->mOuterWindow) {
static_cast<nsGlobalWindow*>(tmp->mOuterWindow.get())->MaybeClearInnerWindow(tmp);
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOuterWindow)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOpenerScriptPrincipal)
if (tmp->mListenerManager) {
@ -2234,17 +2225,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
nsGlobalWindow *currentInner = GetCurrentInnerWindowInternal();
if (currentInner) {
JSObject* obj = currentInner->FastGetGlobalJSObject();
if (obj) {
JSContext* cx =
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
JSAutoRequest ar(cx);
js::NukeChromeCrossCompartmentWrappersForGlobal(cx, obj,
js::NukeForGlobalObject);
}
NS_ASSERTION(mDoc, "Must have doc!");
// Remember the document's principal.
@ -6663,8 +6643,12 @@ nsGlobalWindow::NotifyDOMWindowDestroyed(nsGlobalWindow* aWindow) {
class WindowDestroyedEvent : public nsRunnable
{
public:
WindowDestroyedEvent(PRUint64 aID, const char* aTopic) :
mID(aID), mTopic(aTopic) {}
WindowDestroyedEvent(nsPIDOMWindow* aWindow, PRUint64 aID,
const char* aTopic) :
mID(aID), mTopic(aTopic)
{
mWindow = do_GetWeakReference(aWindow);
}
NS_IMETHOD Run()
{
@ -6678,18 +6662,40 @@ public:
observerService->NotifyObservers(wrapper, mTopic.get(), nsnull);
}
}
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
if (window) {
nsGlobalWindow* currentInner =
window->IsInnerWindow() ? static_cast<nsGlobalWindow*>(window.get()) :
static_cast<nsGlobalWindow*>(window->GetCurrentInnerWindow());
NS_ENSURE_TRUE(currentInner, NS_OK);
JSObject* obj = currentInner->FastGetGlobalJSObject();
if (obj) {
JSContext* cx =
nsContentUtils::ThreadJSContextStack()->GetSafeJSContext();
JSAutoRequest ar(cx);
js::NukeChromeCrossCompartmentWrappersForGlobal(cx, obj,
window->IsInnerWindow() ? js::DontNukeForGlobalObject :
js::NukeForGlobalObject);
}
}
return NS_OK;
}
private:
PRUint64 mID;
nsCString mTopic;
nsWeakPtr mWindow;
};
void
nsGlobalWindow::NotifyWindowIDDestroyed(const char* aTopic)
{
nsRefPtr<nsIRunnable> runnable = new WindowDestroyedEvent(mWindowID, aTopic);
nsRefPtr<nsIRunnable> runnable = new WindowDestroyedEvent(this, mWindowID, aTopic);
nsresult rv = NS_DispatchToCurrentThread(runnable);
if (NS_SUCCEEDED(rv)) {
mNotifiedIDDestroyed = true;

View File

@ -568,6 +568,13 @@ protected:
void ClearControllers();
nsresult FinalClose();
inline void MaybeClearInnerWindow(nsGlobalWindow* aExpectedInner)
{
if(mInnerWindow == aExpectedInner) {
mInnerWindow = nsnull;
}
}
void FreeInnerObjects();
JSObject *CallerGlobal();
nsGlobalWindow *CallerInnerWindow();

View File

@ -13,7 +13,7 @@ import android.content.ComponentName;
public class GeckoActivity extends Activity {
private boolean hasStarted = false;
private boolean isGeckoActivityOpened = false;
private boolean mGeckoActivityOpened = false;
@Override
public void onPause() {
@ -31,7 +31,7 @@ public class GeckoActivity extends Activity {
// Avoid resume notifications in startup path.
if (hasStarted && (getApplication() instanceof GeckoApplication)) {
((GeckoApplication) getApplication()).onActivityResume(this);
isGeckoActivityOpened = false;
mGeckoActivityOpened = false;
} else {
hasStarted = true;
}
@ -54,15 +54,19 @@ public class GeckoActivity extends Activity {
// If we call an activity from another package, or an open intent (leaving android to resolve)
// component has a different package name or it is null.
ComponentName component = intent.getComponent();
isGeckoActivityOpened = false;
mGeckoActivityOpened = false;
if (component != null &&
component.getPackageName() != null &&
component.getPackageName().equals("@ANDROID_PACKAGE_NAME@")) {
isGeckoActivityOpened = true;
mGeckoActivityOpened = true;
}
}
public boolean isGeckoActivityOpened() {
return mGeckoActivityOpened;
}
public boolean isApplicationInBackground() {
return !isGeckoActivityOpened;
return ((GeckoApplication) getApplication()).isApplicationInBackground();
}
}

View File

@ -11,6 +11,7 @@ import android.app.Application;
public class GeckoApplication extends Application {
private boolean mInBackground = false;
private ArrayList<ApplicationLifecycleCallbacks> mListeners;
public interface ApplicationLifecycleCallbacks {
@ -33,19 +34,21 @@ public class GeckoApplication extends Application {
}
public void onActivityPause(GeckoActivity activity) {
if (!activity.isApplicationInBackground())
if (activity.isGeckoActivityOpened())
return;
if (mListeners == null)
return;
mInBackground = true;
for (ApplicationLifecycleCallbacks listener: mListeners)
listener.onApplicationPause();
}
public void onActivityResume(GeckoActivity activity) {
// This is a misnomer. Should have been "wasApplicationInBackground".
if (!activity.isApplicationInBackground())
// This is a misnomer. Should have been "wasGeckoActivityOpened".
if (activity.isGeckoActivityOpened())
return;
if (mListeners == null)
@ -53,5 +56,11 @@ public class GeckoApplication extends Application {
for (ApplicationLifecycleCallbacks listener: mListeners)
listener.onApplicationResume();
mInBackground = false;
}
public boolean isApplicationInBackground() {
return mInBackground;
}
}

View File

@ -1024,8 +1024,6 @@ nsHttpChannel::ProcessResponse()
LOG(("nsHttpChannel::ProcessResponse [this=%p httpStatus=%u]\n",
this, httpStatus));
UpdateInhibitPersistentCachingFlag();
if (mTransaction->SSLConnectFailed()) {
if (!ShouldSSLProxyResponseContinue(httpStatus))
return ProcessFailedSSLConnect(httpStatus);
@ -1273,6 +1271,8 @@ nsHttpChannel::ContinueProcessNormal(nsresult rv)
ClearBogusContentEncodingIfNeeded();
UpdateInhibitPersistentCachingFlag();
// this must be called before firing OnStartRequest, since http clients,
// such as imagelib, expect our cache entry to already have the correct
// expiration time (bug 87710).