Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/plugin/npobject_proxy.cc

Issue 155238: Add the page url to plugin crashes to aid debugging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/plugin/npobject_proxy.h ('k') | chrome/plugin/npobject_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/plugin/npobject_proxy.h" 5 #include "chrome/plugin/npobject_proxy.h"
6 6
7 #include "base/waitable_event.h" 7 #include "base/waitable_event.h"
8 #include "chrome/common/plugin_messages.h" 8 #include "chrome/common/plugin_messages.h"
9 #include "chrome/plugin/npobject_util.h" 9 #include "chrome/plugin/npobject_util.h"
10 #include "chrome/plugin/plugin_channel_base.h" 10 #include "chrome/plugin/plugin_channel_base.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 proxy = wrapper->proxy; 42 proxy = wrapper->proxy;
43 } 43 }
44 44
45 return proxy; 45 return proxy;
46 } 46 }
47 47
48 NPObjectProxy::NPObjectProxy( 48 NPObjectProxy::NPObjectProxy(
49 PluginChannelBase* channel, 49 PluginChannelBase* channel,
50 int route_id, 50 int route_id,
51 intptr_t npobject_ptr, 51 intptr_t npobject_ptr,
52 base::WaitableEvent* modal_dialog_event) 52 base::WaitableEvent* modal_dialog_event,
53 const GURL& page_url)
53 : channel_(channel), 54 : channel_(channel),
54 route_id_(route_id), 55 route_id_(route_id),
55 npobject_ptr_(npobject_ptr), 56 npobject_ptr_(npobject_ptr),
56 modal_dialog_event_(modal_dialog_event) { 57 modal_dialog_event_(modal_dialog_event),
58 page_url_(page_url) {
57 channel_->AddRoute(route_id, this, true); 59 channel_->AddRoute(route_id, this, true);
58 } 60 }
59 61
60 NPObjectProxy::~NPObjectProxy() { 62 NPObjectProxy::~NPObjectProxy() {
61 if (channel_.get()) { 63 if (channel_.get()) {
62 Send(new NPObjectMsg_Release(route_id_)); 64 Send(new NPObjectMsg_Release(route_id_));
63 if (channel_.get()) 65 if (channel_.get())
64 channel_->RemoveRoute(route_id_); 66 channel_->RemoveRoute(route_id_);
65 } 67 }
66 } 68 }
67 69
68 NPObject* NPObjectProxy::Create(PluginChannelBase* channel, 70 NPObject* NPObjectProxy::Create(PluginChannelBase* channel,
69 int route_id, 71 int route_id,
70 intptr_t npobject_ptr, 72 intptr_t npobject_ptr,
71 base::WaitableEvent* modal_dialog_event) { 73 base::WaitableEvent* modal_dialog_event,
74 const GURL& page_url) {
72 NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>( 75 NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>(
73 NPN_CreateObject(0, &npclass_proxy_)); 76 NPN_CreateObject(0, &npclass_proxy_));
74 obj->proxy = new NPObjectProxy( 77 obj->proxy = new NPObjectProxy(
75 channel, route_id, npobject_ptr, modal_dialog_event); 78 channel, route_id, npobject_ptr, modal_dialog_event, page_url);
76 79
77 return reinterpret_cast<NPObject*>(obj); 80 return reinterpret_cast<NPObject*>(obj);
78 } 81 }
79 82
80 bool NPObjectProxy::Send(IPC::Message* msg) { 83 bool NPObjectProxy::Send(IPC::Message* msg) {
81 if (channel_.get()) 84 if (channel_.get())
82 return channel_->Send(msg); 85 return channel_->Send(msg);
83 86
84 delete msg; 87 delete msg;
85 return false; 88 return false;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 CreateNPIdentifierParam(name, &name_param); 162 CreateNPIdentifierParam(name, &name_param);
160 } 163 }
161 164
162 // Note: This instance can get destroyed in the context of 165 // Note: This instance can get destroyed in the context of
163 // Send so addref the channel in this scope. 166 // Send so addref the channel in this scope.
164 scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_; 167 scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_;
165 std::vector<NPVariant_Param> args_param; 168 std::vector<NPVariant_Param> args_param;
166 for (unsigned int i = 0; i < arg_count; ++i) { 169 for (unsigned int i = 0; i < arg_count; ++i) {
167 NPVariant_Param param; 170 NPVariant_Param param;
168 CreateNPVariantParam( 171 CreateNPVariantParam(
169 args[i], channel_copy, &param, false, proxy->modal_dialog_event_); 172 args[i], channel_copy, &param, false, proxy->modal_dialog_event_,
173 proxy->page_url_);
170 args_param.push_back(param); 174 args_param.push_back(param);
171 } 175 }
172 176
173 NPVariant_Param param_result; 177 NPVariant_Param param_result;
174 NPObjectMsg_Invoke* msg = new NPObjectMsg_Invoke( 178 NPObjectMsg_Invoke* msg = new NPObjectMsg_Invoke(
175 proxy->route_id_, is_default, name_param, args_param, &param_result, 179 proxy->route_id_, is_default, name_param, args_param, &param_result,
176 &result); 180 &result);
177 181
178 // If we're in the plugin process and this invoke leads to a dialog box, the 182 // If we're in the plugin process and this invoke leads to a dialog box, the
179 // plugin will hang the window hierarchy unless we pump the window message 183 // plugin will hang the window hierarchy unless we pump the window message
180 // queue while waiting for a reply. We need to do this to simulate what 184 // queue while waiting for a reply. We need to do this to simulate what
181 // happens when everything runs in-process (while calling MessageBox window 185 // happens when everything runs in-process (while calling MessageBox window
182 // messages are pumped). 186 // messages are pumped).
183 msg->set_pump_messages_event(proxy->modal_dialog_event_); 187 msg->set_pump_messages_event(proxy->modal_dialog_event_);
184 188
185 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; 189 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
186 190
191 GURL page_url = proxy->page_url_;
187 proxy->Send(msg); 192 proxy->Send(msg);
188 193
189 // Send may delete proxy. 194 // Send may delete proxy.
190 proxy = NULL; 195 proxy = NULL;
191 196
192 if (!result) 197 if (!result)
193 return false; 198 return false;
194 199
195 CreateNPVariant( 200 CreateNPVariant(
196 param_result, channel_copy, np_result, modal_dialog_event_handle); 201 param_result, channel_copy, np_result, modal_dialog_event_handle,
202 page_url);
197 return true; 203 return true;
198 } 204 }
199 205
200 bool NPObjectProxy::NPHasProperty(NPObject *obj, 206 bool NPObjectProxy::NPHasProperty(NPObject *obj,
201 NPIdentifier name) { 207 NPIdentifier name) {
202 bool result = false; 208 bool result = false;
203 NPObjectProxy* proxy = GetProxy(obj); 209 NPObjectProxy* proxy = GetProxy(obj);
204 if (!proxy) { 210 if (!proxy) {
205 return obj->_class->hasProperty(obj, name); 211 return obj->_class->hasProperty(obj, name);
206 } 212 }
(...skipping 29 matching lines...) Expand all
236 if (!proxy) { 242 if (!proxy) {
237 return obj->_class->getProperty(obj, name, np_result); 243 return obj->_class->getProperty(obj, name, np_result);
238 } 244 }
239 245
240 NPIdentifier_Param name_param; 246 NPIdentifier_Param name_param;
241 CreateNPIdentifierParam(name, &name_param); 247 CreateNPIdentifierParam(name, &name_param);
242 248
243 NPVariant_Param param; 249 NPVariant_Param param;
244 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; 250 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
245 scoped_refptr<PluginChannelBase> channel(proxy->channel_); 251 scoped_refptr<PluginChannelBase> channel(proxy->channel_);
252
253 GURL page_url = proxy->page_url_;
246 proxy->Send(new NPObjectMsg_GetProperty( 254 proxy->Send(new NPObjectMsg_GetProperty(
247 proxy->route_id(), name_param, &param, &result)); 255 proxy->route_id(), name_param, &param, &result));
248 // Send may delete proxy. 256 // Send may delete proxy.
249 proxy = NULL; 257 proxy = NULL;
250 if (!result) 258 if (!result)
251 return false; 259 return false;
252 260
253 CreateNPVariant( 261 CreateNPVariant(
254 param, channel.get(), np_result, modal_dialog_event_handle); 262 param, channel.get(), np_result, modal_dialog_event_handle, page_url);
255 263
256 return true; 264 return true;
257 } 265 }
258 266
259 bool NPObjectProxy::NPSetProperty(NPObject *obj, 267 bool NPObjectProxy::NPSetProperty(NPObject *obj,
260 NPIdentifier name, 268 NPIdentifier name,
261 const NPVariant *value) { 269 const NPVariant *value) {
262 bool result = false; 270 bool result = false;
263 NPObjectProxy* proxy = GetProxy(obj); 271 NPObjectProxy* proxy = GetProxy(obj);
264 if (!proxy) { 272 if (!proxy) {
265 return obj->_class->setProperty(obj, name, value); 273 return obj->_class->setProperty(obj, name, value);
266 } 274 }
267 275
268 NPIdentifier_Param name_param; 276 NPIdentifier_Param name_param;
269 CreateNPIdentifierParam(name, &name_param); 277 CreateNPIdentifierParam(name, &name_param);
270 278
271 NPVariant_Param value_param; 279 NPVariant_Param value_param;
272 CreateNPVariantParam( 280 CreateNPVariantParam(
273 *value, proxy->channel(), &value_param, false, 281 *value, proxy->channel(), &value_param, false,
274 proxy->modal_dialog_event_); 282 proxy->modal_dialog_event_, proxy->page_url_);
275 283
276 proxy->Send(new NPObjectMsg_SetProperty( 284 proxy->Send(new NPObjectMsg_SetProperty(
277 proxy->route_id(), name_param, value_param, &result)); 285 proxy->route_id(), name_param, value_param, &result));
278 // Send may delete proxy. 286 // Send may delete proxy.
279 proxy = NULL; 287 proxy = NULL;
280 288
281 return result; 289 return result;
282 } 290 }
283 291
284 bool NPObjectProxy::NPRemoveProperty(NPObject *obj, 292 bool NPObjectProxy::NPRemoveProperty(NPObject *obj,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 359
352 bool result = false; 360 bool result = false;
353 361
354 // Note: This instance can get destroyed in the context of 362 // Note: This instance can get destroyed in the context of
355 // Send so addref the channel in this scope. 363 // Send so addref the channel in this scope.
356 scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_; 364 scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_;
357 std::vector<NPVariant_Param> args_param; 365 std::vector<NPVariant_Param> args_param;
358 for (unsigned int i = 0; i < arg_count; ++i) { 366 for (unsigned int i = 0; i < arg_count; ++i) {
359 NPVariant_Param param; 367 NPVariant_Param param;
360 CreateNPVariantParam( 368 CreateNPVariantParam(
361 args[i], channel_copy, &param, false, proxy->modal_dialog_event_); 369 args[i], channel_copy, &param, false, proxy->modal_dialog_event_,
370 proxy->page_url_);
362 args_param.push_back(param); 371 args_param.push_back(param);
363 } 372 }
364 373
365 NPVariant_Param param_result; 374 NPVariant_Param param_result;
366 NPObjectMsg_Construct* msg = new NPObjectMsg_Construct( 375 NPObjectMsg_Construct* msg = new NPObjectMsg_Construct(
367 proxy->route_id_, args_param, &param_result, &result); 376 proxy->route_id_, args_param, &param_result, &result);
368 377
369 // See comment in NPObjectProxy::NPInvokePrivate. 378 // See comment in NPObjectProxy::NPInvokePrivate.
370 msg->set_pump_messages_event(proxy->modal_dialog_event_); 379 msg->set_pump_messages_event(proxy->modal_dialog_event_);
371 380
372 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; 381 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
373 382
383 GURL page_url = proxy->page_url_;
374 proxy->Send(msg); 384 proxy->Send(msg);
375 385
376 // Send may delete proxy. 386 // Send may delete proxy.
377 proxy = NULL; 387 proxy = NULL;
378 388
379 if (!result) 389 if (!result)
380 return false; 390 return false;
381 391
382 CreateNPVariant( 392 CreateNPVariant(
383 param_result, channel_copy, np_result, modal_dialog_event_handle); 393 param_result, channel_copy, np_result, modal_dialog_event_handle,
394 page_url);
384 return true; 395 return true;
385 } 396 }
386 397
387 bool NPObjectProxy::NPNEvaluate(NPP npp, 398 bool NPObjectProxy::NPNEvaluate(NPP npp,
388 NPObject *obj, 399 NPObject *obj,
389 NPString *script, 400 NPString *script,
390 NPVariant *result_var) { 401 NPVariant *result_var) {
391 bool result = false; 402 bool result = false;
392 NPObjectProxy* proxy = GetProxy(obj); 403 NPObjectProxy* proxy = GetProxy(obj);
393 if (!proxy) { 404 if (!proxy) {
(...skipping 17 matching lines...) Expand all
411 script_str, 422 script_str,
412 popups_allowed, 423 popups_allowed,
413 &result_param, 424 &result_param,
414 &result); 425 &result);
415 426
416 // Please refer to the comments in NPObjectProxy::NPInvokePrivate for 427 // Please refer to the comments in NPObjectProxy::NPInvokePrivate for
417 // the reasoning behind setting the pump messages event in the sync message. 428 // the reasoning behind setting the pump messages event in the sync message.
418 msg->set_pump_messages_event(proxy->modal_dialog_event_); 429 msg->set_pump_messages_event(proxy->modal_dialog_event_);
419 scoped_refptr<PluginChannelBase> channel(proxy->channel_); 430 scoped_refptr<PluginChannelBase> channel(proxy->channel_);
420 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; 431 base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_;
432
433 GURL page_url = proxy->page_url_;
421 proxy->Send(msg); 434 proxy->Send(msg);
422 // Send may delete proxy. 435 // Send may delete proxy.
423 proxy = NULL; 436 proxy = NULL;
424 if (!result) 437 if (!result)
425 return false; 438 return false;
426 439
427 CreateNPVariant( 440 CreateNPVariant(
428 result_param, channel.get(), result_var, modal_dialog_event_handle); 441 result_param, channel.get(), result_var, modal_dialog_event_handle,
442 page_url);
429 return true; 443 return true;
430 } 444 }
431 445
432 void NPObjectProxy::NPNSetException(NPObject *obj, 446 void NPObjectProxy::NPNSetException(NPObject *obj,
433 const NPUTF8 *message) { 447 const NPUTF8 *message) {
434 NPObjectProxy* proxy = GetProxy(obj); 448 NPObjectProxy* proxy = GetProxy(obj);
435 if (!proxy) { 449 if (!proxy) {
436 return; 450 return;
437 } 451 }
438 452
439 NPVariant_Param result_param; 453 NPVariant_Param result_param;
440 std::string message_str(message); 454 std::string message_str(message);
441 455
442 proxy->Send(new NPObjectMsg_SetException(proxy->route_id(), message_str)); 456 proxy->Send(new NPObjectMsg_SetException(proxy->route_id(), message_str));
443 // Send may delete proxy. 457 // Send may delete proxy.
444 proxy = NULL; 458 proxy = NULL;
445 } 459 }
OLDNEW
« no previous file with comments | « chrome/plugin/npobject_proxy.h ('k') | chrome/plugin/npobject_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698