| 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 <list> | 10 #include <list> |
| 11 | 11 |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "remoting/client/host_connection.h" | 13 #include "remoting/client/host_connection.h" |
| 14 #include "remoting/client/client_config.h" | 14 #include "remoting/client/client_config.h" |
| 15 #include "remoting/client/chromoting_view.h" | 15 #include "remoting/client/chromoting_view.h" |
| 16 #include "remoting/protocol/video_stub.h" |
| 16 | 17 |
| 17 class MessageLoop; | 18 class MessageLoop; |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| 20 | 21 |
| 21 class ChromotingHostMessage; | 22 class ChromotingHostMessage; |
| 22 class ClientContext; | 23 class ClientContext; |
| 23 class InitClientMessage; | 24 class InitClientMessage; |
| 24 class InputHandler; | 25 class InputHandler; |
| 25 class RectangleUpdateDecoder; | 26 class RectangleUpdateDecoder; |
| 26 | 27 |
| 27 class ChromotingClient : public HostConnection::HostEventCallback { | 28 // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. |
| 29 class ChromotingClient : public HostConnection::HostEventCallback, |
| 30 public VideoStub { |
| 28 public: | 31 public: |
| 29 // Objects passed in are not owned by this class. | 32 // Objects passed in are not owned by this class. |
| 30 ChromotingClient(const ClientConfig& config, | 33 ChromotingClient(const ClientConfig& config, |
| 31 ClientContext* context, | 34 ClientContext* context, |
| 32 HostConnection* connection, | 35 HostConnection* connection, |
| 33 ChromotingView* view, | 36 ChromotingView* view, |
| 34 RectangleUpdateDecoder* rectangle_decoder, | 37 RectangleUpdateDecoder* rectangle_decoder, |
| 35 InputHandler* input_handler, | 38 InputHandler* input_handler, |
| 36 CancelableTask* client_done); | 39 CancelableTask* client_done); |
| 37 virtual ~ChromotingClient(); | 40 virtual ~ChromotingClient(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 // thread synchronously really. | 54 // thread synchronously really. |
| 52 virtual void SetViewport(int x, int y, int width, int height); | 55 virtual void SetViewport(int x, int y, int width, int height); |
| 53 | 56 |
| 54 // HostConnection::HostEventCallback implementation. | 57 // HostConnection::HostEventCallback implementation. |
| 55 virtual void HandleMessage(HostConnection* conn, | 58 virtual void HandleMessage(HostConnection* conn, |
| 56 ChromotingHostMessage* messages); | 59 ChromotingHostMessage* messages); |
| 57 virtual void OnConnectionOpened(HostConnection* conn); | 60 virtual void OnConnectionOpened(HostConnection* conn); |
| 58 virtual void OnConnectionClosed(HostConnection* conn); | 61 virtual void OnConnectionClosed(HostConnection* conn); |
| 59 virtual void OnConnectionFailed(HostConnection* conn); | 62 virtual void OnConnectionFailed(HostConnection* conn); |
| 60 | 63 |
| 64 // VideoStub implementation. |
| 65 virtual void ProcessVideoPacket(const VideoPacket* packet, Task* done); |
| 66 |
| 61 private: | 67 private: |
| 68 struct QueuedVideoPacket { |
| 69 QueuedVideoPacket(const VideoPacket* packet, Task* done) |
| 70 : packet(packet), done(done) { |
| 71 } |
| 72 const VideoPacket* packet; |
| 73 Task* done; |
| 74 }; |
| 75 |
| 62 MessageLoop* message_loop(); | 76 MessageLoop* message_loop(); |
| 63 | 77 |
| 64 // Convenience method for modifying the state on this object's message loop. | 78 // Convenience method for modifying the state on this object's message loop. |
| 65 void SetConnectionState(ConnectionState s); | 79 void SetConnectionState(ConnectionState s); |
| 66 | 80 |
| 67 // If a message is not being processed, dispatches a single message from the | 81 // If a packet is not being processed, dispatches a single message from the |
| 68 // |received_messages_| queue. | 82 // |received_packets_| queue. |
| 69 void DispatchMessage(); | 83 void DispatchPacket(); |
| 70 | 84 |
| 71 void OnMessageDone(ChromotingHostMessage* msg); | 85 void OnPacketDone(); |
| 72 | 86 |
| 73 // Handles for chromotocol messages. | 87 // Handles for chromotocol messages. |
| 74 void InitClient(const InitClientMessage& msg, Task* done); | 88 void InitClient(const InitClientMessage& msg); |
| 75 | 89 |
| 76 // The following are not owned by this class. | 90 // The following are not owned by this class. |
| 77 ClientConfig config_; | 91 ClientConfig config_; |
| 78 ClientContext* context_; | 92 ClientContext* context_; |
| 79 HostConnection* connection_; | 93 HostConnection* connection_; |
| 80 ChromotingView* view_; | 94 ChromotingView* view_; |
| 81 RectangleUpdateDecoder* rectangle_decoder_; | 95 RectangleUpdateDecoder* rectangle_decoder_; |
| 82 InputHandler* input_handler_; | 96 InputHandler* input_handler_; |
| 83 | 97 |
| 84 // If non-NULL, this is called when the client is done. | 98 // If non-NULL, this is called when the client is done. |
| 85 CancelableTask* client_done_; | 99 CancelableTask* client_done_; |
| 86 | 100 |
| 87 ConnectionState state_; | 101 ConnectionState state_; |
| 88 | 102 |
| 89 // Contains all messages that have been received, but have not yet been | 103 // Contains all video packets that have been received, but have not yet been |
| 90 // processed. | 104 // processed. |
| 91 // | 105 // |
| 92 // Used to serialize sending of messages to the client. | 106 // Used to serialize sending of messages to the client. |
| 93 std::list<ChromotingHostMessage*> received_messages_; | 107 std::list<QueuedVideoPacket> received_packets_; |
| 94 | 108 |
| 95 // True if a message is being processed. Can be used to determine if it is | 109 // True if a message is being processed. Can be used to determine if it is |
| 96 // safe to dispatch another message. | 110 // safe to dispatch another message. |
| 97 bool message_being_processed_; | 111 bool packet_being_processed_; |
| 98 | 112 |
| 99 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 113 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
| 100 }; | 114 }; |
| 101 | 115 |
| 102 } // namespace remoting | 116 } // namespace remoting |
| 103 | 117 |
| 104 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); | 118 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::ChromotingClient); |
| 105 | 119 |
| 106 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H | 120 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H |
| OLD | NEW |