Chromium Code Reviews| 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 | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 const char* kAttrNameDisconnected = "DISCONNECTED"; | 67 const char* kAttrNameDisconnected = "DISCONNECTED"; |
| 68 const char* kAttrNameStarting = "STARTING"; | 68 const char* kAttrNameStarting = "STARTING"; |
| 69 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE"; | 69 const char* kAttrNameRequestedAccessCode = "REQUESTED_ACCESS_CODE"; |
| 70 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE"; | 70 const char* kAttrNameReceivedAccessCode = "RECEIVED_ACCESS_CODE"; |
| 71 const char* kAttrNameConnected = "CONNECTED"; | 71 const char* kAttrNameConnected = "CONNECTED"; |
| 72 const char* kAttrNameDisconnecting = "DISCONNECTING"; | 72 const char* kAttrNameDisconnecting = "DISCONNECTING"; |
| 73 const char* kAttrNameError = "ERROR"; | 73 const char* kAttrNameError = "ERROR"; |
| 74 | 74 |
| 75 const int kMaxLoginAttempts = 5; | 75 const int kMaxLoginAttempts = 5; |
| 76 | 76 |
| 77 const int kMinPortNumber = 12400; | |
|
Sergey Ulanov
2012/08/22 23:50:34
Maybe put these values somewhere where they can be
Wez
2012/08/23 23:26:26
Done.
| |
| 78 const int kMaxPortNumber = 12409; | |
| 79 | |
| 77 // We may need to have more than one task running at the same time | 80 // We may need to have more than one task running at the same time |
| 78 // (e.g. key generation and status update), yet unlikely to ever need | 81 // (e.g. key generation and status update), yet unlikely to ever need |
| 79 // more than 2 threads. | 82 // more than 2 threads. |
| 80 const int kMaxWorkerPoolThreads = 2; | 83 const int kMaxWorkerPoolThreads = 2; |
| 81 | 84 |
| 82 } // namespace | 85 } // namespace |
| 83 | 86 |
| 84 HostNPScriptObject::HostNPScriptObject( | 87 HostNPScriptObject::HostNPScriptObject( |
| 85 NPP plugin, | 88 NPP plugin, |
| 86 NPObject* parent, | 89 NPObject* parent, |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 scoped_ptr<RegisterSupportHostRequest> register_request( | 572 scoped_ptr<RegisterSupportHostRequest> register_request( |
| 570 new RegisterSupportHostRequest( | 573 new RegisterSupportHostRequest( |
| 571 signal_strategy.get(), &host_key_pair_, | 574 signal_strategy.get(), &host_key_pair_, |
| 572 base::Bind(&HostNPScriptObject::OnReceivedSupportID, | 575 base::Bind(&HostNPScriptObject::OnReceivedSupportID, |
| 573 base::Unretained(this)))); | 576 base::Unretained(this)))); |
| 574 | 577 |
| 575 // Beyond this point nothing can fail, so save the config and request. | 578 // Beyond this point nothing can fail, so save the config and request. |
| 576 signal_strategy_.reset(signal_strategy.release()); | 579 signal_strategy_.reset(signal_strategy.release()); |
| 577 register_request_.reset(register_request.release()); | 580 register_request_.reset(register_request.release()); |
| 578 | 581 |
| 582 // If NAT traversal is off then limit port range to allow firewall pin-holing. | |
| 583 LOG(INFO) << "NAT state: " << nat_traversal_enabled_; | |
| 584 NetworkSettings network_settings( | |
| 585 nat_traversal_enabled_ ? | |
| 586 NetworkSettings::NAT_TRAVERSAL_ENABLED : | |
| 587 NetworkSettings::NAT_TRAVERSAL_DISABLED); | |
| 588 if (!nat_traversal_enabled_) { | |
| 589 network_settings.min_port = kMinPortNumber; | |
| 590 network_settings.max_port = kMaxPortNumber; | |
| 591 } | |
| 592 | |
| 579 // Create the Host. | 593 // Create the Host. |
| 580 LOG(INFO) << "NAT state: " << nat_traversal_enabled_; | |
| 581 host_ = new ChromotingHost( | 594 host_ = new ChromotingHost( |
| 582 host_context_.get(), signal_strategy_.get(), desktop_environment_.get(), | 595 host_context_.get(), signal_strategy_.get(), desktop_environment_.get(), |
| 583 CreateHostSessionManager( | 596 CreateHostSessionManager(network_settings, |
| 584 NetworkSettings(nat_traversal_enabled_ ? | 597 host_context_->url_request_context_getter())); |
| 585 NetworkSettings::NAT_TRAVERSAL_ENABLED : | |
| 586 NetworkSettings::NAT_TRAVERSAL_DISABLED), | |
| 587 host_context_->url_request_context_getter())); | |
| 588 host_->AddStatusObserver(this); | 598 host_->AddStatusObserver(this); |
| 589 log_to_server_.reset( | 599 log_to_server_.reset( |
| 590 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get())); | 600 new LogToServer(host_, ServerLogEntry::IT2ME, signal_strategy_.get())); |
| 591 base::Closure disconnect_callback = base::Bind( | 601 base::Closure disconnect_callback = base::Bind( |
| 592 &ChromotingHost::Shutdown, base::Unretained(host_.get()), | 602 &ChromotingHost::Shutdown, base::Unretained(host_.get()), |
| 593 base::Closure()); | 603 base::Closure()); |
| 594 it2me_host_user_interface_->Start(host_.get(), disconnect_callback); | 604 it2me_host_user_interface_->Start(host_.get(), disconnect_callback); |
| 595 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName); | 605 host_event_logger_ = HostEventLogger::Create(host_, kApplicationName); |
| 596 | 606 |
| 597 { | 607 { |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 return is_good; | 1301 return is_good; |
| 1292 } | 1302 } |
| 1293 | 1303 |
| 1294 void HostNPScriptObject::SetException(const std::string& exception_string) { | 1304 void HostNPScriptObject::SetException(const std::string& exception_string) { |
| 1295 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 1305 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
| 1296 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); | 1306 g_npnetscape_funcs->setexception(parent_, exception_string.c_str()); |
| 1297 LOG(INFO) << exception_string; | 1307 LOG(INFO) << exception_string; |
| 1298 } | 1308 } |
| 1299 | 1309 |
| 1300 } // namespace remoting | 1310 } // namespace remoting |
| OLD | NEW |