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

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: Fix Windows build. 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
« no previous file with comments | « remoting/host/desktop_environment_factory.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 NPP plugin, 86 NPP plugin,
87 NPObject* parent, 87 NPObject* parent,
88 PluginThreadTaskRunner::Delegate* plugin_thread_delegate) 88 PluginThreadTaskRunner::Delegate* plugin_thread_delegate)
89 : plugin_(plugin), 89 : plugin_(plugin),
90 parent_(parent), 90 parent_(parent),
91 am_currently_logging_(false), 91 am_currently_logging_(false),
92 state_(kDisconnected), 92 state_(kDisconnected),
93 np_thread_id_(base::PlatformThread::CurrentId()), 93 np_thread_id_(base::PlatformThread::CurrentId()),
94 plugin_task_runner_( 94 plugin_task_runner_(
95 new PluginThreadTaskRunner(plugin_thread_delegate)), 95 new PluginThreadTaskRunner(plugin_thread_delegate)),
96 desktop_environment_factory_(new DesktopEnvironmentFactory()),
97 failed_login_attempts_(0), 96 failed_login_attempts_(0),
98 nat_traversal_enabled_(false), 97 nat_traversal_enabled_(false),
99 policy_received_(false), 98 policy_received_(false),
100 daemon_controller_(DaemonController::Create()), 99 daemon_controller_(DaemonController::Create()),
101 worker_thread_("RemotingHostPlugin") { 100 worker_thread_("RemotingHostPlugin") {
102 worker_thread_.Start(); 101 worker_thread_.Start();
103 } 102 }
104 103
105 HostNPScriptObject::~HostNPScriptObject() { 104 HostNPScriptObject::~HostNPScriptObject() {
106 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_); 105 CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
(...skipping 20 matching lines...) Expand all
127 126
128 // Stop all threads. 127 // Stop all threads.
129 host_context_.reset(); 128 host_context_.reset();
130 worker_thread_.Stop(); 129 worker_thread_.Stop();
131 } 130 }
132 131
133 bool HostNPScriptObject::Init() { 132 bool HostNPScriptObject::Init() {
134 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 133 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
135 VLOG(2) << "Init"; 134 VLOG(2) << "Init";
136 135
136 // Create threads for the Chromoting host & desktop environment to use.
137 scoped_refptr<AutoThreadTaskRunner> auto_plugin_task_runner = 137 scoped_refptr<AutoThreadTaskRunner> auto_plugin_task_runner =
138 new AutoThreadTaskRunner(plugin_task_runner_, 138 new AutoThreadTaskRunner(plugin_task_runner_,
139 base::Bind(&PluginThreadTaskRunner::Quit, 139 base::Bind(&PluginThreadTaskRunner::Quit,
140 plugin_task_runner_)); 140 plugin_task_runner_));
141 host_context_.reset(new ChromotingHostContext(auto_plugin_task_runner)); 141 host_context_.reset(new ChromotingHostContext(auto_plugin_task_runner));
142 auto_plugin_task_runner = NULL; 142 auto_plugin_task_runner = NULL;
143 if (!host_context_->Start()) { 143 if (!host_context_->Start()) {
144 host_context_.reset(); 144 host_context_.reset();
145 return false; 145 return false;
146 } 146 }
147 147
148 // Create the desktop environment factory.
149 desktop_environment_factory_.reset(new DesktopEnvironmentFactory(
150 host_context_->input_task_runner(), host_context_->ui_task_runner()));
151
152 // Start monitoring configured policies.
148 policy_watcher_.reset( 153 policy_watcher_.reset(
149 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner())); 154 policy_hack::PolicyWatcher::Create(host_context_->network_task_runner()));
150 policy_watcher_->StartWatching( 155 policy_watcher_->StartWatching(
151 base::Bind(&HostNPScriptObject::OnPolicyUpdate, 156 base::Bind(&HostNPScriptObject::OnPolicyUpdate,
152 base::Unretained(this))); 157 base::Unretained(this)));
153 return true; 158 return true;
154 } 159 }
155 160
156 bool HostNPScriptObject::HasMethod(const std::string& method_name) { 161 bool HostNPScriptObject::HasMethod(const std::string& method_name) {
157 VLOG(2) << "HasMethod " << method_name; 162 VLOG(2) << "HasMethod " << method_name;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 nat_traversal_enabled_ ? 559 nat_traversal_enabled_ ?
555 NetworkSettings::NAT_TRAVERSAL_ENABLED : 560 NetworkSettings::NAT_TRAVERSAL_ENABLED :
556 NetworkSettings::NAT_TRAVERSAL_DISABLED); 561 NetworkSettings::NAT_TRAVERSAL_DISABLED);
557 if (!nat_traversal_enabled_) { 562 if (!nat_traversal_enabled_) {
558 network_settings.min_port = NetworkSettings::kDefaultMinPort; 563 network_settings.min_port = NetworkSettings::kDefaultMinPort;
559 network_settings.max_port = NetworkSettings::kDefaultMaxPort; 564 network_settings.max_port = NetworkSettings::kDefaultMaxPort;
560 } 565 }
561 566
562 // Create the host. 567 // Create the host.
563 host_ = new ChromotingHost( 568 host_ = new ChromotingHost(
564 host_context_.get(), signal_strategy_.get(), 569 signal_strategy_.get(),
565 desktop_environment_factory_.get(), 570 desktop_environment_factory_.get(),
566 CreateHostSessionManager(network_settings, 571 CreateHostSessionManager(network_settings,
567 host_context_->url_request_context_getter())); 572 host_context_->url_request_context_getter()),
573 host_context_->capture_task_runner(),
574 host_context_->encode_task_runner(),
575 host_context_->network_task_runner());
568 host_->AddStatusObserver(this); 576 host_->AddStatusObserver(this);
569 log_to_server_.reset( 577 log_to_server_.reset(
570 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get())); 578 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get()));
571 579
572 // Disable audio by default. 580 // Disable audio by default.
573 // TODO(sergeyu): Add UI to enable it. 581 // TODO(sergeyu): Add UI to enable it.
574 scoped_ptr<protocol::CandidateSessionConfig> protocol_config = 582 scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
575 protocol::CandidateSessionConfig::CreateDefault(); 583 protocol::CandidateSessionConfig::CreateDefault();
576 protocol::CandidateSessionConfig::DisableAudioChannel(protocol_config.get()); 584 protocol::CandidateSessionConfig::DisableAudioChannel(protocol_config.get());
577 host_->set_protocol_config(protocol_config.Pass()); 585 host_->set_protocol_config(protocol_config.Pass());
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 return; 915 return;
908 } 916 }
909 917
910 // UI needs to be shut down on the UI thread before we destroy the 918 // UI needs to be shut down on the UI thread before we destroy the
911 // host context (because it depends on the context object), but 919 // host context (because it depends on the context object), but
912 // only after the host has been shut down (becase the UI object is 920 // only after the host has been shut down (becase the UI object is
913 // registered as status observer for the host, and we can't 921 // registered as status observer for the host, and we can't
914 // unregister it from this thread). 922 // unregister it from this thread).
915 it2me_host_user_interface_.reset(); 923 it2me_host_user_interface_.reset();
916 924
925 // Destroy the DesktopEnvironmentFactory, to free thread references.
926 desktop_environment_factory_.reset();
927
917 // Release the context's TaskRunner references for the threads, so they can 928 // Release the context's TaskRunner references for the threads, so they can
918 // exit when no objects need them. 929 // exit when no objects need them.
919 host_context_->ReleaseTaskRunners(); 930 host_context_->ReleaseTaskRunners();
920 } 931 }
921 932
922 void HostNPScriptObject::OnPolicyUpdate( 933 void HostNPScriptObject::OnPolicyUpdate(
923 scoped_ptr<base::DictionaryValue> policies) { 934 scoped_ptr<base::DictionaryValue> policies) {
924 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { 935 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) {
925 host_context_->network_task_runner()->PostTask( 936 host_context_->network_task_runner()->PostTask(
926 FROM_HERE, 937 FROM_HERE,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 return is_good; 1331 return is_good;
1321 } 1332 }
1322 1333
1323 void HostNPScriptObject::SetException(const std::string& exception_string) { 1334 void HostNPScriptObject::SetException(const std::string& exception_string) {
1324 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 1335 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
1325 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); 1336 g_npnetscape_funcs->setexception(parent_, exception_string.c_str());
1326 LOG(INFO) << exception_string; 1337 LOG(INFO) << exception_string;
1327 } 1338 }
1328 1339
1329 } // namespace remoting 1340 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_environment_factory.cc ('k') | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698