Chromium Code Reviews| Index: content/browser/browser_plugin/browser_plugin_guest_manager.cc |
| diff --git a/content/browser/browser_plugin/browser_plugin_guest_manager.cc b/content/browser/browser_plugin/browser_plugin_guest_manager.cc |
| index 5aa8f84216c56af55d55a22055c7c1e9e2a59421..5c9fa9f7608a75d8087ae9a2b5902f7a89b026c4 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_guest_manager.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_guest_manager.cc |
| @@ -121,18 +121,29 @@ BrowserPluginGuest* BrowserPluginGuestManager::CreateGuest( |
| extra_params.Pass()); |
| } |
| -BrowserPluginGuest* BrowserPluginGuestManager::GetGuestByInstanceID( |
| +static void BrowserPluginGuestByInstanceIDCallback( |
|
lazyboy
2014/05/01 23:27:58
Again, OnGuestRetrieved might be better describing
Fady Samuel
2014/05/06 16:51:36
Skipping. This file is going away very soon.
|
| + const BrowserPluginGuestManager::GuestByInstanceIDCallback& callback, |
| + WebContents* guest_web_contents) { |
| + if (!guest_web_contents) { |
| + callback.Run(NULL); |
| + return; |
| + } |
| + callback.Run(static_cast<WebContentsImpl*>(guest_web_contents)-> |
| + GetBrowserPluginGuest()); |
| +} |
| + |
| +void BrowserPluginGuestManager::MaybeGetGuestByInstanceIDOrKill( |
| int instance_id, |
| - int embedder_render_process_id) const { |
| + int embedder_render_process_id, |
| + const GuestByInstanceIDCallback& callback) const { |
| if (!GetDelegate()) |
|
lazyboy
2014/05/01 23:27:58
Consider callback.Run(NULL) to be more consistent,
Fady Samuel
2014/05/06 16:51:36
Done.
|
| - return NULL; |
| - |
| - WebContentsImpl* guest_web_contents = static_cast<WebContentsImpl*>( |
| - GetDelegate()->GetGuestByInstanceID(instance_id, |
| - embedder_render_process_id)); |
| + return; |
| - return guest_web_contents ? |
| - guest_web_contents->GetBrowserPluginGuest() : NULL; |
| + GetDelegate()->MaybeGetGuestByInstanceIDOrKill( |
| + instance_id, |
| + embedder_render_process_id, |
| + base::Bind(&BrowserPluginGuestByInstanceIDCallback, |
| + callback)); |
| } |
| void BrowserPluginGuestManager::AddGuest(int instance_id, |
| @@ -148,14 +159,11 @@ void BrowserPluginGuestManager::RemoveGuest(int instance_id) { |
| GetDelegate()->RemoveGuest(instance_id); |
| } |
| -bool BrowserPluginGuestManager::CanEmbedderAccessInstanceIDMaybeKill( |
| - int embedder_render_process_id, |
| - int instance_id) const { |
| - if (!GetDelegate()) |
| - return false; |
| - |
| - return GetDelegate()->CanEmbedderAccessInstanceIDMaybeKill( |
| - embedder_render_process_id, instance_id); |
| +static void BrowserPluginGuestMessageCallback(const IPC::Message& message, |
| + BrowserPluginGuest* guest) { |
| + if (!guest) |
| + return; |
| + guest->OnMessageReceivedFromEmbedder(message); |
| } |
| void BrowserPluginGuestManager::OnMessageReceived(const IPC::Message& message, |
| @@ -166,11 +174,10 @@ void BrowserPluginGuestManager::OnMessageReceived(const IPC::Message& message, |
| PickleIterator iter(message); |
| bool success = iter.ReadInt(&instance_id); |
| DCHECK(success); |
| - BrowserPluginGuest* guest = |
| - GetGuestByInstanceID(instance_id, render_process_id); |
| - if (!guest) |
| - return; |
| - guest->OnMessageReceivedFromEmbedder(message); |
| + MaybeGetGuestByInstanceIDOrKill(instance_id, |
| + render_process_id, |
| + base::Bind(&BrowserPluginGuestMessageCallback, |
| + message)); |
| } |
| SiteInstance* BrowserPluginGuestManager::GetGuestSiteInstance( |