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 "remoting/host/plugin/host_script_object.h" | 5 #include "remoting/host/plugin/host_script_object.h" |
6 #include "remoting/host/plugin/daemon_controller.h" | 6 #include "remoting/host/plugin/daemon_controller.h" |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Stops all threads. | 108 // Stops all threads. |
109 host_context_.reset(); | 109 host_context_.reset(); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 bool HostNPScriptObject::Init() { | 113 bool HostNPScriptObject::Init() { |
114 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); | 114 DCHECK(plugin_message_loop_proxy_->BelongsToCurrentThread()); |
115 VLOG(2) << "Init"; | 115 VLOG(2) << "Init"; |
116 | 116 |
117 host_context_.reset(new ChromotingHostContext(plugin_message_loop_proxy_)); | 117 host_context_.reset(new ChromotingHostContext(NULL, |
| 118 plugin_message_loop_proxy_)); |
118 if (!host_context_->Start()) { | 119 if (!host_context_->Start()) { |
119 host_context_.reset(); | 120 host_context_.reset(); |
120 return false; | 121 return false; |
121 } | 122 } |
122 | 123 |
123 nat_policy_.reset( | 124 nat_policy_.reset( |
124 policy_hack::NatPolicy::Create(host_context_->network_message_loop())); | 125 policy_hack::NatPolicy::Create(host_context_->network_message_loop())); |
125 nat_policy_->StartWatching( | 126 nat_policy_->StartWatching( |
126 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate, | 127 base::Bind(&HostNPScriptObject::OnNatPolicyUpdate, |
127 base::Unretained(this))); | 128 base::Unretained(this))); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 &HostNPScriptObject::FinishConnectMainThread, base::Unretained(this), | 458 &HostNPScriptObject::FinishConnectMainThread, base::Unretained(this), |
458 uid, auth_token, auth_service)); | 459 uid, auth_token, auth_service)); |
459 return; | 460 return; |
460 } | 461 } |
461 | 462 |
462 // DesktopEnvironment must be initialized on the main thread. | 463 // DesktopEnvironment must be initialized on the main thread. |
463 // | 464 // |
464 // TODO(sergeyu): Fix DesktopEnvironment so that it can be created | 465 // TODO(sergeyu): Fix DesktopEnvironment so that it can be created |
465 // on either the UI or the network thread so that we can avoid | 466 // on either the UI or the network thread so that we can avoid |
466 // jumping to the main thread here. | 467 // jumping to the main thread here. |
467 desktop_environment_.reset(DesktopEnvironment::Create(host_context_.get())); | 468 desktop_environment_ = DesktopEnvironment::Create(host_context_.get()); |
468 | 469 |
469 FinishConnectNetworkThread(uid, auth_token, auth_service); | 470 FinishConnectNetworkThread(uid, auth_token, auth_service); |
470 } | 471 } |
471 | 472 |
472 void HostNPScriptObject::FinishConnectNetworkThread( | 473 void HostNPScriptObject::FinishConnectNetworkThread( |
473 const std::string& uid, | 474 const std::string& uid, |
474 const std::string& auth_token, | 475 const std::string& auth_token, |
475 const std::string& auth_service) { | 476 const std::string& auth_service) { |
476 if (!host_context_->network_message_loop()->BelongsToCurrentThread()) { | 477 if (!host_context_->network_message_loop()->BelongsToCurrentThread()) { |
477 host_context_->network_message_loop()->PostTask(FROM_HERE, base::Bind( | 478 host_context_->network_message_loop()->PostTask(FROM_HERE, base::Bind( |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 uint32_t argCount) { | 881 uint32_t argCount) { |
881 NPVariant np_result; | 882 NPVariant np_result; |
882 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, | 883 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, |
883 argCount, &np_result); | 884 argCount, &np_result); |
884 if (is_good) | 885 if (is_good) |
885 g_npnetscape_funcs->releasevariantvalue(&np_result); | 886 g_npnetscape_funcs->releasevariantvalue(&np_result); |
886 return is_good; | 887 return is_good; |
887 } | 888 } |
888 | 889 |
889 } // namespace remoting | 890 } // namespace remoting |
OLD | NEW |