| OLD | NEW |
| 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/plugin_module.h" | 5 #include "webkit/plugins/ppapi/plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 const FilePath& path, | 412 const FilePath& path, |
| 413 PluginDelegate::ModuleLifetime* lifetime_delegate) | 413 PluginDelegate::ModuleLifetime* lifetime_delegate) |
| 414 : lifetime_delegate_(lifetime_delegate), | 414 : lifetime_delegate_(lifetime_delegate), |
| 415 callback_tracker_(new ::ppapi::CallbackTracker), | 415 callback_tracker_(new ::ppapi::CallbackTracker), |
| 416 is_in_destructor_(false), | 416 is_in_destructor_(false), |
| 417 is_crashed_(false), | 417 is_crashed_(false), |
| 418 broker_(NULL), | 418 broker_(NULL), |
| 419 library_(NULL), | 419 library_(NULL), |
| 420 name_(name), | 420 name_(name), |
| 421 path_(path), | 421 path_(path), |
| 422 reserve_instance_id_(NULL) { | 422 reserve_instance_id_(NULL), |
| 423 nacl_ipc_proxy_(false) { |
| 423 // Ensure the globals object is created. | 424 // Ensure the globals object is created. |
| 424 if (!host_globals) | 425 if (!host_globals) |
| 425 host_globals = new HostGlobals; | 426 host_globals = new HostGlobals; |
| 426 | 427 |
| 427 memset(&entry_points_, 0, sizeof(entry_points_)); | 428 memset(&entry_points_, 0, sizeof(entry_points_)); |
| 428 pp_module_ = HostGlobals::Get()->AddModule(this); | 429 pp_module_ = HostGlobals::Get()->AddModule(this); |
| 429 GetMainThreadMessageLoop(); // Initialize the main thread message loop. | 430 GetMainThreadMessageLoop(); // Initialize the main thread message loop. |
| 430 GetLivePluginSet()->insert(this); | 431 GetLivePluginSet()->insert(this); |
| 431 } | 432 } |
| 432 | 433 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 return true; | 490 return true; |
| 490 } | 491 } |
| 491 | 492 |
| 492 void PluginModule::InitAsProxied( | 493 void PluginModule::InitAsProxied( |
| 493 PluginDelegate::OutOfProcessProxy* out_of_process_proxy) { | 494 PluginDelegate::OutOfProcessProxy* out_of_process_proxy) { |
| 494 DCHECK(!out_of_process_proxy_.get()); | 495 DCHECK(!out_of_process_proxy_.get()); |
| 495 out_of_process_proxy_.reset(out_of_process_proxy); | 496 out_of_process_proxy_.reset(out_of_process_proxy); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void PluginModule::InitAsProxiedNaCl( | 499 void PluginModule::InitAsProxiedNaCl( |
| 499 PluginDelegate::OutOfProcessProxy* out_of_process_proxy, | 500 scoped_ptr<PluginDelegate::OutOfProcessProxy> out_of_process_proxy, |
| 500 PP_Instance instance) { | 501 PP_Instance instance) { |
| 501 InitAsProxied(out_of_process_proxy); | 502 // TODO(bbudge) We need to switch the mode of the PluginModule on a |
| 503 // per-instance basis. Fix this so out_of_process_proxy and other |
| 504 // state is stored in a map, indexed by instance. |
| 505 nacl_ipc_proxy_ = true; |
| 506 InitAsProxied(out_of_process_proxy.release()); |
| 502 // InitAsProxied (for the trusted/out-of-process case) initializes only the | 507 // InitAsProxied (for the trusted/out-of-process case) initializes only the |
| 503 // module, and one or more instances are added later. In this case, the | 508 // module, and one or more instances are added later. In this case, the |
| 504 // PluginInstance was already created as in-process, so we missed the proxy | 509 // PluginInstance was already created as in-process, so we missed the proxy |
| 505 // AddInstance step and must do it now. | 510 // AddInstance step and must do it now. |
| 506 out_of_process_proxy_->AddInstance(instance); | 511 out_of_process_proxy_->AddInstance(instance); |
| 507 | 512 |
| 508 // In NaCl, we need to tell the instance to reset itself as proxied. This will | 513 // In NaCl, we need to tell the instance to reset itself as proxied. This will |
| 509 // clear cached interface pointers and send DidCreate (etc) to the plugin | 514 // clear cached interface pointers and send DidCreate (etc) to the plugin |
| 510 // side of the proxy. | 515 // side of the proxy. |
| 511 PluginInstance* plugin_instance = host_globals->GetInstance(instance); | 516 PluginInstance* plugin_instance = host_globals->GetInstance(instance); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 558 } |
| 554 | 559 |
| 555 void PluginModule::InstanceCreated(PluginInstance* instance) { | 560 void PluginModule::InstanceCreated(PluginInstance* instance) { |
| 556 instances_.insert(instance); | 561 instances_.insert(instance); |
| 557 } | 562 } |
| 558 | 563 |
| 559 void PluginModule::InstanceDeleted(PluginInstance* instance) { | 564 void PluginModule::InstanceDeleted(PluginInstance* instance) { |
| 560 if (out_of_process_proxy_.get()) | 565 if (out_of_process_proxy_.get()) |
| 561 out_of_process_proxy_->RemoveInstance(instance->pp_instance()); | 566 out_of_process_proxy_->RemoveInstance(instance->pp_instance()); |
| 562 instances_.erase(instance); | 567 instances_.erase(instance); |
| 568 |
| 569 if (nacl_ipc_proxy_) { |
| 570 out_of_process_proxy_.reset(); |
| 571 reserve_instance_id_ = NULL; |
| 572 } |
| 563 } | 573 } |
| 564 | 574 |
| 565 scoped_refptr< ::ppapi::CallbackTracker> PluginModule::GetCallbackTracker() { | 575 scoped_refptr< ::ppapi::CallbackTracker> PluginModule::GetCallbackTracker() { |
| 566 return callback_tracker_; | 576 return callback_tracker_; |
| 567 } | 577 } |
| 568 | 578 |
| 569 void PluginModule::PluginCrashed() { | 579 void PluginModule::PluginCrashed() { |
| 570 DCHECK(!is_crashed_); // Should only get one notification. | 580 DCHECK(!is_crashed_); // Should only get one notification. |
| 571 is_crashed_ = true; | 581 is_crashed_ = true; |
| 572 | 582 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 int retval = entry_points.initialize_module(pp_module(), &GetInterface); | 616 int retval = entry_points.initialize_module(pp_module(), &GetInterface); |
| 607 if (retval != 0) { | 617 if (retval != 0) { |
| 608 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 618 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 609 return false; | 619 return false; |
| 610 } | 620 } |
| 611 return true; | 621 return true; |
| 612 } | 622 } |
| 613 | 623 |
| 614 } // namespace ppapi | 624 } // namespace ppapi |
| 615 } // namespace webkit | 625 } // namespace webkit |
| OLD | NEW |