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

Side by Side Diff: remoting/host/plugin/host_script_object.cc

Issue 11018004: Fix ChromotingHost and DesktopEnvironmentFactory references to TaskRunners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 "remoting/host/plugin/host_script_object.h" 5 #include "remoting/host/plugin/host_script_object.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 NPP plugin, 87 NPP plugin,
88 NPObject* parent, 88 NPObject* parent,
89 PluginThreadTaskRunner::Delegate* plugin_thread_delegate) 89 PluginThreadTaskRunner::Delegate* plugin_thread_delegate)
90 : plugin_(plugin), 90 : plugin_(plugin),
91 parent_(parent), 91 parent_(parent),
92 am_currently_logging_(false), 92 am_currently_logging_(false),
93 state_(kDisconnected), 93 state_(kDisconnected),
94 np_thread_id_(base::PlatformThread::CurrentId()), 94 np_thread_id_(base::PlatformThread::CurrentId()),
95 plugin_task_runner_( 95 plugin_task_runner_(
96 new PluginThreadTaskRunner(plugin_thread_delegate)), 96 new PluginThreadTaskRunner(plugin_thread_delegate)),
97 desktop_environment_factory_(new DesktopEnvironmentFactory()),
98 failed_login_attempts_(0), 97 failed_login_attempts_(0),
99 disconnected_event_(true, false), 98 disconnected_event_(true, false),
100 stopped_event_(true, false), 99 stopped_event_(true, false),
101 nat_traversal_enabled_(false), 100 nat_traversal_enabled_(false),
102 policy_received_(false), 101 policy_received_(false),
103 daemon_controller_(DaemonController::Create()), 102 daemon_controller_(DaemonController::Create()),
104 worker_thread_("RemotingHostPlugin") { 103 worker_thread_("RemotingHostPlugin") {
105 worker_thread_.Start(); 104 worker_thread_.Start();
106 } 105 }
107 106
108 HostNPScriptObject::~HostNPScriptObject() { 107 HostNPScriptObject::~HostNPScriptObject() {
109 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); 108 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
110 109
111 HostLogHandler::UnregisterLoggingScriptObject(this); 110 HostLogHandler::UnregisterLoggingScriptObject(this);
112 111
113 // Stop the message loop. Any attempt to post a task to 112 // Stop the message loop. Any attempt to post a task to
114 // |context_.ui_task_runner()| will result in a CHECK() after this point. 113 // |host_context_.ui_task_runner()| will result in a CHECK() after this point.
115 // TODO(alexeypa): Enable posting messages to |plugin_task_runner_| during 114 // TODO(alexeypa): Enable posting messages to |plugin_task_runner_| during
116 // shutdown to avoid this hack. 115 // shutdown to avoid this hack.
117 plugin_task_runner_->Detach(); 116 plugin_task_runner_->Detach();
118 117
119 // Stop listening for policy updates. 118 // Stop listening for policy updates.
120 if (policy_watcher_.get()) { 119 if (policy_watcher_.get()) {
121 base::WaitableEvent policy_watcher_stopped_(true, false); 120 base::WaitableEvent policy_watcher_stopped_(true, false);
122 policy_watcher_->StopWatching(&policy_watcher_stopped_); 121 policy_watcher_->StopWatching(&policy_watcher_stopped_);
123 policy_watcher_stopped_.Wait(); 122 policy_watcher_stopped_.Wait();
124 policy_watcher_.reset(); 123 policy_watcher_.reset();
(...skipping 29 matching lines...) Expand all
154 host_context_.reset(); 153 host_context_.reset();
155 } 154 }
156 155
157 worker_thread_.Stop(); 156 worker_thread_.Stop();
158 } 157 }
159 158
160 bool HostNPScriptObject::Init() { 159 bool HostNPScriptObject::Init() {
161 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 160 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
162 VLOG(2) << "Init"; 161 VLOG(2) << "Init";
163 162
163 // Create threads for the Chromoting host & desktop environment to use.
164 host_context_.reset(new ChromotingHostContext(new AutoThreadTaskRunner( 164 host_context_.reset(new ChromotingHostContext(new AutoThreadTaskRunner(
165 plugin_task_runner_, 165 plugin_task_runner_,
166 base::Bind(&base::WaitableEvent::Signal, 166 base::Bind(&base::WaitableEvent::Signal,
167 base::Unretained(&stopped_event_))))); 167 base::Unretained(&stopped_event_)))));
168 if (!host_context_->Start()) { 168 if (!host_context_->Start()) {
169 host_context_.reset(); 169 host_context_.reset();
170 return false; 170 return false;
171 } 171 }
172 172
173 // Create the desktop environment factory.
174 desktop_environment_factory_.reset(new DesktopEnvironmentFactory(
175 host_context_->input_task_runner(), host_context_->ui_task_runner()));
176
177 // Start monitoring configured policies.
173 policy_watcher_.reset( 178 policy_watcher_.reset(
174 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); 179 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner()));
175 policy_watcher_->StartWatching( 180 policy_watcher_->StartWatching(
176 base::Bind(&HostNPScriptObject::OnPolicyUpdate, 181 base::Bind(&HostNPScriptObject::OnPolicyUpdate,
177 base::Unretained(this))); 182 base::Unretained(this)));
178 return true; 183 return true;
179 } 184 }
180 185
181 bool HostNPScriptObject::HasMethod(const std::string& method_name) { 186 bool HostNPScriptObject::HasMethod(const std::string& method_name) {
182 VLOG(2) << "HasMethod " << method_name; 187 VLOG(2) << "HasMethod " << method_name;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 nat_traversal_enabled_ ? 584 nat_traversal_enabled_ ?
580 NetworkSettings::NAT_TRAVERSAL_ENABLED : 585 NetworkSettings::NAT_TRAVERSAL_ENABLED :
581 NetworkSettings::NAT_TRAVERSAL_DISABLED); 586 NetworkSettings::NAT_TRAVERSAL_DISABLED);
582 if (!nat_traversal_enabled_) { 587 if (!nat_traversal_enabled_) {
583 network_settings.min_port = NetworkSettings::kDefaultMinPort; 588 network_settings.min_port = NetworkSettings::kDefaultMinPort;
584 network_settings.max_port = NetworkSettings::kDefaultMaxPort; 589 network_settings.max_port = NetworkSettings::kDefaultMaxPort;
585 } 590 }
586 591
587 // Create the host. 592 // Create the host.
588 host_ = new ChromotingHost( 593 host_ = new ChromotingHost(
589 host_context_.get(), signal_strategy_.get(), 594 signal_strategy_.get(),
590 desktop_environment_factory_.get(), 595 desktop_environment_factory_.get(),
591 CreateHostSessionManager(network_settings, 596 CreateHostSessionManager(network_settings,
592 host_context_->url_request_context_getter())); 597 host_context_->url_request_context_getter()),
598 host_context_->capture_task_runner(),
599 host_context_->encode_task_runner(),
600 host_context_->network_task_runner());
593 host_->AddStatusObserver(this); 601 host_->AddStatusObserver(this);
594 log_to_server_.reset( 602 log_to_server_.reset(
595 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get())); 603 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get()));
596 604
597 // Disable audio by default. 605 // Disable audio by default.
598 // TODO(sergeyu): Add UI to enable it. 606 // TODO(sergeyu): Add UI to enable it.
599 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = 607 scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
600 protocol::CandidateSessionConfig::CreateDefault(); 608 protocol::CandidateSessionConfig::CreateDefault();
601 protocol::CandidateSessionConfig::DisableAudioChannel(protocol_config.get()); 609 protocol::CandidateSessionConfig::DisableAudioChannel(protocol_config.get());
602 host_->set_protocol_config(protocol_config.Pass()); 610 host_->set_protocol_config(protocol_config.Pass());
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 return is_good; 1329 return is_good;
1322 } 1330 }
1323 1331
1324 void HostNPScriptObject::SetException(const std::string& exception_string) { 1332 void HostNPScriptObject::SetException(const std::string& exception_string) {
1325 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 1333 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
1326 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); 1334 g_npnetscape_funcs->setexception(parent_, exception_string.c_str());
1327 LOG(INFO) << exception_string; 1335 LOG(INFO) << exception_string;
1328 } 1336 }
1329 1337
1330 } // namespace remoting 1338 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698