| Index: remoting/host/plugin/host_script_object.cc
|
| diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
|
| index 5357cfb65a59e5dc8f04c41ee3bc403709f88eac..7f714147dfea9a223e9b1fa6b7dd84c7d7d93702 100644
|
| --- a/remoting/host/plugin/host_script_object.cc
|
| +++ b/remoting/host/plugin/host_script_object.cc
|
| @@ -75,13 +75,19 @@ static bool g_logging_to_plugin = false;
|
| static HostNPScriptObject* g_logging_scriptable_object = NULL;
|
| static logging::LogMessageHandlerFunction g_logging_old_handler = NULL;
|
|
|
| -HostNPScriptObject::HostNPScriptObject(NPP plugin, NPObject* parent)
|
| +HostNPScriptObject::HostNPScriptObject(
|
| + NPP plugin,
|
| + NPObject* parent,
|
| + PluginMessageLoopProxy::Delegate* plugin_thread_delegate)
|
| : plugin_(plugin),
|
| parent_(parent),
|
| state_(kDisconnected),
|
| log_debug_info_func_(NULL),
|
| on_state_changed_func_(NULL),
|
| np_thread_id_(base::PlatformThread::CurrentId()),
|
| + plugin_message_loop_proxy_(
|
| + new PluginMessageLoopProxy(plugin_thread_delegate)),
|
| + host_context_(plugin_message_loop_proxy_),
|
| failed_login_attempts_(0),
|
| disconnected_event_(true, false) {
|
| // Set up log message handler.
|
| @@ -96,10 +102,6 @@ HostNPScriptObject::HostNPScriptObject(NPP plugin, NPObject* parent)
|
| g_logging_old_handler = logging::GetLogMessageHandler();
|
| logging::SetLogMessageHandler(&LogToUI);
|
| g_logging_scriptable_object = this;
|
| -
|
| - VLOG(2) << "HostNPScriptObject";
|
| - host_context_.SetUITaskPostFunction(base::Bind(
|
| - &HostNPScriptObject::PostTaskToNPThread, base::Unretained(this)));
|
| }
|
|
|
| HostNPScriptObject::~HostNPScriptObject() {
|
| @@ -113,11 +115,12 @@ HostNPScriptObject::~HostNPScriptObject() {
|
| g_logging_old_handler = NULL;
|
| g_logging_scriptable_object = NULL;
|
|
|
| + plugin_message_loop_proxy_->Detach();
|
| +
|
| // Disconnect synchronously. We cannot disconnect asynchronously
|
| // here because |host_context_| needs to be stopped on the plugin
|
| // thread, but the plugin thread may not exist after the instance
|
| // is destroyed.
|
| - destructing_.Set();
|
| disconnected_event_.Reset();
|
| DisconnectInternal();
|
| disconnected_event_.Wait();
|
| @@ -514,11 +517,8 @@ void HostNPScriptObject::OnReceivedSupportID(
|
| }
|
|
|
| void HostNPScriptObject::OnStateChanged(State state) {
|
| - if (destructing_.IsSet())
|
| - return;
|
| -
|
| - if (!host_context_.IsUIThread()) {
|
| - host_context_.PostTaskToUIThread(
|
| + if (!plugin_message_loop_proxy_->BelongsToCurrentThread()) {
|
| + plugin_message_loop_proxy_->PostTask(
|
| FROM_HERE, base::Bind(&HostNPScriptObject::OnStateChanged,
|
| base::Unretained(this), state));
|
| return;
|
| @@ -552,11 +552,8 @@ bool HostNPScriptObject::LogToUI(int severity, const char* file, int line,
|
| }
|
|
|
| void HostNPScriptObject::LogDebugInfo(const std::string& message) {
|
| - if (destructing_.IsSet())
|
| - return;
|
| -
|
| - if (!host_context_.IsUIThread()) {
|
| - host_context_.PostTaskToUIThread(
|
| + if (!plugin_message_loop_proxy_->BelongsToCurrentThread()) {
|
| + plugin_message_loop_proxy_->PostTask(
|
| FROM_HERE, base::Bind(&HostNPScriptObject::LogDebugInfo,
|
| base::Unretained(this), message));
|
| return;
|
| @@ -588,25 +585,4 @@ bool HostNPScriptObject::InvokeAndIgnoreResult(NPObject* func,
|
| return is_good;
|
| }
|
|
|
| -void HostNPScriptObject::PostTaskToNPThread(
|
| - const tracked_objects::Location& from_here, const base::Closure& task) {
|
| - // The NPAPI functions cannot make use of |from_here|, but this method is
|
| - // passed as a callback to ChromotingHostContext, so it needs to have the
|
| - // appropriate signature.
|
| -
|
| - // Copy task to the heap so that we can pass it to NPTaskSpringboard().
|
| - base::Closure* task_in_heap = new base::Closure(task);
|
| -
|
| - // Can be called from any thread.
|
| - g_npnetscape_funcs->pluginthreadasynccall(plugin_, &NPTaskSpringboard,
|
| - task_in_heap);
|
| -}
|
| -
|
| -// static
|
| -void HostNPScriptObject::NPTaskSpringboard(void* task) {
|
| - base::Closure* real_task = reinterpret_cast<base::Closure*>(task);
|
| - real_task->Run();
|
| - delete real_task;
|
| -}
|
| -
|
| } // namespace remoting
|
|
|