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

Side by Side Diff: remoting/host/register_support_host_request.h

Issue 9004050: Move signaling connection creation out of ChromotingHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/jingle_glue/signal_strategy.h"
13 #include "remoting/host/host_key_pair.h" 14 #include "remoting/host/host_key_pair.h"
14 #include "remoting/host/host_status_observer.h"
15 #include "testing/gtest/include/gtest/gtest_prod.h" 15 #include "testing/gtest/include/gtest/gtest_prod.h"
16 16
17 class MessageLoop; 17 class MessageLoop;
18 18
19 namespace buzz { 19 namespace buzz {
20 class XmlElement; 20 class XmlElement;
21 } // namespace buzz 21 } // namespace buzz
22 22
23 namespace base { 23 namespace base {
24 class TimeDelta; 24 class TimeDelta;
25 } // namespace base 25 } // namespace base
26 26
27 namespace remoting { 27 namespace remoting {
28 28
29 class IqRequest; 29 class IqRequest;
30 class IqSender; 30 class IqSender;
31 31
32 // RegisterSupportHostRequest sends support host registeration request 32 // RegisterSupportHostRequest sends support host registeration request
33 // to the Chromoting Bot. It listens to the status of the host using 33 // to the Chromoting Bot. It listens to signalling channel status and
34 // HostStatusObserver interface and sends the request when signalling 34 // sends the request when signalling channel is connected. When a
Wez 2012/01/03 16:25:04 nit: ... sends a request to register the host for
Sergey Ulanov 2012/01/03 21:51:02 Done.
35 // channel is connected. When a response is received from the bot, it 35 // response is received from the bot, it calls the callback specified
36 // calls the callback specified in the Init() method. 36 // in the Init() method.
37 class RegisterSupportHostRequest : public HostStatusObserver { 37 class RegisterSupportHostRequest : public SignalStrategy::Listener {
38 public: 38 public:
39 // First parameter is set to true on success. Second parameter is 39 // First parameter is set to true on success. Second parameter is
40 // the new SessionID received from the bot. Third parameter is the 40 // the new SessionID received from the bot. Third parameter is the
41 // amount of time until that id expires. 41 // amount of time until that id expires.
Wez 2012/01/03 16:25:04 nit: Could use a zero time-to-expiry to indicate f
Sergey Ulanov 2012/01/03 21:51:02 I think that using a separate parameter is cleaner
42 typedef base::Callback<void(bool, const std::string&, 42 typedef base::Callback<void(bool, const std::string&,
43 const base::TimeDelta&)> RegisterCallback; 43 const base::TimeDelta&)> RegisterCallback;
44 44
45 RegisterSupportHostRequest(); 45 RegisterSupportHostRequest();
46 virtual ~RegisterSupportHostRequest(); 46 virtual ~RegisterSupportHostRequest();
47 47
48 // Provide the configuration to use to register the host, and a 48 // Provide the configuration to use to register the host, and a
Wez 2012/01/03 16:25:04 nit: Initializes the registration to use a supplie
Sergey Ulanov 2012/01/03 21:51:02 Done.
49 // callback to invoke when a registration response is received. 49 // callback to invoke when a registration response is received.
50 // |callback| is called when registration response is received from 50 // |callback| is called when registration response is received from
51 // the server. Ownership of |callback| is given to the request 51 // the server. Returns false on falure (e.g. config is
52 // object. Caller must ensure that the callback object is valid 52 // invalid). Callback is never called if the bot malfunctions and
Wez 2012/01/03 16:25:04 nit: Would it simplify the interface to notify the
Sergey Ulanov 2012/01/03 21:51:02 Having result here is useful to detect config erro
53 // while signalling connection exists. Returns false on falure 53 // doesn't respond to the request.
Wez 2012/01/03 16:25:04 If the caller is responsible for implementing a se
Sergey Ulanov 2012/01/03 21:51:02 Normally GTalk would reply with an error when the
54 // (e.g. config is invalid). Callback is never called if the bot 54 bool Init(SignalStrategy* signal_strategy_,
55 // malfunctions and doesn't respond to the request. 55 HostConfig* config,
56 bool Init(HostConfig* config, const RegisterCallback& callback); 56 const RegisterCallback& callback);
57 57
58 // HostStatusObserver implementation. 58 // HostStatusObserver implementation.
59 virtual void OnSignallingConnected(SignalStrategy* signal_strategy) OVERRIDE; 59 virtual void OnSignalStrategyStateChange(
60 virtual void OnSignallingDisconnected() OVERRIDE; 60 SignalStrategy::State state) OVERRIDE;
61 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; 61 virtual bool OnSignalStrategyIncomingStanza(
62 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; 62 const buzz::XmlElement* stanza) OVERRIDE;
63 virtual void OnAccessDenied() OVERRIDE;
64 virtual void OnShutdown() OVERRIDE;
65 63
66 private: 64 private:
67 void DoSend(); 65 void DoSend();
68 66
69 // Caller owns the result. 67 // Caller owns the result.
70 buzz::XmlElement* CreateRegistrationRequest(const std::string& jid); 68 buzz::XmlElement* CreateRegistrationRequest(const std::string& jid);
71 buzz::XmlElement* CreateSignature(const std::string& jid); 69 buzz::XmlElement* CreateSignature(const std::string& jid);
72 70
73 void ProcessResponse(const buzz::XmlElement* response); 71 void ProcessResponse(const buzz::XmlElement* response);
74 bool ParseResponse(const buzz::XmlElement* response, 72 bool ParseResponse(const buzz::XmlElement* response,
75 std::string* support_id, base::TimeDelta* lifetime); 73 std::string* support_id, base::TimeDelta* lifetime);
76 74
77 MessageLoop* message_loop_; 75 SignalStrategy* signal_strategy_;
78 RegisterCallback callback_; 76 RegisterCallback callback_;
79 scoped_ptr<IqSender> iq_sender_; 77 scoped_ptr<IqSender> iq_sender_;
80 scoped_ptr<IqRequest> request_; 78 scoped_ptr<IqRequest> request_;
81 HostKeyPair key_pair_; 79 HostKeyPair key_pair_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698