Chromium Code Reviews| Index: remoting/host/register_support_host_request.cc |
| diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc |
| index 95c8be50e074282a6c0d1be03375990407210f95..105d59e2d6dbe634993d3787aa3c535c6e7030a8 100644 |
| --- a/remoting/host/register_support_host_request.cc |
| +++ b/remoting/host/register_support_host_request.cc |
| @@ -16,6 +16,7 @@ |
| #include "remoting/base/constants.h" |
| #include "remoting/host/host_config.h" |
| #include "remoting/host/host_details.h" |
| +#include "remoting/protocol/errors.h" |
| #include "remoting/signaling/iq_sender.h" |
| #include "remoting/signaling/jid_util.h" |
| #include "remoting/signaling/signal_strategy.h" |
| @@ -42,6 +43,9 @@ const char kHostOsVersionTag[] = "host-os-version"; |
| const char kRegisterQueryResultTag[] = "register-support-host-result"; |
| const char kSupportIdTag[] = "support-id"; |
| const char kSupportIdLifetimeTag[] = "support-id-lifetime"; |
| + |
| +// The signaling timeout for register support host requests. |
| +const int kRegisterRequestTimeoutInSeconds = 10; |
|
Sergey Ulanov
2017/06/07 06:41:30
nit: use constexpr base::TimeDelta:
constexpr ba
kelvinp
2017/06/12 21:31:26
Done.
|
| } |
| RegisterSupportHostRequest::RegisterSupportHostRequest( |
| @@ -68,12 +72,22 @@ void RegisterSupportHostRequest::OnSignalStrategyStateChange( |
| SignalStrategy::State state) { |
| if (state == SignalStrategy::CONNECTED) { |
| DCHECK(!callback_.is_null()); |
| - |
| request_ = iq_sender_->SendIq( |
| buzz::STR_SET, directory_bot_jid_, |
| CreateRegistrationRequest(signal_strategy_->GetLocalAddress().jid()), |
| base::Bind(&RegisterSupportHostRequest::ProcessResponse, |
| base::Unretained(this))); |
| + if (!request_.get()) { |
|
Sergey Ulanov
2017/06/07 06:41:29
nit: don't need .get()
kelvinp
2017/06/12 21:31:25
Done.
|
| + std::string error_message = |
| + protocol::ErrorCodeToString(protocol::ErrorCode::SIGNALING_ERROR); |
|
Sergey Ulanov
2017/06/07 06:41:29
error_message should a human-readable message that
kelvinp
2017/06/12 21:31:26
Done.
|
| + LOG(ERROR) << error_message; |
| + CallCallback(std::string(), base::TimeDelta(), error_message); |
| + return; |
| + } |
| + |
| + request_->SetTimeout( |
| + base::TimeDelta::FromSeconds(kRegisterRequestTimeoutInSeconds)); |
| + |
| } else if (state == SignalStrategy::DISCONNECTED) { |
| // We will reach here if signaling fails to connect. |
| std::string error_message = "Signal strategy disconnected."; |
| @@ -143,6 +157,13 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response, |
| std::string* error_message) { |
| std::ostringstream error; |
| + if (!response) { |
| + *error_message = |
| + protocol::ErrorCodeToString(protocol::ErrorCode::SIGNALING_TIMEOUT); |
|
Sergey Ulanov
2017/06/07 06:41:30
same here. Use a readable message please.
kelvinp
2017/06/12 21:31:25
Done.
|
| + LOG(ERROR) << *error_message; |
|
Sergey Ulanov
2017/06/07 06:41:30
I don't think we need to log the message here. Or
kelvinp
2017/06/12 21:31:25
We log the error message in all other branches of
|
| + return; |
| + } |
| + |
| std::string type = response->Attr(buzz::QN_TYPE); |
| if (type == buzz::STR_ERROR) { |
| error << "Received error in response to heartbeat: " << response->Str(); |