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

Side by Side Diff: remoting/protocol/connection_to_client.h

Issue 4726003: Implement InputStub in the host side for chromoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 10 years, 1 month 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) 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 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ 5 #ifndef REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
6 #define REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ 6 #define REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "remoting/protocol/message_reader.h"
15 #include "remoting/protocol/session.h" 14 #include "remoting/protocol/session.h"
16 #include "remoting/protocol/stream_writer.h" 15 #include "remoting/protocol/stream_writer.h"
17 #include "remoting/protocol/video_writer.h" 16 #include "remoting/protocol/video_writer.h"
18 17
19 namespace remoting { 18 namespace remoting {
20 namespace protocol { 19 namespace protocol {
21 20
22 class ClientStub; 21 class ClientStub;
22 class HostStub;
23 class InputStub;
24 class HostMessageDispatcher;
23 25
24 // This class represents a remote viewer connected to the chromoting host 26 // This class represents a remote viewer connected to the chromoting host
25 // through a libjingle connection. A viewer object is responsible for sending 27 // through a libjingle connection. A viewer object is responsible for sending
26 // screen updates and other messages to the remote viewer. It is also 28 // screen updates and other messages to the remote viewer. It is also
27 // responsible for receiving and parsing data from the remote viewer and 29 // responsible for receiving and parsing data from the remote viewer and
28 // delegating events to the event handler. 30 // delegating events to the event handler.
29 class ConnectionToClient : 31 class ConnectionToClient :
30 public base::RefCountedThreadSafe<ConnectionToClient> { 32 public base::RefCountedThreadSafe<ConnectionToClient> {
31 public: 33 public:
32 class EventHandler { 34 class EventHandler {
33 public: 35 public:
34 virtual ~EventHandler() {} 36 virtual ~EventHandler() {}
35 37
36 // Handles an event received by the ConnectionToClient. Receiver will own
37 // the ClientMessages in ClientMessageList and needs to delete them.
38 // Note that the sender of messages will not reference messages
39 // again so it is okay to clear |messages| in this method.
40 virtual void HandleMessage(ConnectionToClient* connection,
41 ChromotingClientMessage* message) = 0;
42
43 // Called when the network connection is opened. 38 // Called when the network connection is opened.
44 virtual void OnConnectionOpened(ConnectionToClient* connection) = 0; 39 virtual void OnConnectionOpened(ConnectionToClient* connection) = 0;
45 40
46 // Called when the network connection is closed. 41 // Called when the network connection is closed.
47 virtual void OnConnectionClosed(ConnectionToClient* connection) = 0; 42 virtual void OnConnectionClosed(ConnectionToClient* connection) = 0;
48 43
49 // Called when the network connection has failed. 44 // Called when the network connection has failed.
50 virtual void OnConnectionFailed(ConnectionToClient* connection) = 0; 45 virtual void OnConnectionFailed(ConnectionToClient* connection) = 0;
51 }; 46 };
52 47
53 // Constructs a ConnectionToClient object. |message_loop| is the message loop 48 // Constructs a ConnectionToClient object. |message_loop| is the message loop
54 // that this object runs on. A viewer object receives events and messages from 49 // that this object runs on. A viewer object receives events and messages from
55 // a libjingle channel, these events are delegated to |handler|. 50 // a libjingle channel, these events are delegated to |handler|.
56 // It is guranteed that |handler| is called only on the |message_loop|. 51 // It is guranteed that |handler| is called only on the |message_loop|.
57 ConnectionToClient(MessageLoop* message_loop, 52 ConnectionToClient(MessageLoop* message_loop,
58 EventHandler* handler); 53 EventHandler* handler,
54 HostStub* host_stub,
55 InputStub* input_stub);
59 56
60 virtual ~ConnectionToClient(); 57 virtual ~ConnectionToClient();
61 58
62 virtual void Init(protocol::Session* session); 59 virtual void Init(protocol::Session* session);
63 60
64 // Returns the connection in use. 61 // Returns the connection in use.
65 virtual protocol::Session* session(); 62 virtual protocol::Session* session();
66 63
67 // Send encoded update stream data to the viewer. 64 // Send encoded update stream data to the viewer.
68 virtual void SendVideoPacket(const VideoPacket& packet); 65 virtual void SendVideoPacket(const VideoPacket& packet);
(...skipping 14 matching lines...) Expand all
83 virtual ClientStub* client_stub() { return client_stub_.get(); } 80 virtual ClientStub* client_stub() { return client_stub_.get(); }
84 81
85 protected: 82 protected:
86 // Protected constructor used by unit test. 83 // Protected constructor used by unit test.
87 ConnectionToClient(); 84 ConnectionToClient();
88 85
89 private: 86 private:
90 // Callback for protocol Session. 87 // Callback for protocol Session.
91 void OnSessionStateChange(protocol::Session::State state); 88 void OnSessionStateChange(protocol::Session::State state);
92 89
93 // Callback for MessageReader.
94 void OnMessageReceived(ChromotingClientMessage* message);
95
96 // Process a libjingle state change event on the |loop_|. 90 // Process a libjingle state change event on the |loop_|.
97 void StateChangeTask(protocol::Session::State state); 91 void StateChangeTask(protocol::Session::State state);
98 92
99 // Process a data buffer received from libjingle.
100 void MessageReceivedTask(ChromotingClientMessage* message);
101
102 void OnClosed(); 93 void OnClosed();
103 94
104 // The libjingle channel used to send and receive data from the remote client. 95 // The libjingle channel used to send and receive data from the remote client.
105 scoped_refptr<protocol::Session> session_; 96 scoped_refptr<protocol::Session> session_;
106 97
107 MessageReader event_reader_;
108 scoped_ptr<VideoWriter> video_writer_; 98 scoped_ptr<VideoWriter> video_writer_;
109 99
110 // ClientStub for sending messages to the client. 100 // ClientStub for sending messages to the client.
111 scoped_ptr<ClientStub> client_stub_; 101 scoped_ptr<ClientStub> client_stub_;
112 102
113 // The message loop that this object runs on. 103 // The message loop that this object runs on.
114 MessageLoop* loop_; 104 MessageLoop* loop_;
115 105
116 // Event handler for handling events sent from this object. 106 // Event handler for handling events sent from this object.
117 EventHandler* handler_; 107 EventHandler* handler_;
118 108
109 // HostStub for receiving control events from the client.
110 HostStub* host_stub_;
111
112 // InputStub for receiving input events from the client.
113 InputStub* input_stub_;
114
115 // Dispatcher for submitting messages to stubs.
116 scoped_ptr<HostMessageDispatcher> dispatcher_;
117
119 DISALLOW_COPY_AND_ASSIGN(ConnectionToClient); 118 DISALLOW_COPY_AND_ASSIGN(ConnectionToClient);
120 }; 119 };
121 120
122 } // namespace protocol 121 } // namespace protocol
123 } // namespace remoting 122 } // namespace remoting
124 123
125 #endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ 124 #endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698