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

Unified Diff: remoting/host/heartbeat_sender.h

Issue 719983002: Reporting of policy errors via host-offline-reason: part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hor-nohoststatussender
Patch Set: Better callback currying. Created 6 years 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
Index: remoting/host/heartbeat_sender.h
diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h
index 73080be9a6d3683cf1cb3c2869214f3477206fe9..f0d180ed33bfc2e84d26d35dc97d64be8f03ad6a 100644
--- a/remoting/host/heartbeat_sender.h
+++ b/remoting/host/heartbeat_sender.h
@@ -19,6 +19,7 @@
namespace base {
class MessageLoopProxy;
+class TimeDelta;
} // namespace base
namespace buzz {
@@ -95,21 +96,24 @@ class HeartbeatSender : public SignalStrategy::Listener {
const base::Closure& on_unknown_host_id_error,
const std::string& host_id,
SignalStrategy* signal_strategy,
- scoped_refptr<RsaKeyPair> key_pair,
+ const scoped_refptr<const RsaKeyPair>& key_pair,
const std::string& directory_bot_jid);
~HeartbeatSender() override;
- // Sets host offline reason for future heartbeat stanzas,
- // as well as intiates sending a stanza right away.
+ // Sets host offline reason for future heartbeat stanzas, and initiates
+ // sending a stanza right away.
//
- // See rem:host-offline-reason class-level comments for discussion
- // of allowed values for |host_offline_reason| string.
+ // For discussion of allowed values for |host_offline_reason| argument,
+ // please see the description of rem:host-offline-reason xml attribute in
+ // the class-level comments above.
//
- // |ack_callback| will be called once, when the bot acks
- // receiving the |host_offline_reason|.
+ // |ack_callback| will be called once, when the bot acks receiving the
+ // |host_offline_reason| or when |timeout| is reached.
+ enum AckOrTimeout { Ack, Timeout };
Wez 2014/12/18 00:46:20 Why do we need this rather than a success/failure
Łukasz Anforowicz 2014/12/18 19:02:33 Done - I switched to bool.
void SetHostOfflineReason(
const std::string& host_offline_reason,
- const base::Closure& ack_callback);
+ const base::TimeDelta& timeout,
+ const base::Callback<void(AckOrTimeout)>& ack_callback);
// SignalStrategy::Listener interface.
void OnSignalStrategyStateChange(SignalStrategy::State state) override;
@@ -131,6 +135,7 @@ class HeartbeatSender : public SignalStrategy::Listener {
const buzz::XmlElement* response);
void SetInterval(int interval);
void SetSequenceId(int sequence_id);
+ void CallHostOfflineReasonAckCallback(AckOrTimeout ack_or_timeout);
// Helper methods used by DoSendStanza() to generate heartbeat stanzas.
scoped_ptr<buzz::XmlElement> CreateHeartbeatMessage();
@@ -140,7 +145,7 @@ class HeartbeatSender : public SignalStrategy::Listener {
base::Closure on_unknown_host_id_error_;
std::string host_id_;
SignalStrategy* signal_strategy_;
- scoped_refptr<RsaKeyPair> key_pair_;
+ scoped_refptr<const RsaKeyPair> key_pair_;
std::string directory_bot_jid_;
scoped_ptr<IqSender> iq_sender_;
scoped_ptr<IqRequest> request_;
@@ -153,7 +158,8 @@ class HeartbeatSender : public SignalStrategy::Listener {
bool heartbeat_succeeded_;
int failed_startup_heartbeat_count_;
std::string host_offline_reason_;
- base::Closure host_offline_reason_ack_callback_;
+ base::Callback<void(AckOrTimeout)> host_offline_reason_ack_callback_;
+ base::OneShotTimer<HeartbeatSender> host_offline_reason_timeout_timer_;
base::ThreadChecker thread_checker_;

Powered by Google App Engine
This is Rietveld 408576698