diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 22:55:06 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-23 22:55:06 +0000 |
commit | 25e7d39fc079c890423dd793562c72f506187e15 (patch) | |
tree | 3106d59520bf9dcf5a7d405e3ab6fb668ab9c614 /chrome/plugin/npobject_proxy.cc | |
parent | 28f2f4e32924ece8a74135178429eb8b10106e31 (diff) | |
download | chromium_src-25e7d39fc079c890423dd793562c72f506187e15.zip chromium_src-25e7d39fc079c890423dd793562c72f506187e15.tar.gz chromium_src-25e7d39fc079c890423dd793562c72f506187e15.tar.bz2 |
Fixes NPAPITester ui tests. I was trying to diagnose failing ui tests
and with page heap enabled these tests consistenly crashed on me. I've
no idea about this code, but this change fixed it. As far as I can
tell in some cases Send deletes the NPObjectProxy, so that any code
that attempts to access the proxy after the Send may crash.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/16418
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7452 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/npobject_proxy.cc')
-rw-r--r-- | chrome/plugin/npobject_proxy.cc | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index 9acde3d..7df4e5c 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -178,13 +178,18 @@ bool NPObjectProxy::NPInvokePrivate(NPP npp, // messages are pumped). msg->set_pump_messages_event(proxy->modal_dialog_event_); + HANDLE modal_dialog_event_handle = proxy->modal_dialog_event_; + proxy->Send(msg); + // Send may delete proxy. + proxy = NULL; + if (!result) return false; CreateNPVariant( - param_result, channel_copy, np_result, proxy->modal_dialog_event_); + param_result, channel_copy, np_result, modal_dialog_event_handle); return true; } @@ -203,6 +208,9 @@ bool NPObjectProxy::NPHasProperty(NPObject *obj, proxy->Send(new NPObjectMsg_HasProperty( proxy->route_id(), name_param, &result)); + // Send may delete proxy. + proxy = NULL; + return result; } @@ -229,13 +237,17 @@ bool NPObjectProxy::NPGetProperty(NPObject *obj, CreateNPIdentifierParam(name, &name_param); NPVariant_Param param; + HANDLE modal_dialog_event_handle = proxy->modal_dialog_event_; + scoped_refptr<PluginChannelBase> channel(proxy->channel_); proxy->Send(new NPObjectMsg_GetProperty( proxy->route_id(), name_param, ¶m, &result)); + // Send may delete proxy. + proxy = NULL; if (!result) return false; CreateNPVariant( - param, proxy->channel(), np_result, proxy->modal_dialog_event_); + param, channel.get(), np_result, modal_dialog_event_handle); return true; } @@ -257,6 +269,8 @@ bool NPObjectProxy::NPSetProperty(NPObject *obj, proxy->Send(new NPObjectMsg_SetProperty( proxy->route_id(), name_param, value_param, &result)); + // Send may delete proxy. + proxy = NULL; return result; } @@ -275,6 +289,8 @@ bool NPObjectProxy::NPRemoveProperty(NPObject *obj, NPVariant_Param param; proxy->Send(new NPObjectMsg_RemoveProperty( proxy->route_id(), name_param, &result)); + // Send may delete proxy. + proxy = NULL; return result; } @@ -287,6 +303,8 @@ void NPObjectProxy::NPPInvalidate(NPObject *obj) { } proxy->Send(new NPObjectMsg_Invalidate(proxy->route_id())); + // Send may delete proxy. + proxy = NULL; } bool NPObjectProxy::NPNEnumerate(NPObject *obj, @@ -301,6 +319,8 @@ bool NPObjectProxy::NPNEnumerate(NPObject *obj, std::vector<NPIdentifier_Param> value_param; proxy->Send(new NPObjectMsg_Enumeration( proxy->route_id(), &value_param, &result)); + // Send may delete proxy. + proxy = NULL; if (!result) return false; @@ -346,12 +366,16 @@ bool NPObjectProxy::NPNEvaluate(NPP npp, // Please refer to the comments in NPObjectProxy::NPInvokePrivate for // the reasoning behind setting the pump messages event in the sync message. msg->set_pump_messages_event(proxy->modal_dialog_event_); + scoped_refptr<PluginChannelBase> channel(proxy->channel_); + HANDLE modal_dialog_event_handle = proxy->modal_dialog_event_; proxy->Send(msg); + // Send may delete proxy. + proxy = NULL; if (!result) return false; CreateNPVariant( - result_param, proxy->channel(), result_var, proxy->modal_dialog_event_); + result_param, channel.get(), result_var, modal_dialog_event_handle); return true; } @@ -366,5 +390,7 @@ void NPObjectProxy::NPNSetException(NPObject *obj, std::string message_str(message); proxy->Send(new NPObjectMsg_SetException(proxy->route_id(), message_str)); + // Send may delete proxy. + proxy = NULL; } |