Commit 90547d76 authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

<webview>: Allocate the view instance ID from the WebView shim

This CL allocates a creates unique instance id for each
<webview> in an embedder RenderView/shim instead of in BrowserPlugin. In a subsequent CL, this will permit
usage of the WebRequest API prior to attachment to the DOM.

This CL also fixes a potential crash on edit commands if the instance ID passed did not exist: Perhaps open two <webview> apps and then close the first one, then send edit commands to the second one.

BUG=178663
Test=WebViewTest.*, WebViewInteractiveTest.*
TBR=cdn@chromium.org for deleted field in browser_plugin_messages.h

Review URL: https://chromiumcodereview.appspot.com/21930006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215807 0039d316-1c4b-4281-b951-d872f2087c98
parent a9cf75c6
...@@ -831,7 +831,7 @@ void ChromeContentBrowserClient::GuestWebContentsCreated( ...@@ -831,7 +831,7 @@ void ChromeContentBrowserClient::GuestWebContentsCreated(
return; return;
} }
std::string api_type; std::string api_type;
extra_params->GetString(guestview::kAttributeApi, &api_type); extra_params->GetString(guestview::kParameterApi, &api_type);
if (api_type == "adview") { if (api_type == "adview") {
*guest_delegate = new AdViewGuest(guest_web_contents); *guest_delegate = new AdViewGuest(guest_web_contents);
...@@ -845,7 +845,6 @@ void ChromeContentBrowserClient::GuestWebContentsCreated( ...@@ -845,7 +845,6 @@ void ChromeContentBrowserClient::GuestWebContentsCreated(
void ChromeContentBrowserClient::GuestWebContentsAttached( void ChromeContentBrowserClient::GuestWebContentsAttached(
WebContents* guest_web_contents, WebContents* guest_web_contents,
WebContents* embedder_web_contents, WebContents* embedder_web_contents,
int browser_plugin_instance_id,
const base::DictionaryValue& extra_params) { const base::DictionaryValue& extra_params) {
Profile* profile = Profile::FromBrowserContext( Profile* profile = Profile::FromBrowserContext(
embedder_web_contents->GetBrowserContext()); embedder_web_contents->GetBrowserContext());
...@@ -873,7 +872,6 @@ void ChromeContentBrowserClient::GuestWebContentsAttached( ...@@ -873,7 +872,6 @@ void ChromeContentBrowserClient::GuestWebContentsAttached(
} }
guest->Attach(embedder_web_contents, guest->Attach(embedder_web_contents,
extension->id(), extension->id(),
browser_plugin_instance_id,
extra_params); extra_params);
} }
......
...@@ -67,7 +67,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -67,7 +67,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
virtual void GuestWebContentsAttached( virtual void GuestWebContentsAttached(
content::WebContents* guest_web_contents, content::WebContents* guest_web_contents,
content::WebContents* embedder_web_contents, content::WebContents* embedder_web_contents,
int browser_plugin_instance_id,
const base::DictionaryValue& extra_params) OVERRIDE; const base::DictionaryValue& extra_params) OVERRIDE;
virtual void RenderProcessHostCreated( virtual void RenderProcessHostCreated(
content::RenderProcessHost* host) OVERRIDE; content::RenderProcessHost* host) OVERRIDE;
......
...@@ -21,7 +21,6 @@ class ExtensionRendererState { ...@@ -21,7 +21,6 @@ class ExtensionRendererState {
struct WebViewInfo { struct WebViewInfo {
int embedder_process_id; int embedder_process_id;
int embedder_routing_id; int embedder_routing_id;
int guest_instance_id;
int instance_id; int instance_id;
}; };
......
...@@ -67,13 +67,12 @@ GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) { ...@@ -67,13 +67,12 @@ GuestView* GuestView::From(int embedder_process_id, int guest_instance_id) {
void GuestView::Attach(content::WebContents* embedder_web_contents, void GuestView::Attach(content::WebContents* embedder_web_contents,
const std::string& extension_id, const std::string& extension_id,
int view_instance_id,
const base::DictionaryValue& args) { const base::DictionaryValue& args) {
embedder_web_contents_ = embedder_web_contents; embedder_web_contents_ = embedder_web_contents;
embedder_render_process_id_ = embedder_render_process_id_ =
embedder_web_contents->GetRenderProcessHost()->GetID(); embedder_web_contents->GetRenderProcessHost()->GetID();
extension_id_ = extension_id; extension_id_ = extension_id;
view_instance_id_ = view_instance_id; args.GetInteger(guestview::kParameterInstanceId, &view_instance_id_);
std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_); std::pair<int, int> key(embedder_render_process_id_, guest_instance_id_);
embedder_guestview_map.Get().insert(std::make_pair(key, this)); embedder_guestview_map.Get().insert(std::make_pair(key, this));
......
...@@ -48,7 +48,6 @@ class GuestView : public content::BrowserPluginGuestDelegate { ...@@ -48,7 +48,6 @@ class GuestView : public content::BrowserPluginGuestDelegate {
virtual void Attach(content::WebContents* embedder_web_contents, virtual void Attach(content::WebContents* embedder_web_contents,
const std::string& extension_id, const std::string& extension_id,
int view_instance_id,
const base::DictionaryValue& args); const base::DictionaryValue& args);
content::WebContents* embedder_web_contents() const { content::WebContents* embedder_web_contents() const {
......
...@@ -11,8 +11,9 @@ const char kIsTopLevel[] = "isTopLevel"; ...@@ -11,8 +11,9 @@ const char kIsTopLevel[] = "isTopLevel";
const char kReason[] = "reason"; const char kReason[] = "reason";
const char kUrl[] = "url"; const char kUrl[] = "url";
// Attributes. // Initialization parameters.
const char kAttributeApi[] = "api"; const char kParameterApi[] = "api";
const char kParameterInstanceId[] = "instanceId";
// Other. // Other.
const int kInstanceIDNone = 0; const int kInstanceIDNone = 0;
......
...@@ -14,8 +14,9 @@ extern const char kIsTopLevel[]; ...@@ -14,8 +14,9 @@ extern const char kIsTopLevel[];
extern const char kReason[]; extern const char kReason[];
extern const char kUrl[]; extern const char kUrl[];
// Attributes. // Initialization parameters.
extern const char kAttributeApi[]; extern const char kParameterApi[];
extern const char kParameterInstanceId[];
// Other. // Other.
extern const int kInstanceIDNone; extern const int kInstanceIDNone;
......
...@@ -80,10 +80,9 @@ WebViewGuest* WebViewGuest::From(int embedder_process_id, ...@@ -80,10 +80,9 @@ WebViewGuest* WebViewGuest::From(int embedder_process_id,
void WebViewGuest::Attach(WebContents* embedder_web_contents, void WebViewGuest::Attach(WebContents* embedder_web_contents,
const std::string& extension_id, const std::string& extension_id,
int view_instance_id,
const base::DictionaryValue& args) { const base::DictionaryValue& args) {
GuestView::Attach( GuestView::Attach(
embedder_web_contents, extension_id, view_instance_id, args); embedder_web_contents, extension_id, args);
AddWebViewToExtensionRendererState(); AddWebViewToExtensionRendererState();
} }
...@@ -317,7 +316,6 @@ void WebViewGuest::AddWebViewToExtensionRendererState() { ...@@ -317,7 +316,6 @@ void WebViewGuest::AddWebViewToExtensionRendererState() {
ExtensionRendererState::WebViewInfo webview_info; ExtensionRendererState::WebViewInfo webview_info;
webview_info.embedder_process_id = embedder_render_process_id(); webview_info.embedder_process_id = embedder_render_process_id();
webview_info.embedder_routing_id = embedder_web_contents()->GetRoutingID(); webview_info.embedder_routing_id = embedder_web_contents()->GetRoutingID();
webview_info.guest_instance_id = guest_instance_id();
webview_info.instance_id = view_instance_id(); webview_info.instance_id = view_instance_id();
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
......
...@@ -33,7 +33,6 @@ class WebViewGuest : public GuestView, ...@@ -33,7 +33,6 @@ class WebViewGuest : public GuestView,
// GuestView implementation. // GuestView implementation.
virtual void Attach(content::WebContents* embedder_web_contents, virtual void Attach(content::WebContents* embedder_web_contents,
const std::string& extension_id, const std::string& extension_id,
int view_instance_id,
const base::DictionaryValue& args) OVERRIDE; const base::DictionaryValue& args) OVERRIDE;
virtual GuestView::Type GetViewType() const OVERRIDE; virtual GuestView::Type GetViewType() const OVERRIDE;
virtual WebViewGuest* AsWebView() OVERRIDE; virtual WebViewGuest* AsWebView() OVERRIDE;
......
...@@ -18,6 +18,8 @@ var WEB_VIEW_EVENTS = { ...@@ -18,6 +18,8 @@ var WEB_VIEW_EVENTS = {
'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'], 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'],
}; };
var webViewInstanceIdCounter = 0;
var createEvent = function(name) { var createEvent = function(name) {
var eventOpts = {supportsListeners: true, supportsFilters: true}; var eventOpts = {supportsListeners: true, supportsFilters: true};
return new eventBindings.Event(name, undefined, eventOpts); return new eventBindings.Event(name, undefined, eventOpts);
...@@ -343,11 +345,13 @@ WebView.prototype.handleBrowserPluginAttributeMutation_ = function(mutation) { ...@@ -343,11 +345,13 @@ WebView.prototype.handleBrowserPluginAttributeMutation_ = function(mutation) {
*/ */
WebView.prototype.setupWebviewNodeEvents_ = function() { WebView.prototype.setupWebviewNodeEvents_ = function() {
var self = this; var self = this;
this.viewInstanceId_ = ++webViewInstanceIdCounter;
var onInstanceIdAllocated = function(e) { var onInstanceIdAllocated = function(e) {
var detail = e.detail ? JSON.parse(e.detail) : {}; var detail = e.detail ? JSON.parse(e.detail) : {};
self.instanceId_ = detail.windowId; self.instanceId_ = detail.windowId;
var params = { var params = {
'api': 'webview' 'api': 'webview',
'instanceId': self.viewInstanceId_
}; };
self.browserPluginNode_['-internal-attach'](params); self.browserPluginNode_['-internal-attach'](params);
......
...@@ -38,7 +38,7 @@ WebView.prototype.setupWebRequestEvents_ = function() { ...@@ -38,7 +38,7 @@ WebView.prototype.setupWebRequestEvents_ = function() {
'webview.' + webRequestEvent.name, 'webview.' + webRequestEvent.name,
webRequestEvent.parameters, webRequestEvent.parameters,
webRequestEvent.extraParameters, null, webRequestEvent.extraParameters, null,
self.browserPluginNode_.getInstanceId()); self.viewInstanceId_);
} }
return self[webRequestEvent.name + '_']; return self[webRequestEvent.name + '_'];
} }
......
...@@ -187,7 +187,6 @@ void BrowserPluginEmbedder::OnAttach( ...@@ -187,7 +187,6 @@ void BrowserPluginEmbedder::OnAttach(
GetContentClient()->browser()->GuestWebContentsAttached( GetContentClient()->browser()->GuestWebContentsAttached(
guest->GetWebContents(), guest->GetWebContents(),
web_contents(), web_contents(),
params.browser_plugin_instance_id,
extra_params); extra_params);
guest->Attach(static_cast<WebContentsImpl*>(web_contents()), params); guest->Attach(static_cast<WebContentsImpl*>(web_contents()), params);
return; return;
...@@ -202,7 +201,6 @@ void BrowserPluginEmbedder::OnAttach( ...@@ -202,7 +201,6 @@ void BrowserPluginEmbedder::OnAttach(
GetContentClient()->browser()->GuestWebContentsAttached( GetContentClient()->browser()->GuestWebContentsAttached(
guest->GetWebContents(), guest->GetWebContents(),
web_contents(), web_contents(),
params.browser_plugin_instance_id,
extra_params); extra_params);
guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params);
} }
......
...@@ -64,7 +64,6 @@ IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params) ...@@ -64,7 +64,6 @@ IPC_STRUCT_BEGIN(BrowserPluginHostMsg_ResizeGuest_Params)
IPC_STRUCT_END() IPC_STRUCT_END()
IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params) IPC_STRUCT_BEGIN(BrowserPluginHostMsg_Attach_Params)
IPC_STRUCT_MEMBER(int, browser_plugin_instance_id)
IPC_STRUCT_MEMBER(std::string, storage_partition_id) IPC_STRUCT_MEMBER(std::string, storage_partition_id)
IPC_STRUCT_MEMBER(bool, persist_storage) IPC_STRUCT_MEMBER(bool, persist_storage)
IPC_STRUCT_MEMBER(bool, focused) IPC_STRUCT_MEMBER(bool, focused)
......
...@@ -163,7 +163,6 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -163,7 +163,6 @@ class CONTENT_EXPORT ContentBrowserClient {
virtual void GuestWebContentsAttached( virtual void GuestWebContentsAttached(
WebContents* guest_web_contents, WebContents* guest_web_contents,
WebContents* embedder_web_contents, WebContents* embedder_web_contents,
int browser_plugin_instance_id,
const base::DictionaryValue& extra_params) {} const base::DictionaryValue& extra_params) {}
// Notifies that a RenderProcessHost has been created. This is called before // Notifies that a RenderProcessHost has been created. This is called before
......
...@@ -91,10 +91,8 @@ static base::LazyInstance<PluginContainerMap> g_plugin_container_map = ...@@ -91,10 +91,8 @@ static base::LazyInstance<PluginContainerMap> g_plugin_container_map =
BrowserPlugin::BrowserPlugin( BrowserPlugin::BrowserPlugin(
RenderViewImpl* render_view, RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebPluginParams& params, const WebPluginParams& params)
int instance_id)
: guest_instance_id_(browser_plugin::kInstanceIDNone), : guest_instance_id_(browser_plugin::kInstanceIDNone),
instance_id_(instance_id),
render_view_(render_view->AsWeakPtr()), render_view_(render_view->AsWeakPtr()),
render_view_routing_id_(render_view->GetRoutingID()), render_view_routing_id_(render_view->GetRoutingID()),
container_(NULL), container_(NULL),
...@@ -397,7 +395,6 @@ void BrowserPlugin::OnInstanceIDAllocated(int guest_instance_id) { ...@@ -397,7 +395,6 @@ void BrowserPlugin::OnInstanceIDAllocated(int guest_instance_id) {
void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) { void BrowserPlugin::Attach(scoped_ptr<base::DictionaryValue> extra_params) {
BrowserPluginHostMsg_Attach_Params attach_params; BrowserPluginHostMsg_Attach_Params attach_params;
attach_params.browser_plugin_instance_id = instance_id_;
attach_params.focused = ShouldGuestBeFocused(); attach_params.focused = ShouldGuestBeFocused();
attach_params.visible = visible_; attach_params.visible = visible_;
attach_params.name = GetNameAttribute(); attach_params.name = GetNameAttribute();
......
...@@ -40,7 +40,6 @@ class CONTENT_EXPORT BrowserPlugin : ...@@ -40,7 +40,6 @@ class CONTENT_EXPORT BrowserPlugin :
RenderViewImpl* render_view() const { return render_view_.get(); } RenderViewImpl* render_view() const { return render_view_.get(); }
int render_view_routing_id() const { return render_view_routing_id_; } int render_view_routing_id() const { return render_view_routing_id_; }
int guest_instance_id() const { return guest_instance_id_; } int guest_instance_id() const { return guest_instance_id_; }
int instance_id() const { return instance_id_; }
static BrowserPlugin* FromContainer(WebKit::WebPluginContainer* container); static BrowserPlugin* FromContainer(WebKit::WebPluginContainer* container);
...@@ -219,8 +218,7 @@ class CONTENT_EXPORT BrowserPlugin : ...@@ -219,8 +218,7 @@ class CONTENT_EXPORT BrowserPlugin :
BrowserPlugin( BrowserPlugin(
RenderViewImpl* render_view, RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params, const WebKit::WebPluginParams& params);
int instance_id);
virtual ~BrowserPlugin(); virtual ~BrowserPlugin();
...@@ -336,9 +334,6 @@ class CONTENT_EXPORT BrowserPlugin : ...@@ -336,9 +334,6 @@ class CONTENT_EXPORT BrowserPlugin :
// This is the browser-process-allocated instance ID that uniquely identifies // This is the browser-process-allocated instance ID that uniquely identifies
// a guest WebContents. // a guest WebContents.
int guest_instance_id_; int guest_instance_id_;
// This is a render-process-allocated instance ID that uniquely identifies a
// BrowserPlugin.
int instance_id_;
base::WeakPtr<RenderViewImpl> render_view_; base::WeakPtr<RenderViewImpl> render_view_;
// We cache the |render_view_|'s routing ID because we need it on destruction. // We cache the |render_view_|'s routing ID because we need it on destruction.
// If the |render_view_| is destroyed before the BrowserPlugin is destroyed // If the |render_view_| is destroyed before the BrowserPlugin is destroyed
......
...@@ -284,26 +284,6 @@ class BrowserPluginBindingAttachWindowTo : public BrowserPluginMethodBinding { ...@@ -284,26 +284,6 @@ class BrowserPluginBindingAttachWindowTo : public BrowserPluginMethodBinding {
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttachWindowTo); DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingAttachWindowTo);
}; };
// Note: This is a method that is used internally by the <webview> shim only.
// This should not be exposed to developers.
class BrowserPluginBindingGetInstanceID : public BrowserPluginMethodBinding {
public:
BrowserPluginBindingGetInstanceID()
: BrowserPluginMethodBinding(browser_plugin::kMethodGetInstanceId, 0) {
}
virtual bool Invoke(BrowserPluginBindings* bindings,
const NPVariant* args,
NPVariant* result) OVERRIDE {
int instance_id = bindings->instance()->instance_id();
INT32_TO_NPVARIANT(instance_id, *result);
return true;
}
private:
DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindingGetInstanceID);
};
// Note: This is a method that is used internally by the <webview> shim only. // Note: This is a method that is used internally by the <webview> shim only.
// This should not be exposed to developers. // This should not be exposed to developers.
class BrowserPluginBindingGetGuestInstanceID : class BrowserPluginBindingGetGuestInstanceID :
...@@ -731,7 +711,6 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance) ...@@ -731,7 +711,6 @@ BrowserPluginBindings::BrowserPluginBindings(BrowserPlugin* instance)
method_bindings_.push_back(new BrowserPluginBindingAttach); method_bindings_.push_back(new BrowserPluginBindingAttach);
method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo); method_bindings_.push_back(new BrowserPluginBindingAttachWindowTo);
method_bindings_.push_back(new BrowserPluginBindingGetInstanceID);
method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID); method_bindings_.push_back(new BrowserPluginBindingGetGuestInstanceID);
method_bindings_.push_back(new BrowserPluginBindingSetPermission); method_bindings_.push_back(new BrowserPluginBindingSetPermission);
method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime); method_bindings_.push_back(new BrowserPluginBindingTrackObjectLifetime);
......
...@@ -192,7 +192,7 @@ TEST_F(BrowserPluginTest, InitialResize) { ...@@ -192,7 +192,7 @@ TEST_F(BrowserPluginTest, InitialResize) {
EXPECT_EQ(480, params.resize_guest_params.view_rect.height()); EXPECT_EQ(480, params.resize_guest_params.view_rect.height());
ASSERT_TRUE(browser_plugin); ASSERT_TRUE(browser_plugin);
// Now the browser plugin is expecting a UpdateRect resize. // Now the browser plugin is expecting a UpdateRect resize.
int instance_id = browser_plugin->instance_id(); int instance_id = browser_plugin->guest_instance_id();
EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get());
// Send the BrowserPlugin an UpdateRect equal to its container size with // Send the BrowserPlugin an UpdateRect equal to its container size with
...@@ -289,7 +289,7 @@ TEST_F(BrowserPluginTest, ResizeFlowControl) { ...@@ -289,7 +289,7 @@ TEST_F(BrowserPluginTest, ResizeFlowControl) {
LoadHTML(GetHTMLForBrowserPluginObject().c_str()); LoadHTML(GetHTMLForBrowserPluginObject().c_str());
MockBrowserPlugin* browser_plugin = GetCurrentPlugin(); MockBrowserPlugin* browser_plugin = GetCurrentPlugin();
ASSERT_TRUE(browser_plugin); ASSERT_TRUE(browser_plugin);
int instance_id = browser_plugin->instance_id(); int instance_id = browser_plugin->guest_instance_id();
EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get()); EXPECT_TRUE(browser_plugin->pending_damage_buffer_.get());
// Send an UpdateRect to the BrowserPlugin to make it use the pending damage // Send an UpdateRect to the BrowserPlugin to make it use the pending damage
// buffer. // buffer.
......
...@@ -16,7 +16,7 @@ namespace content { ...@@ -16,7 +16,7 @@ namespace content {
BrowserPluginManagerImpl::BrowserPluginManagerImpl( BrowserPluginManagerImpl::BrowserPluginManagerImpl(
RenderViewImpl* render_view) RenderViewImpl* render_view)
: BrowserPluginManager(render_view), : BrowserPluginManager(render_view),
browser_plugin_instance_id_counter_(0) { request_id_counter_(0) {
} }
BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { BrowserPluginManagerImpl::~BrowserPluginManagerImpl() {
...@@ -26,17 +26,16 @@ BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( ...@@ -26,17 +26,16 @@ BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin(
RenderViewImpl* render_view, RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) { const WebKit::WebPluginParams& params) {
return new BrowserPlugin(render_view, frame, params, return new BrowserPlugin(render_view, frame, params);
++browser_plugin_instance_id_counter_);
} }
void BrowserPluginManagerImpl::AllocateInstanceID( void BrowserPluginManagerImpl::AllocateInstanceID(
BrowserPlugin* browser_plugin) { BrowserPlugin* browser_plugin) {
int instance_id = browser_plugin->instance_id(); int request_id = ++request_id_counter_;
pending_allocate_guest_instance_id_requests_.AddWithID(browser_plugin, pending_allocate_guest_instance_id_requests_.AddWithID(browser_plugin,
instance_id); request_id);
Send(new BrowserPluginHostMsg_AllocateInstanceID( Send(new BrowserPluginHostMsg_AllocateInstanceID(
browser_plugin->render_view_routing_id(), instance_id)); browser_plugin->render_view_routing_id(), request_id));
} }
bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { bool BrowserPluginManagerImpl::Send(IPC::Message* msg) {
...@@ -78,15 +77,13 @@ void BrowserPluginManagerImpl::DidCommitCompositorFrame() { ...@@ -78,15 +77,13 @@ void BrowserPluginManagerImpl::DidCommitCompositorFrame() {
void BrowserPluginManagerImpl::OnAllocateInstanceIDACK( void BrowserPluginManagerImpl::OnAllocateInstanceIDACK(
const IPC::Message& message, const IPC::Message& message,
int browser_plugin_instance_id, int request_id,
int guest_instance_id) { int guest_instance_id) {
BrowserPlugin* plugin = BrowserPlugin* plugin =
pending_allocate_guest_instance_id_requests_.Lookup( pending_allocate_guest_instance_id_requests_.Lookup(request_id);
browser_plugin_instance_id);
if (!plugin) if (!plugin)
return; return;
pending_allocate_guest_instance_id_requests_.Remove( pending_allocate_guest_instance_id_requests_.Remove(request_id);
browser_plugin_instance_id);
plugin->OnInstanceIDAllocated(guest_instance_id); plugin->OnInstanceIDAllocated(guest_instance_id);
} }
......
...@@ -45,7 +45,7 @@ class BrowserPluginManagerImpl : public BrowserPluginManager { ...@@ -45,7 +45,7 @@ class BrowserPluginManagerImpl : public BrowserPluginManager {
int request_id, int request_id,
const gfx::Point& position); const gfx::Point& position);
int browser_plugin_instance_id_counter_; int request_id_counter_;
IDMap<BrowserPlugin> pending_allocate_guest_instance_id_requests_; IDMap<BrowserPlugin> pending_allocate_guest_instance_id_requests_;
DISALLOW_COPY_AND_ASSIGN(BrowserPluginManagerImpl); DISALLOW_COPY_AND_ASSIGN(BrowserPluginManagerImpl);
......
...@@ -9,9 +9,8 @@ namespace content { ...@@ -9,9 +9,8 @@ namespace content {
MockBrowserPlugin::MockBrowserPlugin(RenderViewImpl* render_view, MockBrowserPlugin::MockBrowserPlugin(RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params, const WebKit::WebPluginParams& params)
int instance_id) : BrowserPlugin(render_view, frame, params) {
: BrowserPlugin(render_view, frame, params, instance_id) {
} }
MockBrowserPlugin::~MockBrowserPlugin() {} MockBrowserPlugin::~MockBrowserPlugin() {}
......
...@@ -13,8 +13,7 @@ class MockBrowserPlugin : public BrowserPlugin { ...@@ -13,8 +13,7 @@ class MockBrowserPlugin : public BrowserPlugin {
public: public:
MockBrowserPlugin(RenderViewImpl* render_view, MockBrowserPlugin(RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params, const WebKit::WebPluginParams& params);
int instance_id);
virtual ~MockBrowserPlugin(); virtual ~MockBrowserPlugin();
......
...@@ -14,7 +14,6 @@ namespace content { ...@@ -14,7 +14,6 @@ namespace content {
MockBrowserPluginManager::MockBrowserPluginManager( MockBrowserPluginManager::MockBrowserPluginManager(
RenderViewImpl* render_view) RenderViewImpl* render_view)
: BrowserPluginManager(render_view), : BrowserPluginManager(render_view),
browser_plugin_instance_id_counter_(0),
guest_instance_id_counter_(0) { guest_instance_id_counter_(0) {
} }
...@@ -25,8 +24,7 @@ BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( ...@@ -25,8 +24,7 @@ BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin(
RenderViewImpl* render_view, RenderViewImpl* render_view,
WebKit::WebFrame* frame, WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params) { const WebKit::WebPluginParams& params) {
int instance_id = ++browser_plugin_instance_id_counter_; return new MockBrowserPlugin(render_view, frame, params);
return new MockBrowserPlugin(render_view, frame, params, instance_id);
} }
void MockBrowserPluginManager::AllocateInstanceID( void MockBrowserPluginManager::AllocateInstanceID(
......
...@@ -40,7 +40,6 @@ class MockBrowserPluginManager : public BrowserPluginManager { ...@@ -40,7 +40,6 @@ class MockBrowserPluginManager : public BrowserPluginManager {
// The last known good deserializer for sync messages. // The last known good deserializer for sync messages.
scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_;
int browser_plugin_instance_id_counter_;
int guest_instance_id_counter_; int guest_instance_id_counter_;
DISALLOW_COPY_AND_ASSIGN(MockBrowserPluginManager); DISALLOW_COPY_AND_ASSIGN(MockBrowserPluginManager);
......
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