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 // ChromotingClient is the controller for the Client implementation. | 5 // ChromotingClient is the controller for the Client implementation. |
6 | 6 |
7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H | 7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H |
8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H | 8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H |
9 | 9 |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "remoting/client/host_connection.h" | 11 #include "remoting/client/host_connection.h" |
12 #include "remoting/client/client_config.h" | 12 #include "remoting/client/client_config.h" |
13 | 13 |
14 class MessageLoop; | 14 class MessageLoop; |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class ChromotingView; | 18 class ChromotingView; |
19 class ClientContext; | 19 class ClientContext; |
20 class InputHandler; | 20 class InputHandler; |
| 21 class ChromotingHostMessage; |
| 22 class InitClientMessage; |
| 23 class RectangleUpdateDecoder; |
21 | 24 |
22 class ChromotingClient : public HostConnection::HostEventCallback { | 25 class ChromotingClient : public HostConnection::HostEventCallback { |
23 public: | 26 public: |
24 // Objects passed in are not owned by this class. | 27 // Objects passed in are not owned by this class. |
25 ChromotingClient(const ClientConfig& config, | 28 ChromotingClient(const ClientConfig& config, |
26 ClientContext* context, | 29 ClientContext* context, |
27 HostConnection* connection, | 30 HostConnection* connection, |
28 ChromotingView* view, | 31 ChromotingView* view, |
| 32 RectangleUpdateDecoder* rectangle_decoder, |
29 InputHandler* input_handler, | 33 InputHandler* input_handler, |
30 CancelableTask* client_done); | 34 CancelableTask* client_done); |
31 virtual ~ChromotingClient(); | 35 virtual ~ChromotingClient(); |
32 | 36 |
33 void Start(); | 37 void Start(); |
34 void Stop(); | 38 void Stop(); |
35 void ClientDone(); | 39 void ClientDone(); |
36 | 40 |
37 // Signals that the associated view may need updating. | 41 // Signals that the associated view may need updating. |
38 virtual void Repaint(); | 42 virtual void Repaint(); |
(...skipping 18 matching lines...) Expand all Loading... |
57 CONNECTED, | 61 CONNECTED, |
58 DISCONNECTED, | 62 DISCONNECTED, |
59 FAILED, | 63 FAILED, |
60 }; | 64 }; |
61 | 65 |
62 MessageLoop* message_loop(); | 66 MessageLoop* message_loop(); |
63 | 67 |
64 // Convenience method for modifying the state on this object's message loop. | 68 // Convenience method for modifying the state on this object's message loop. |
65 void SetState(State s); | 69 void SetState(State s); |
66 | 70 |
| 71 // If a message is not being processed, dispatches a single message from the |
| 72 // |received_messages_| queue. |
| 73 void DispatchMessage(); |
| 74 |
| 75 void OnMessageDone(ChromotingHostMessage* msg); |
| 76 |
67 // Handles for chromotocol messages. | 77 // Handles for chromotocol messages. |
68 void InitClient(ChromotingHostMessage* msg); | 78 void InitClient(const InitClientMessage& msg, Task* done); |
69 void BeginUpdate(ChromotingHostMessage* msg); | |
70 void HandleUpdate(ChromotingHostMessage* msg); | |
71 void EndUpdate(ChromotingHostMessage* msg); | |
72 | 79 |
73 // The following are not owned by this class. | 80 // The following are not owned by this class. |
74 ClientConfig config_; | 81 ClientConfig config_; |
75 ClientContext* context_; | 82 ClientContext* context_; |
76 HostConnection* connection_; | 83 HostConnection* connection_; |
77 ChromotingView* view_; | 84 ChromotingView* view_; |
| 85 RectangleUpdateDecoder* rectangle_decoder_; |
78 InputHandler* input_handler_; | 86 InputHandler* input_handler_; |
79 | 87 |
80 // If non-NULL, this is called when the client is done. | 88 // If non-NULL, this is called when the client is done. |
81 CancelableTask* client_done_; | 89 CancelableTask* client_done_; |
82 | 90 |
83 State state_; | 91 State state_; |
84 | 92 |
| 93 // Contains all messages that have been received, but have not yet been |
| 94 // processed. |
| 95 // |
| 96 // Used to serialize sending of messages to the client. |
| 97 HostMessageList received_messages_; |
| 98 |
| 99 // True if a message is being processed. Can be used to determine if it is |
| 100 // safe to dispatch another message. |
| 101 bool message_being_processed_; |
| 102 |
85 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 103 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
86 }; | 104 }; |
87 | 105 |
88 } // namespace remoting | 106 } // namespace remoting |
89 | 107 |
90 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); | 108 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); |
91 | 109 |
92 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H | 110 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H |
OLD | NEW |