Commit 14efbd4e authored by lfg's avatar lfg Committed by Commit bot

Use a weak pointer when binding GuestViewBase::DidAttach.

The lifetime of GuestViewBase doesn't match the lifetime of GuestViewMessageFilter, so it's possible that the GuestViewBase is already destroyed by the time this callback is called.

BUG=716223

Review-Url: https://codereview.chromium.org/2848723002
Cr-Commit-Position: refs/heads/master@{#468072}
parent f97da42c
......@@ -144,7 +144,8 @@ void GuestViewMessageFilter::OnAttachToEmbedderFrame(
guest->WillAttach(
owner_web_contents, element_instance_id, false,
base::Bind(&GuestViewMessageFilter::WillAttachCallback, this, guest));
base::Bind(&GuestViewBase::DidAttach,
guest->weak_ptr_factory_.GetWeakPtr(), MSG_ROUTING_NONE));
// Attach this inner WebContents |guest_web_contents| to the outer
// WebContents |owner_web_contents|. The outer WebContents's
......@@ -155,8 +156,4 @@ void GuestViewMessageFilter::OnAttachToEmbedderFrame(
embedder_frame);
}
void GuestViewMessageFilter::WillAttachCallback(GuestViewBase* guest) {
guest->DidAttach(MSG_ROUTING_NONE);
}
} // namespace guest_view
......@@ -23,7 +23,6 @@ class BrowserContext;
}
namespace guest_view {
class GuestViewBase;
class GuestViewManager;
// This class filters out incoming GuestView-specific IPC messages from the
......@@ -75,8 +74,6 @@ class GuestViewMessageFilter : public content::BrowserMessageFilter {
void OnViewCreated(int view_instance_id, const std::string& view_type);
void OnViewGarbageCollected(int view_instance_id);
void WillAttachCallback(GuestViewBase* guest);
DISALLOW_COPY_AND_ASSIGN(GuestViewMessageFilter);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment