| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // JingleConnectionToHost implements the ConnectionToHost interface using | 5 // JingleConnectionToHost implements the ConnectionToHost interface using |
| 6 // libjingle as the transport protocol. | 6 // libjingle as the transport protocol. |
| 7 // | 7 // |
| 8 // Much of this class focuses on translating JingleClient and | 8 // Much of this class focuses on translating JingleClient and |
| 9 // ChromotingConnection callbacks into ConnectionToHost::HostEventCallback | 9 // ChromotingConnection callbacks into ConnectionToHost::HostEventCallback |
| 10 // messages. | 10 // messages. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class MessageLoop; | 31 class MessageLoop; |
| 32 | 32 |
| 33 namespace remoting { | 33 namespace remoting { |
| 34 | 34 |
| 35 class JingleThread; | 35 class JingleThread; |
| 36 class VideoPacket; | 36 class VideoPacket; |
| 37 | 37 |
| 38 namespace protocol { | 38 namespace protocol { |
| 39 | 39 |
| 40 class ClientMessageDispatcher; |
| 40 class VideoReader; | 41 class VideoReader; |
| 41 class VideoStub; | 42 class VideoStub; |
| 42 | 43 |
| 43 class JingleConnectionToHost : public ConnectionToHost, | 44 class JingleConnectionToHost : public ConnectionToHost, |
| 44 public JingleClient::Callback { | 45 public JingleClient::Callback { |
| 45 public: | 46 public: |
| 46 // TODO(sergeyu): Constructor shouldn't need thread here. | 47 // TODO(sergeyu): Constructor shouldn't need thread here. |
| 47 explicit JingleConnectionToHost(JingleThread* thread); | 48 explicit JingleConnectionToHost(JingleThread* thread); |
| 48 virtual ~JingleConnectionToHost(); | 49 virtual ~JingleConnectionToHost(); |
| 49 | 50 |
| 50 virtual void Connect(const std::string& username, | 51 virtual void Connect(const std::string& username, |
| 51 const std::string& auth_token, | 52 const std::string& auth_token, |
| 52 const std::string& host_jid, | 53 const std::string& host_jid, |
| 53 HostEventCallback* event_callback, | 54 HostEventCallback* event_callback, |
| 54 ClientStub* client_stub, | 55 ClientStub* client_stub, |
| 55 VideoStub* video_stub); | 56 VideoStub* video_stub); |
| 56 virtual void Disconnect(); | 57 virtual void Disconnect(); |
| 57 | 58 |
| 58 virtual const SessionConfig* config(); | 59 virtual const SessionConfig* config(); |
| 59 | 60 |
| 60 // JingleClient::Callback interface. | 61 // JingleClient::Callback interface. |
| 61 virtual void OnStateChange(JingleClient* client, JingleClient::State state); | 62 virtual void OnStateChange(JingleClient* client, JingleClient::State state); |
| 62 | 63 |
| 63 // Callback for chromotocol SessionManager. | 64 // Callback for chromotocol SessionManager. |
| 64 void OnNewSession( | 65 void OnNewSession( |
| 65 protocol::Session* connection, | 66 Session* connection, |
| 66 protocol::SessionManager::IncomingSessionResponse* response); | 67 SessionManager::IncomingSessionResponse* response); |
| 67 | 68 |
| 68 // Callback for chromotocol Session. | 69 // Callback for chromotocol Session. |
| 69 void OnSessionStateChange(protocol::Session::State state); | 70 void OnSessionStateChange(Session::State state); |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 // The message loop for the jingle thread this object works on. | 73 // The message loop for the jingle thread this object works on. |
| 73 MessageLoop* message_loop(); | 74 MessageLoop* message_loop(); |
| 74 | 75 |
| 75 // Called on the jingle thread after we've successfully to XMPP server. Starts | 76 // Called on the jingle thread after we've successfully to XMPP server. Starts |
| 76 // P2P connection to the host. | 77 // P2P connection to the host. |
| 77 void InitSession(); | 78 void InitSession(); |
| 78 | 79 |
| 79 // Callback for |control_reader_|. | |
| 80 void OnControlMessage(ControlMessage* msg); | |
| 81 | |
| 82 // Callback for |video_reader_|. | 80 // Callback for |video_reader_|. |
| 83 void OnVideoPacket(VideoPacket* packet); | 81 void OnVideoPacket(VideoPacket* packet); |
| 84 | 82 |
| 85 // Used by Disconnect() to disconnect chromoting connection, stop chromoting | 83 // Used by Disconnect() to disconnect chromoting connection, stop chromoting |
| 86 // server, and then disconnect XMPP connection. | 84 // server, and then disconnect XMPP connection. |
| 87 void OnDisconnected(); | 85 void OnDisconnected(); |
| 88 void OnServerClosed(); | 86 void OnServerClosed(); |
| 89 | 87 |
| 90 JingleThread* thread_; | 88 JingleThread* thread_; |
| 91 | 89 |
| 92 scoped_refptr<JingleClient> jingle_client_; | 90 scoped_refptr<JingleClient> jingle_client_; |
| 93 scoped_refptr<protocol::SessionManager> session_manager_; | 91 scoped_refptr<SessionManager> session_manager_; |
| 94 scoped_refptr<protocol::Session> session_; | 92 scoped_refptr<Session> session_; |
| 95 | 93 |
| 96 MessageReader control_reader_; | 94 MessageReader control_reader_; |
| 97 scoped_ptr<VideoReader> video_reader_; | 95 scoped_ptr<VideoReader> video_reader_; |
| 98 | 96 |
| 99 HostEventCallback* event_callback_; | 97 HostEventCallback* event_callback_; |
| 100 VideoStub* video_stub_; | 98 VideoStub* video_stub_; |
| 101 | 99 |
| 102 std::string host_jid_; | 100 std::string host_jid_; |
| 103 | 101 |
| 102 scoped_ptr<ClientMessageDispatcher> dispatcher_; |
| 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(JingleConnectionToHost); | 104 DISALLOW_COPY_AND_ASSIGN(JingleConnectionToHost); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace protocol | 107 } // namespace protocol |
| 108 } // namespace remoting | 108 } // namespace remoting |
| 109 | 109 |
| 110 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::JingleConnectionToHost); | 110 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::JingleConnectionToHost); |
| 111 | 111 |
| 112 #endif // REMOTING_PROTOCOL_JINGLE_CONNECTION_TO_HOST_H_ | 112 #endif // REMOTING_PROTOCOL_JINGLE_CONNECTION_TO_HOST_H_ |
| OLD | NEW |