Bug 628132 - Crash [@ mozilla::ipc::RPCChannel::CxxStackFrame::CxxStackFrame] (from PContentPermissionRequestParent::Send__delete__) [r=cjones a=fennec-crash] DONTBUILD
authorAlex Pakhotin <alexp@mozilla.com>
Wed, 09 Feb 2011 11:07:43 -0800
changeset 62454 0644a18eb249c04ea9f01963d7f7effdbff6bae3
parent 62453 edf89132ec20b0408562a9bf214eca8c78699775
child 62455 644a1f424797dbfdc787afcf44ae6beaa90cb419
push idunknown
push userunknown
push dateunknown
reviewerscjones, fennec-crash
bugs628132
milestone2.0b12pre
Bug 628132 - Crash [@ mozilla::ipc::RPCChannel::CxxStackFrame::CxxStackFrame] (from PContentPermissionRequestParent::Send__delete__) [r=cjones a=fennec-crash] DONTBUILD
dom/base/nsContentPermissionHelper.cpp
dom/base/nsContentPermissionHelper.h
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -67,16 +67,22 @@ nsContentPermissionRequestProxy::Init(co
   if (!prompt) {
     return NS_ERROR_FAILURE;
   }
 
   prompt->Prompt(this);
   return NS_OK;
 }
 
+void
+nsContentPermissionRequestProxy::OnParentDestroyed()
+{
+  mParent = nsnull;
+}
+
 NS_IMPL_ISUPPORTS1(nsContentPermissionRequestProxy, nsIContentPermissionRequest);
 
 NS_IMETHODIMP
 nsContentPermissionRequestProxy::GetType(nsACString & aType)
 {
   aType = mType;
   return NS_OK;
 }
@@ -108,28 +114,26 @@ nsContentPermissionRequestProxy::GetElem
     return NS_ERROR_FAILURE;
   NS_ADDREF(*aRequestingElement = mParent->mElement);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsContentPermissionRequestProxy::Cancel()
 {
-  NS_ASSERTION(mParent, "No parent for request");
   if (mParent == nsnull)
     return NS_ERROR_FAILURE;
   unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, false);
   mParent = nsnull;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsContentPermissionRequestProxy::Allow()
 {
-  NS_ASSERTION(mParent, "No parent for request");
   if (mParent == nsnull)
     return NS_ERROR_FAILURE;
   unused << mozilla::dom::ContentPermissionRequestParent::Send__delete__(mParent, true);
   mParent = nsnull;
   return NS_OK;
 }
 
 namespace mozilla {
@@ -156,10 +160,16 @@ ContentPermissionRequestParent::Recvprom
 {
   mProxy = new nsContentPermissionRequestProxy();
   NS_ASSERTION(mProxy, "Alloc of request proxy failed");
   if (NS_FAILED(mProxy->Init(mType, this)))
     mProxy->Cancel();
   return true;
 }
 
+void
+ContentPermissionRequestParent::ActorDestroy(ActorDestroyReason why)
+{
+  mProxy->OnParentDestroyed();
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/dom/base/nsContentPermissionHelper.h
+++ b/dom/base/nsContentPermissionHelper.h
@@ -59,28 +59,30 @@ class ContentPermissionRequestParent : p
   
   nsCOMPtr<nsIURI>           mURI;
   nsCOMPtr<nsIDOMElement>    mElement;
   nsCOMPtr<nsContentPermissionRequestProxy> mProxy;
   nsCString mType;
 
  private:  
   virtual bool Recvprompt();
+  virtual void ActorDestroy(ActorDestroyReason why);
 };
   
 } // namespace dom
 } // namespace mozilla
 
 class nsContentPermissionRequestProxy : public nsIContentPermissionRequest
 {
  public:
   nsContentPermissionRequestProxy();
   virtual ~nsContentPermissionRequestProxy();
   
   nsresult Init(const nsACString& type, mozilla::dom::ContentPermissionRequestParent* parent);
+  void OnParentDestroyed();
   
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTENTPERMISSIONREQUEST
 
  private:
   // Non-owning pointer to the ContentPermissionRequestParent object which owns this proxy.
   mozilla::dom::ContentPermissionRequestParent* mParent;
   nsCString mType;