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

Side by Side Diff: remoting/host/simple_host_process.cc

Issue 10106013: Chromoting: stopping the service if the host ID is permanently not recognized by the could. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cr feedback. Created 8 years, 8 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 // This is an application of a minimal host process in a Chromoting 5 // This is an application of a minimal host process in a Chromoting
6 // system. It serves the purpose of gluing different pieces together 6 // system. It serves the purpose of gluing different pieces together
7 // to make a functional host process for testing. 7 // to make a functional host process for testing.
8 // 8 //
9 // It peforms the following functionality: 9 // It peforms the following functionality:
10 // 1. Connect to the GTalk network and register the machine as a host. 10 // 1. Connect to the GTalk network and register the machine as a host.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 const char kVideoSwitchValueVerbatim[] = "verbatim"; 83 const char kVideoSwitchValueVerbatim[] = "verbatim";
84 const char kVideoSwitchValueZip[] = "zip"; 84 const char kVideoSwitchValueZip[] = "zip";
85 const char kVideoSwitchValueVp8[] = "vp8"; 85 const char kVideoSwitchValueVp8[] = "vp8";
86 const char kVideoSwitchValueVp8Rtp[] = "vp8rtp"; 86 const char kVideoSwitchValueVp8Rtp[] = "vp8rtp";
87 87
88 } // namespace 88 } // namespace
89 89
90 namespace remoting { 90 namespace remoting {
91 91
92 class SimpleHost { 92 class SimpleHost : public HeartbeatSender::Delegate {
93 public: 93 public:
94 SimpleHost() 94 SimpleHost()
95 : message_loop_(MessageLoop::TYPE_UI), 95 : message_loop_(MessageLoop::TYPE_UI),
96 file_io_thread_("FileIO"), 96 file_io_thread_("FileIO"),
97 context_(NULL, message_loop_.message_loop_proxy()), 97 context_(NULL, message_loop_.message_loop_proxy()),
98 fake_(false), 98 fake_(false),
99 is_it2me_(false) { 99 is_it2me_(false) {
100 context_.Start(); 100 context_.Start();
101 file_io_thread_.Start(); 101 file_io_thread_.Start();
102 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 102 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
103 } 103 }
104 104
105 // Overridden from HeartbeatSender::Delegate
106 virtual void OnUnknownHostIdError() OVERRIDE {
107 LOG(ERROR) << "Host ID not found.";
108 Shutdown();
109 }
110
105 int Run() { 111 int Run() {
106 FilePath config_path = GetConfigPath(); 112 FilePath config_path = GetConfigPath();
107 JsonHostConfig config(config_path); 113 JsonHostConfig config(config_path);
108 if (!config.Read()) { 114 if (!config.Read()) {
109 LOG(ERROR) << "Failed to read configuration file " 115 LOG(ERROR) << "Failed to read configuration file "
110 << config_path.value(); 116 << config_path.value();
111 return 1; 117 return 1;
112 } 118 }
113 119
114 if (!config.GetString(kHostIdConfigPath, &host_id_)) { 120 if (!config.GetString(kHostIdConfigPath, &host_id_)) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 245
240 if (protocol_config_.get()) { 246 if (protocol_config_.get()) {
241 host_->set_protocol_config(protocol_config_.release()); 247 host_->set_protocol_config(protocol_config_.release());
242 } 248 }
243 249
244 if (is_it2me_) { 250 if (is_it2me_) {
245 register_request_.reset(new RegisterSupportHostRequest( 251 register_request_.reset(new RegisterSupportHostRequest(
246 signal_strategy_.get(), &key_pair_, 252 signal_strategy_.get(), &key_pair_,
247 base::Bind(&SimpleHost::SetIT2MeAccessCode, host_, &key_pair_))); 253 base::Bind(&SimpleHost::SetIT2MeAccessCode, host_, &key_pair_)));
248 } else { 254 } else {
249 heartbeat_sender_.reset( 255 heartbeat_sender_.reset(new HeartbeatSender(
250 new HeartbeatSender(host_id_, signal_strategy_.get(), &key_pair_)); 256 this, host_id_, signal_strategy_.get(), &key_pair_));
251 } 257 }
252 258
253 host_->Start(); 259 host_->Start();
254 260
255 // Create a Me2Me authenticator factory. 261 // Create a Me2Me authenticator factory.
256 if (!is_it2me_) { 262 if (!is_it2me_) {
257 scoped_ptr<protocol::AuthenticatorFactory> factory( 263 scoped_ptr<protocol::AuthenticatorFactory> factory(
258 new protocol::Me2MeHostAuthenticatorFactory( 264 new protocol::Me2MeHostAuthenticatorFactory(
259 xmpp_login_, key_pair_.GenerateCertificate(), 265 xmpp_login_, key_pair_.GenerateCertificate(),
260 *key_pair_.private_key(), host_secret_hash_)); 266 *key_pair_.private_key(), host_secret_hash_));
261 host_->SetAuthenticatorFactory(factory.Pass()); 267 host_->SetAuthenticatorFactory(factory.Pass());
262 } 268 }
263 } 269 }
264 270
271 void Shutdown() {
272 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
273 }
274
265 MessageLoop message_loop_; 275 MessageLoop message_loop_;
266 base::Thread file_io_thread_; 276 base::Thread file_io_thread_;
267 ChromotingHostContext context_; 277 ChromotingHostContext context_;
268 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 278 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
269 279
270 FilePath config_path_; 280 FilePath config_path_;
271 bool fake_; 281 bool fake_;
272 bool is_it2me_; 282 bool is_it2me_;
273 NetworkSettings network_settings_; 283 NetworkSettings network_settings_;
274 scoped_ptr<CandidateSessionConfig> protocol_config_; 284 scoped_ptr<CandidateSessionConfig> protocol_config_;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 max_port < 0 || max_port > 65535) { 380 max_port < 0 || max_port > 65535) {
371 LOG(ERROR) << "Invalid max-port value: " << max_port 381 LOG(ERROR) << "Invalid max-port value: " << max_port
372 << ". Expected integer in range [0, 65535]."; 382 << ". Expected integer in range [0, 65535].";
373 return 1; 383 return 1;
374 } 384 }
375 simple_host.network_settings()->max_port = max_port; 385 simple_host.network_settings()->max_port = max_port;
376 } 386 }
377 387
378 return simple_host.Run(); 388 return simple_host.Run();
379 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698