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

Unified Diff: remoting/host/register_support_host_request.cc

Issue 2925733003: Report signling errors for register-support-host requests. (Closed)
Patch Set: Fix memory leak Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/it2me/it2me_host_unittest.cc ('k') | remoting/host/register_support_host_request_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d4617d52a1e568b114eef4aa8c82c4a7f522e0ef 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.
+constexpr int kRegisterRequestTimeoutInSeconds = 10;
}
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_) {
+ std::string error_message =
+ "Error sending the register-support-host request.";
+ 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,11 +157,15 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
std::string* error_message) {
std::ostringstream error;
+ if (!response) {
+ *error_message = "register-support-host request timed out.";
+ return;
+ }
+
std::string type = response->Attr(buzz::QN_TYPE);
if (type == buzz::STR_ERROR) {
error << "Received error in response to heartbeat: " << response->Str();
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -155,7 +173,6 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
if (type != buzz::STR_RESULT) {
error << "Received unexpect stanza of type \"" << type << "\"";
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -166,7 +183,6 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
<< "> is missing in the host registration response: "
<< response->Str();
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -177,7 +193,6 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
<< "> is missing in the host registration response: "
<< response->Str();
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -189,7 +204,6 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
<< "> is missing in the host registration response: "
<< response->Str();
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -200,7 +214,6 @@ void RegisterSupportHostRequest::ParseResponse(const XmlElement* response,
<< "> is malformed in the host registration response: "
<< response->Str();
*error_message = error.str();
- LOG(ERROR) << *error_message;
return;
}
@@ -215,6 +228,9 @@ void RegisterSupportHostRequest::ProcessResponse(IqRequest* request,
base::TimeDelta lifetime;
std::string error_message;
ParseResponse(response, &support_id, &lifetime, &error_message);
+ if (!error_message.empty()) {
+ LOG(ERROR) << error_message;
+ }
CallCallback(support_id, lifetime, error_message);
}
« no previous file with comments | « remoting/host/it2me/it2me_host_unittest.cc ('k') | remoting/host/register_support_host_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698