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 #ifndef REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ | 5 #ifndef REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ |
6 #define REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ | 6 #define REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // object. |callback| is called when registration response is | 43 // object. |callback| is called when registration response is |
44 // received from the server. Callback is never called if the bot | 44 // received from the server. Callback is never called if the bot |
45 // malfunctions and doesn't respond to the request. | 45 // malfunctions and doesn't respond to the request. |
46 // | 46 // |
47 // TODO(sergeyu): This class should have timeout for the bot | 47 // TODO(sergeyu): This class should have timeout for the bot |
48 // response. | 48 // response. |
49 RegisterSupportHostRequest(SignalStrategy* signal_strategy, | 49 RegisterSupportHostRequest(SignalStrategy* signal_strategy, |
50 scoped_refptr<RsaKeyPair> key_pair, | 50 scoped_refptr<RsaKeyPair> key_pair, |
51 const std::string& directory_bot_jid, | 51 const std::string& directory_bot_jid, |
52 const RegisterCallback& callback); | 52 const RegisterCallback& callback); |
53 virtual ~RegisterSupportHostRequest(); | 53 ~RegisterSupportHostRequest() override; |
54 | 54 |
55 // HostStatusObserver implementation. | 55 // HostStatusObserver implementation. |
56 virtual void OnSignalStrategyStateChange( | 56 void OnSignalStrategyStateChange(SignalStrategy::State state) override; |
57 SignalStrategy::State state) override; | 57 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; |
58 virtual bool OnSignalStrategyIncomingStanza( | |
59 const buzz::XmlElement* stanza) override; | |
60 | 58 |
61 private: | 59 private: |
62 void DoSend(); | 60 void DoSend(); |
63 | 61 |
64 scoped_ptr<buzz::XmlElement> CreateRegistrationRequest( | 62 scoped_ptr<buzz::XmlElement> CreateRegistrationRequest( |
65 const std::string& jid); | 63 const std::string& jid); |
66 scoped_ptr<buzz::XmlElement> CreateSignature(const std::string& jid); | 64 scoped_ptr<buzz::XmlElement> CreateSignature(const std::string& jid); |
67 | 65 |
68 void ProcessResponse(IqRequest* request, const buzz::XmlElement* response); | 66 void ProcessResponse(IqRequest* request, const buzz::XmlElement* response); |
69 bool ParseResponse(const buzz::XmlElement* response, | 67 bool ParseResponse(const buzz::XmlElement* response, |
70 std::string* support_id, base::TimeDelta* lifetime); | 68 std::string* support_id, base::TimeDelta* lifetime); |
71 | 69 |
72 void CallCallback( | 70 void CallCallback( |
73 bool success, const std::string& support_id, base::TimeDelta lifetime); | 71 bool success, const std::string& support_id, base::TimeDelta lifetime); |
74 | 72 |
75 SignalStrategy* signal_strategy_; | 73 SignalStrategy* signal_strategy_; |
76 scoped_refptr<RsaKeyPair> key_pair_; | 74 scoped_refptr<RsaKeyPair> key_pair_; |
77 std::string directory_bot_jid_; | 75 std::string directory_bot_jid_; |
78 RegisterCallback callback_; | 76 RegisterCallback callback_; |
79 | 77 |
80 scoped_ptr<IqSender> iq_sender_; | 78 scoped_ptr<IqSender> iq_sender_; |
81 scoped_ptr<IqRequest> request_; | 79 scoped_ptr<IqRequest> request_; |
82 | 80 |
83 DISALLOW_COPY_AND_ASSIGN(RegisterSupportHostRequest); | 81 DISALLOW_COPY_AND_ASSIGN(RegisterSupportHostRequest); |
84 }; | 82 }; |
85 | 83 |
86 } // namespace remoting | 84 } // namespace remoting |
87 | 85 |
88 #endif // REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ | 86 #endif // REMOTING_HOST_REGISTER_SUPPORT_HOST_REQUEST_H_ |
OLD | NEW |