summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_plugin/browser_plugin_embedder.cc
diff options
context:
space:
mode:
authorfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-20 11:25:51 +0000
committerfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-20 11:25:51 +0000
commitb371a5651f02bb1f1d6d8b6a7934b1c3c7f371c4 (patch)
treec28f0f9698d49e698540eb7ed7b92162e2bf7bd8 /content/browser/browser_plugin/browser_plugin_embedder.cc
parent8daae47a36bb43df1939a7586ec8066356a48332 (diff)
downloadchromium_src-b371a5651f02bb1f1d6d8b6a7934b1c3c7f371c4.zip
chromium_src-b371a5651f02bb1f1d6d8b6a7934b1c3c7f371c4.tar.gz
chromium_src-b371a5651f02bb1f1d6d8b6a7934b1c3c7f371c4.tar.bz2
Browser Plugin: BrowserPluginGuest manages its own lifetime
In an effort to eventually remove BrowserPluginEmbedder, I've moved a guest's lifetime management to the BrowserPluginGuest itself. 1. BrowserPluginHostMsg_PluginDestroyed messages are routed to BrowserPluginGuest. 2. A guest listens for its embedder's NOTIFICATION_RENDER_VIEW_HOST_DELETED and destroys itself. BUG=174673, 140316 Test=BrowserPluginHostTest.* Review URL: https://chromiumcodereview.appspot.com/12230028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_plugin/browser_plugin_embedder.cc')
-rw-r--r--content/browser/browser_plugin/browser_plugin_embedder.cc38
1 files changed, 8 insertions, 30 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index ccd53e5..cb7283f 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -52,7 +52,6 @@ void BrowserPluginEmbedder::CreateGuest(
int routing_id,
BrowserPluginGuest* guest_opener,
const BrowserPluginHostMsg_CreateGuest_Params& params) {
- WebContentsImpl* guest_web_contents = NULL;
SiteInstance* guest_site_instance = NULL;
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
CHECK(!guest);
@@ -124,7 +123,7 @@ void BrowserPluginEmbedder::CreateGuest(
WebContentsImpl* opener_web_contents = static_cast<WebContentsImpl*>(
guest_opener ? guest_opener->GetWebContents() : NULL);
- guest_web_contents = WebContentsImpl::CreateGuest(
+ WebContentsImpl::CreateGuest(
web_contents()->GetBrowserContext(),
guest_site_instance,
routing_id,
@@ -132,11 +131,6 @@ void BrowserPluginEmbedder::CreateGuest(
opener_web_contents,
instance_id,
params);
-
- guest = guest_web_contents->GetBrowserPluginGuest();
- AddGuest(instance_id, guest_web_contents);
-
- guest->Initialize(params, guest_web_contents->GetRenderViewHost());
}
BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID(
@@ -148,17 +142,6 @@ BrowserPluginGuest* BrowserPluginEmbedder::GetGuestByInstanceID(
return NULL;
}
-void BrowserPluginEmbedder::DestroyGuestByInstanceID(int instance_id) {
- BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
- if (guest) {
- WebContents* guest_web_contents = guest->GetWebContents();
-
- // Destroy the guest's web_contents.
- delete guest_web_contents;
- guest_web_contents_by_instance_id_.erase(instance_id);
- }
-}
-
void BrowserPluginEmbedder::GetRenderViewHostAtPosition(
int x, int y, const WebContents::GetRenderViewHostCallback& callback) {
// Store the callback so we can call it later when we have the response.
@@ -199,8 +182,6 @@ bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
OnCreateGuest)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginAtPositionResponse,
OnPluginAtPositionResponse)
- IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_PluginDestroyed,
- OnPluginDestroyed)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_BuffersSwappedACK,
OnUnhandledSwapBuffersACK)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -215,13 +196,13 @@ void BrowserPluginEmbedder::AddGuest(int instance_id,
guest_web_contents_by_instance_id_[instance_id] = guest_web_contents;
}
-void BrowserPluginEmbedder::CleanUp() {
- // Destroy guests that are managed by the current embedder.
- STLDeleteContainerPairSecondPointers(
- guest_web_contents_by_instance_id_.begin(),
- guest_web_contents_by_instance_id_.end());
- guest_web_contents_by_instance_id_.clear();
+void BrowserPluginEmbedder::RemoveGuest(int instance_id) {
+ DCHECK(guest_web_contents_by_instance_id_.find(instance_id) !=
+ guest_web_contents_by_instance_id_.end());
+ guest_web_contents_by_instance_id_.erase(instance_id);
+}
+void BrowserPluginEmbedder::CleanUp() {
// CleanUp gets called when BrowserPluginEmbedder's WebContents goes away
// or the associated RenderViewHost is destroyed or swapped out. Therefore we
// don't need to care about the pending callbacks anymore.
@@ -237,6 +218,7 @@ bool BrowserPluginEmbedder::ShouldForwardToBrowserPluginGuest(
case BrowserPluginHostMsg_Go::ID:
case BrowserPluginHostMsg_HandleInputEvent::ID:
case BrowserPluginHostMsg_NavigateGuest::ID:
+ case BrowserPluginHostMsg_PluginDestroyed::ID:
case BrowserPluginHostMsg_Reload::ID:
case BrowserPluginHostMsg_ResizeGuest::ID:
case BrowserPluginHostMsg_SetAutoSize::ID:
@@ -283,10 +265,6 @@ void BrowserPluginEmbedder::OnPluginAtPositionResponse(
pending_get_render_view_callbacks_.erase(callback_iter);
}
-void BrowserPluginEmbedder::OnPluginDestroyed(int instance_id) {
- DestroyGuestByInstanceID(instance_id);
-}
-
// We only get here during teardown if we have one last buffer pending,
// otherwise the ACK is handled by the guest.
void BrowserPluginEmbedder::OnUnhandledSwapBuffersACK(