OLD | NEW |
---|---|
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_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 |
(...skipping 29 matching lines...) Expand all Loading... | |
40 // Called when the network connection is closed. | 40 // Called when the network connection is closed. |
41 virtual void OnConnectionClosed(ConnectionToClient* connection) = 0; | 41 virtual void OnConnectionClosed(ConnectionToClient* connection) = 0; |
42 | 42 |
43 // Called when the network connection has failed. | 43 // Called when the network connection has failed. |
44 virtual void OnConnectionFailed(ConnectionToClient* connection) = 0; | 44 virtual void OnConnectionFailed(ConnectionToClient* connection) = 0; |
45 }; | 45 }; |
46 | 46 |
47 // Constructs a ConnectionToClient object. |message_loop| is the message loop | 47 // Constructs a ConnectionToClient object. |message_loop| is the message loop |
48 // that this object runs on. A viewer object receives events and messages from | 48 // that this object runs on. A viewer object receives events and messages from |
49 // a libjingle channel, these events are delegated to |handler|. | 49 // a libjingle channel, these events are delegated to |handler|. |
50 // It is guranteed that |handler| is called only on the |message_loop|. | 50 // It is guaranteed that |handler| is called only on the |message_loop|. |
51 ConnectionToClient(MessageLoop* message_loop, | 51 ConnectionToClient(MessageLoop* message_loop, |
52 EventHandler* handler, | 52 EventHandler* handler); |
53 InputStub* input_stub); | |
54 | 53 |
55 virtual void Init(Session* session); | 54 virtual void Init(Session* session); |
56 | 55 |
57 // Returns the connection in use. | 56 // Returns the connection in use. |
58 virtual Session* session(); | 57 virtual Session* session(); |
59 | 58 |
60 // Disconnect the client connection. This method is allowed to be called | 59 // Disconnect the client connection. This method is allowed to be called |
61 // more than once and calls after the first one will be ignored. | 60 // more than once and calls after the first one will be ignored. |
62 // | 61 // |
63 // After this method is called all the send method calls will be ignored. | 62 // After this method is called all the send method calls will be ignored. |
64 virtual void Disconnect(); | 63 virtual void Disconnect(); |
65 | 64 |
66 // Send encoded update stream data to the viewer. | 65 // Send encoded update stream data to the viewer. |
67 virtual VideoStub* video_stub(); | 66 virtual VideoStub* video_stub(); |
68 | 67 |
69 // Return pointer to ClientStub. | 68 // Return pointer to ClientStub. |
70 virtual ClientStub* client_stub(); | 69 virtual ClientStub* client_stub(); |
71 | 70 |
72 virtual HostStub* host_stub(); | 71 virtual HostStub* host_stub(); |
73 virtual void set_host_stub(HostStub* host_stub); | 72 virtual void set_host_stub(HostStub* host_stub); |
74 | 73 |
75 // Called when the host accepts the client authentication. | 74 virtual void set_input_stub(InputStub* input_stub); |
Alpha Left Google
2011/03/28 16:22:26
do we need a getter like host stub?
Alpha Left Google
2011/03/28 16:22:26
Since we have these setters now for stubs, need to
simonmorris
2011/03/29 17:07:51
It turns out we don't need a host_stub_ getter, ei
simonmorris
2011/03/29 17:07:51
Added comments.
| |
76 void OnClientAuthenticated(); | |
77 | |
78 // Whether the client has been authenticated. | |
79 bool client_authenticated(); | |
80 | 75 |
81 protected: | 76 protected: |
Alpha Left Google
2011/03/28 16:22:26
Can we not have protected here?
simonmorris
2011/03/29 17:07:51
MockConnectionToClient inherits from ConnectionToC
| |
82 friend class base::RefCountedThreadSafe<ConnectionToClient>; | 77 friend class base::RefCountedThreadSafe<ConnectionToClient>; |
83 virtual ~ConnectionToClient(); | 78 virtual ~ConnectionToClient(); |
84 | 79 |
85 private: | 80 private: |
86 // Callback for protocol Session. | 81 // Callback for protocol Session. |
87 void OnSessionStateChange(Session::State state); | 82 void OnSessionStateChange(Session::State state); |
88 | 83 |
89 // Process a libjingle state change event on the |loop_|. | 84 // Process a libjingle state change event on the |loop_|. |
90 void StateChangeTask(Session::State state); | 85 void StateChangeTask(Session::State state); |
91 | 86 |
92 void OnClosed(); | 87 void OnClosed(); |
93 | 88 |
94 // Initially false, this is set to true once the client has authenticated | |
95 // properly. When this is false, many client messages (like input events) | |
96 // will be ignored. | |
97 bool client_authenticated_; | |
98 | |
99 // The libjingle channel used to send and receive data from the remote client. | 89 // The libjingle channel used to send and receive data from the remote client. |
100 scoped_refptr<Session> session_; | 90 scoped_refptr<Session> session_; |
101 | 91 |
102 scoped_ptr<VideoWriter> video_writer_; | 92 scoped_ptr<VideoWriter> video_writer_; |
103 | 93 |
104 // ClientStub for sending messages to the client. | 94 // ClientStub for sending messages to the client. |
105 scoped_ptr<ClientStub> client_stub_; | 95 scoped_ptr<ClientStub> client_stub_; |
106 | 96 |
107 // The message loop that this object runs on. | 97 // The message loop that this object runs on. |
108 MessageLoop* loop_; | 98 MessageLoop* loop_; |
(...skipping 10 matching lines...) Expand all Loading... | |
119 // Dispatcher for submitting messages to stubs. | 109 // Dispatcher for submitting messages to stubs. |
120 scoped_ptr<HostMessageDispatcher> dispatcher_; | 110 scoped_ptr<HostMessageDispatcher> dispatcher_; |
121 | 111 |
122 DISALLOW_COPY_AND_ASSIGN(ConnectionToClient); | 112 DISALLOW_COPY_AND_ASSIGN(ConnectionToClient); |
123 }; | 113 }; |
124 | 114 |
125 } // namespace protocol | 115 } // namespace protocol |
126 } // namespace remoting | 116 } // namespace remoting |
127 | 117 |
128 #endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ | 118 #endif // REMOTING_PROTOCOL_CONNECTION_TO_CLIENT_H_ |
OLD | NEW |