| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace protocol { | 31 namespace protocol { |
| 32 class TransportFactory; | 32 class TransportFactory; |
| 33 } // namespace protocol | 33 } // namespace protocol |
| 34 | 34 |
| 35 class AudioDecodeScheduler; | 35 class AudioDecodeScheduler; |
| 36 class AudioPlayer; | 36 class AudioPlayer; |
| 37 class ClientContext; | 37 class ClientContext; |
| 38 class ClientUserInterface; | 38 class ClientUserInterface; |
| 39 class RectangleUpdateDecoder; | 39 class RectangleUpdateDecoder; |
| 40 | 40 |
| 41 // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. | |
| 42 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, | 41 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, |
| 43 public protocol::ClientStub, | 42 public protocol::ClientStub { |
| 44 public protocol::VideoStub { | |
| 45 public: | 43 public: |
| 46 // Objects passed in are not owned by this class. | 44 // Objects passed in are not owned by this class. |
| 47 ChromotingClient(const ClientConfig& config, | 45 ChromotingClient(const ClientConfig& config, |
| 48 ClientContext* client_context, | 46 ClientContext* client_context, |
| 49 protocol::ConnectionToHost* connection, | 47 protocol::ConnectionToHost* connection, |
| 50 ClientUserInterface* user_interface, | 48 ClientUserInterface* user_interface, |
| 51 RectangleUpdateDecoder* rectangle_decoder, | 49 RectangleUpdateDecoder* rectangle_decoder, |
| 52 scoped_ptr<AudioPlayer> audio_player); | 50 scoped_ptr<AudioPlayer> audio_player); |
| 53 | 51 |
| 54 virtual ~ChromotingClient(); | 52 virtual ~ChromotingClient(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 // CursorShapeStub implementation for receiving cursor shape updates. | 66 // CursorShapeStub implementation for receiving cursor shape updates. |
| 69 virtual void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) | 67 virtual void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) |
| 70 OVERRIDE; | 68 OVERRIDE; |
| 71 | 69 |
| 72 // ConnectionToHost::HostEventCallback implementation. | 70 // ConnectionToHost::HostEventCallback implementation. |
| 73 virtual void OnConnectionState( | 71 virtual void OnConnectionState( |
| 74 protocol::ConnectionToHost::State state, | 72 protocol::ConnectionToHost::State state, |
| 75 protocol::ErrorCode error) OVERRIDE; | 73 protocol::ErrorCode error) OVERRIDE; |
| 76 virtual void OnConnectionReady(bool ready) OVERRIDE; | 74 virtual void OnConnectionReady(bool ready) OVERRIDE; |
| 77 | 75 |
| 78 // VideoStub implementation. | |
| 79 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | |
| 80 const base::Closure& done) OVERRIDE; | |
| 81 virtual int GetPendingVideoPackets() OVERRIDE; | |
| 82 | |
| 83 private: | 76 private: |
| 84 struct QueuedVideoPacket { | |
| 85 QueuedVideoPacket(scoped_ptr<VideoPacket> packet, | |
| 86 const base::Closure& done); | |
| 87 ~QueuedVideoPacket(); | |
| 88 VideoPacket* packet; | |
| 89 base::Closure done; | |
| 90 }; | |
| 91 | |
| 92 // Initializes connection. | 77 // Initializes connection. |
| 93 void Initialize(); | 78 void Initialize(); |
| 94 | 79 |
| 95 // If a packet is not being processed, dispatches a single message from the | |
| 96 // |received_packets_| queue. | |
| 97 void DispatchPacket(); | |
| 98 | |
| 99 // Callback method when a VideoPacket is processed. | |
| 100 // If |last_packet| is true then |decode_start| contains the timestamp when | |
| 101 // the packet will start to be processed. | |
| 102 void OnPacketDone(bool last_packet, base::Time decode_start); | |
| 103 | |
| 104 void OnDisconnected(const base::Closure& shutdown_task); | 80 void OnDisconnected(const base::Closure& shutdown_task); |
| 105 | 81 |
| 106 // The following are not owned by this class. | 82 // The following are not owned by this class. |
| 107 ClientConfig config_; | 83 ClientConfig config_; |
| 108 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 84 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 109 protocol::ConnectionToHost* connection_; | 85 protocol::ConnectionToHost* connection_; |
| 110 ClientUserInterface* user_interface_; | 86 ClientUserInterface* user_interface_; |
| 111 // TODO(kxing): Make ChromotingClient own RectangleUpdateDecoder. | 87 // TODO(kxing): Make ChromotingClient own RectangleUpdateDecoder. |
| 112 RectangleUpdateDecoder* rectangle_decoder_; | 88 RectangleUpdateDecoder* rectangle_decoder_; |
| 113 | 89 |
| 114 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; | 90 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_; |
| 115 | 91 |
| 116 // If non-NULL, this is called when the client is done. | 92 // If non-NULL, this is called when the client is done. |
| 117 base::Closure client_done_; | 93 base::Closure client_done_; |
| 118 | 94 |
| 119 // Contains all video packets that have been received, but have not yet been | |
| 120 // processed. | |
| 121 // | |
| 122 // Used to serialize sending of messages to the client. | |
| 123 std::list<QueuedVideoPacket> received_packets_; | |
| 124 | |
| 125 // True if a message is being processed. Can be used to determine if it is | |
| 126 // safe to dispatch another message. | |
| 127 bool packet_being_processed_; | |
| 128 | |
| 129 // Record the statistics of the connection. | 95 // Record the statistics of the connection. |
| 130 ChromotingStats stats_; | 96 ChromotingStats stats_; |
| 131 | 97 |
| 132 // Keep track of the last sequence number bounced back from the host. | |
| 133 int64 last_sequence_number_; | |
| 134 | |
| 135 // WeakPtr used to avoid tasks accessing the client after it is deleted. | 98 // WeakPtr used to avoid tasks accessing the client after it is deleted. |
| 136 base::WeakPtrFactory<ChromotingClient> weak_factory_; | 99 base::WeakPtrFactory<ChromotingClient> weak_factory_; |
| 137 base::WeakPtr<ChromotingClient> weak_ptr_; | 100 base::WeakPtr<ChromotingClient> weak_ptr_; |
| 138 | 101 |
| 139 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 102 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
| 140 }; | 103 }; |
| 141 | 104 |
| 142 } // namespace remoting | 105 } // namespace remoting |
| 143 | 106 |
| 144 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 107 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| OLD | NEW |