| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef REMOTING_HOST_GCD_STATE_UPDATER_H_ | 5 #ifndef REMOTING_HOST_GCD_STATE_UPDATER_H_ |
| 6 #define REMOTING_HOST_GCD_STATE_UPDATER_H_ | 6 #define REMOTING_HOST_GCD_STATE_UPDATER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class GcdStateUpdater : public SignalStrategy::Listener { | 29 class GcdStateUpdater : public SignalStrategy::Listener { |
| 30 public: | 30 public: |
| 31 // |signal_strategy| must outlive this object. Updates will start | 31 // |signal_strategy| must outlive this object. Updates will start |
| 32 // when the supplied SignalStrategy enters the CONNECTED state. | 32 // when the supplied SignalStrategy enters the CONNECTED state. |
| 33 // | 33 // |
| 34 // |on_update_successful_callback| is invoked after the first successful | 34 // |on_update_successful_callback| is invoked after the first successful |
| 35 // update. | 35 // update. |
| 36 GcdStateUpdater(const base::Closure& on_update_successful_callback, | 36 GcdStateUpdater(const base::Closure& on_update_successful_callback, |
| 37 const base::Closure& on_unknown_host_id_error, | 37 const base::Closure& on_unknown_host_id_error, |
| 38 SignalStrategy* signal_strategy, | 38 SignalStrategy* signal_strategy, |
| 39 GcdRestClient* gcd_client); | 39 scoped_ptr<GcdRestClient> gcd_client); |
| 40 ~GcdStateUpdater() override; | 40 ~GcdStateUpdater() override; |
| 41 | 41 |
| 42 // See HeartbeatSender::SetHostOfflineReason. | 42 // See HeartbeatSender::SetHostOfflineReason. |
| 43 void SetHostOfflineReason( | 43 void SetHostOfflineReason( |
| 44 const std::string& host_offline_reason, | 44 const std::string& host_offline_reason, |
| 45 const base::TimeDelta& timeout, | 45 const base::TimeDelta& timeout, |
| 46 const base::Callback<void(bool success)>& ack_callback); | 46 const base::Callback<void(bool success)>& ack_callback); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // SignalStrategy::Listener interface. | 49 // SignalStrategy::Listener interface. |
| 50 void OnSignalStrategyStateChange(SignalStrategy::State state) override; | 50 void OnSignalStrategyStateChange(SignalStrategy::State state) override; |
| 51 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; | 51 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; |
| 52 | 52 |
| 53 void OnPatchStateStatus(GcdRestClient::Status status); | 53 void OnPatchStateStatus(GcdRestClient::Status status); |
| 54 void MaybeSendStateUpdate(); | 54 void MaybeSendStateUpdate(); |
| 55 | 55 |
| 56 base::Closure on_update_successful_callback_; | 56 base::Closure on_update_successful_callback_; |
| 57 base::Closure on_unknown_host_id_error_; | 57 base::Closure on_unknown_host_id_error_; |
| 58 SignalStrategy* signal_strategy_; | 58 SignalStrategy* signal_strategy_; |
| 59 GcdRestClient* gcd_rest_client_; | 59 scoped_ptr<GcdRestClient> gcd_rest_client_; |
| 60 BackoffTimer timer_; | 60 BackoffTimer timer_; |
| 61 base::ThreadChecker thread_checker_; | 61 base::ThreadChecker thread_checker_; |
| 62 bool has_pending_state_request_ = false; | 62 bool has_pending_state_request_ = false; |
| 63 std::string pending_request_jid_; | 63 std::string pending_request_jid_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(GcdStateUpdater); | 65 DISALLOW_COPY_AND_ASSIGN(GcdStateUpdater); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace remoting | 68 } // namespace remoting |
| 69 | 69 |
| 70 #endif // REMOTING_HOST_GCD_STATE_UPDATER_H_ | 70 #endif // REMOTING_HOST_GCD_STATE_UPDATER_H_ |
| OLD | NEW |