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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10912060: Allow the NaCl IPC proxy to support multiple instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 live_plugin_objects_.swap(plugin_object_copy); 477 live_plugin_objects_.swap(plugin_object_copy);
478 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); 478 for (PluginObjectSet::iterator i = plugin_object_copy.begin();
479 i != plugin_object_copy.end(); ++i) 479 i != plugin_object_copy.end(); ++i)
480 delete *i; 480 delete *i;
481 481
482 if (lock_mouse_callback_) 482 if (lock_mouse_callback_)
483 TrackedCallback::ClearAndAbort(&lock_mouse_callback_); 483 TrackedCallback::ClearAndAbort(&lock_mouse_callback_);
484 484
485 delegate_->InstanceDeleted(this); 485 delegate_->InstanceDeleted(this);
486 module_->InstanceDeleted(this); 486 module_->InstanceDeleted(this);
487 // If we switched from the NaCl plugin module, notify it too.
488 if (nacl_module_.get())
489 nacl_module_->InstanceDeleted(this);
487 490
488 HostGlobals::Get()->InstanceDeleted(pp_instance_); 491 HostGlobals::Get()->InstanceDeleted(pp_instance_);
489 } 492 }
490 493
491 // NOTE: Any of these methods that calls into the plugin needs to take into 494 // NOTE: Any of these methods that calls into the plugin needs to take into
492 // account that the plugin may use Var to remove the <embed> from the DOM, which 495 // account that the plugin may use Var to remove the <embed> from the DOM, which
493 // will make the WebPluginImpl drop its reference, usually the last one. If a 496 // will make the WebPluginImpl drop its reference, usually the last one. If a
494 // method needs to access a member of the instance after the call has returned, 497 // method needs to access a member of the instance after the call has returned,
495 // then it needs to keep its own reference on the stack. 498 // then it needs to keep its own reference on the stack.
496 499
497 void PluginInstance::Delete() { 500 void PluginInstance::Delete() {
498 // Keep a reference on the stack. See NOTE above. 501 // Keep a reference on the stack. See NOTE above.
499 scoped_refptr<PluginInstance> ref(this); 502 scoped_refptr<PluginInstance> ref(this);
500 // Force the MessageChannel to release its "passthrough object" which should 503 // Force the MessageChannel to release its "passthrough object" which should
501 // release our last reference to the "InstanceObject" and will probably 504 // release our last reference to the "InstanceObject" and will probably
502 // destroy it. We want to do this prior to calling DidDestroy in case the 505 // destroy it. We want to do this prior to calling DidDestroy in case the
503 // destructor of the instance object tries to use the instance. 506 // destructor of the instance object tries to use the instance.
504 message_channel_->SetPassthroughObject(NULL); 507 message_channel_->SetPassthroughObject(NULL);
505 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling 508 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling
506 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, 509 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance,
507 // since there is little that it can do at this point. 510 // since there is little that it can do at this point.
508 if (nacl_plugin_instance_interface_.get()) 511 if (nacl_instance_interface_.get())
509 nacl_plugin_instance_interface_->DidDestroy(pp_instance()); 512 nacl_instance_interface_->DidDestroy(pp_instance());
510 else 513 else
511 instance_interface_->DidDestroy(pp_instance()); 514 instance_interface_->DidDestroy(pp_instance());
512 515
513 if (fullscreen_container_) { 516 if (fullscreen_container_) {
514 fullscreen_container_->Destroy(); 517 fullscreen_container_->Destroy();
515 fullscreen_container_ = NULL; 518 fullscreen_container_ = NULL;
516 } 519 }
517 container_ = NULL; 520 container_ = NULL;
518 } 521 }
519 522
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 components); 2520 components);
2518 } 2521 }
2519 2522
2520 PP_Var PluginInstance::GetPluginInstanceURL( 2523 PP_Var PluginInstance::GetPluginInstanceURL(
2521 PP_Instance instance, 2524 PP_Instance instance,
2522 PP_URLComponents_Dev* components) { 2525 PP_URLComponents_Dev* components) {
2523 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, 2526 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_,
2524 components); 2527 components);
2525 } 2528 }
2526 2529
2527 bool PluginInstance::ResetAsProxied() { 2530 bool PluginInstance::ResetAsProxied(scoped_refptr<PluginModule> module) {
2531 // Save the original module and switch over to the new one now that this
2532 // plugin is using the IPC-based proxy.
2533 nacl_module_.swap(module_);
dmichael (off chromium) 2012/09/04 21:21:33 What's the benefit of using swap()? Are you just t
bbudge 2012/09/05 19:15:48 Done.
2534 module_.swap(module);
2535
2528 // For NaCl instances, remember the NaCl plugin instance interface, so we 2536 // For NaCl instances, remember the NaCl plugin instance interface, so we
2529 // can shut it down by calling its DidDestroy in our Delete() method. 2537 // can shut it down by calling its DidDestroy in our Delete() method.
2530 nacl_plugin_instance_interface_.reset(instance_interface_.release()); 2538 nacl_instance_interface_.reset(instance_interface_.release());
2531 2539
2532 base::Callback<const void*(const char*)> get_plugin_interface_func = 2540 base::Callback<const void*(const char*)> get_plugin_interface_func =
2533 base::Bind(&PluginModule::GetPluginInterface, module_.get()); 2541 base::Bind(&PluginModule::GetPluginInterface, module_.get());
2534 PPP_Instance_Combined* ppp_instance_combined = 2542 PPP_Instance_Combined* ppp_instance_combined =
2535 PPP_Instance_Combined::Create(get_plugin_interface_func); 2543 PPP_Instance_Combined::Create(get_plugin_interface_func);
2536 if (!ppp_instance_combined) { 2544 if (!ppp_instance_combined) {
2537 // The proxy must support at least one usable PPP_Instance interface. 2545 // The proxy must support at least one usable PPP_Instance interface.
2538 NOTREACHED(); 2546 NOTREACHED();
2539 return false; 2547 return false;
2540 } 2548 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 screen_size_for_fullscreen_ = gfx::Size(); 2645 screen_size_for_fullscreen_ = gfx::Size();
2638 WebElement element = container_->element(); 2646 WebElement element = container_->element();
2639 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2647 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2640 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2648 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2641 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2649 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2642 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2650 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2643 } 2651 }
2644 2652
2645 } // namespace ppapi 2653 } // namespace ppapi
2646 } // namespace webkit 2654 } // namespace webkit
OLDNEW
« webkit/plugins/ppapi/ppapi_plugin_instance.h ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698