Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "remoting/base/scoped_thread_proxy.h" | 14 #include "remoting/base/scoped_thread_proxy.h" |
| 15 #include "remoting/client/client_config.h" | 15 #include "remoting/client/client_config.h" |
| 16 #include "remoting/client/chromoting_stats.h" | 16 #include "remoting/client/chromoting_stats.h" |
| 17 #include "remoting/client/chromoting_view.h" | 17 #include "remoting/client/chromoting_view.h" |
| 18 #include "remoting/protocol/client_stub.h" | 18 #include "remoting/protocol/client_stub.h" |
| 19 #include "remoting/protocol/clipboard_stub.h" | 19 #include "remoting/protocol/clipboard_stub.h" |
| 20 #include "remoting/protocol/connection_to_host.h" | 20 #include "remoting/protocol/connection_to_host.h" |
| 21 #include "remoting/protocol/input_stub.h" | 21 #include "remoting/protocol/input_stub.h" |
| 22 #include "remoting/protocol/video_stub.h" | 22 #include "remoting/protocol/video_stub.h" |
| 23 #include "remoting/jingle_glue/xmpp_proxy.h" | 23 #include "remoting/jingle_glue/xmpp_proxy.h" |
| 24 | 24 |
| 25 class MessageLoop; | |
| 26 | |
| 27 namespace remoting { | 25 namespace remoting { |
| 28 | 26 |
| 29 namespace protocol { | 27 namespace protocol { |
| 30 class TransportFactory; | 28 class TransportFactory; |
| 31 } // namespace protocol | 29 } // namespace protocol |
| 32 | 30 |
| 33 class ClientContext; | 31 class ClientContext; |
| 34 class RectangleUpdateDecoder; | 32 class RectangleUpdateDecoder; |
| 35 | 33 |
| 36 // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. | 34 // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. |
| 37 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, | 35 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, |
| 38 public protocol::ClientStub, | 36 public protocol::ClientStub, |
| 39 public protocol::VideoStub { | 37 public protocol::VideoStub { |
| 40 public: | 38 public: |
| 41 // Objects passed in are not owned by this class. | 39 // Objects passed in are not owned by this class. |
| 42 ChromotingClient(const ClientConfig& config, | 40 ChromotingClient(const ClientConfig& config, |
| 43 ClientContext* context, | 41 ClientContext* context, |
| 44 protocol::ConnectionToHost* connection, | 42 protocol::ConnectionToHost* connection, |
| 45 ChromotingView* view, | 43 ChromotingView* view, |
| 46 RectangleUpdateDecoder* rectangle_decoder, | 44 RectangleUpdateDecoder* rectangle_decoder); |
| 47 const base::Closure& client_done); | |
| 48 virtual ~ChromotingClient(); | 45 virtual ~ChromotingClient(); |
| 49 | 46 |
| 50 void Start(scoped_refptr<XmppProxy> xmpp_proxy, | 47 void Start(scoped_refptr<XmppProxy> xmpp_proxy, |
| 51 scoped_ptr<protocol::TransportFactory> transport_factory); | 48 scoped_ptr<protocol::TransportFactory> transport_factory); |
| 52 void Stop(const base::Closure& shutdown_task); | 49 void Stop(const base::Closure& shutdown_task); |
|
Wez
2012/05/26 00:18:40
Add a comment clarifying the threading properties
Sergey Ulanov
2012/05/30 01:07:07
Done.
| |
| 53 void ClientDone(); | |
| 54 | 50 |
| 55 // Return the stats recorded by this client. | 51 // Return the stats recorded by this client. |
| 56 ChromotingStats* GetStats(); | 52 ChromotingStats* GetStats(); |
| 57 | 53 |
| 58 // ClipboardStub implementation. | 54 // ClipboardStub implementation. |
| 59 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) | 55 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) |
| 60 OVERRIDE; | 56 OVERRIDE; |
| 61 | 57 |
| 62 // ConnectionToHost::HostEventCallback implementation. | 58 // ConnectionToHost::HostEventCallback implementation. |
| 63 virtual void OnConnectionState( | 59 virtual void OnConnectionState( |
| 64 protocol::ConnectionToHost::State state, | 60 protocol::ConnectionToHost::State state, |
| 65 protocol::ErrorCode error) OVERRIDE; | 61 protocol::ErrorCode error) OVERRIDE; |
| 66 | 62 |
| 67 // VideoStub implementation. | 63 // VideoStub implementation. |
| 68 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | 64 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, |
| 69 const base::Closure& done) OVERRIDE; | 65 const base::Closure& done) OVERRIDE; |
| 70 virtual int GetPendingPackets() OVERRIDE; | 66 virtual int GetPendingPackets() OVERRIDE; |
| 71 | 67 |
| 72 private: | 68 private: |
| 73 struct QueuedVideoPacket { | 69 struct QueuedVideoPacket { |
| 74 QueuedVideoPacket(scoped_ptr<VideoPacket> packet, | 70 QueuedVideoPacket(scoped_ptr<VideoPacket> packet, |
| 75 const base::Closure& done); | 71 const base::Closure& done); |
| 76 ~QueuedVideoPacket(); | 72 ~QueuedVideoPacket(); |
| 77 VideoPacket* packet; | 73 VideoPacket* packet; |
| 78 base::Closure done; | 74 base::Closure done; |
| 79 }; | 75 }; |
| 80 | 76 |
| 81 base::MessageLoopProxy* message_loop(); | 77 base::SingleThreadTaskRunner* task_runner(); |
| 82 | 78 |
| 83 // Initializes connection. | 79 // Initializes connection. |
| 84 void Initialize(); | 80 void Initialize(); |
| 85 | 81 |
| 86 // If a packet is not being processed, dispatches a single message from the | 82 // If a packet is not being processed, dispatches a single message from the |
| 87 // |received_packets_| queue. | 83 // |received_packets_| queue. |
| 88 void DispatchPacket(); | 84 void DispatchPacket(); |
| 89 | 85 |
| 90 // Callback method when a VideoPacket is processed. | 86 // Callback method when a VideoPacket is processed. |
| 91 // If |last_packet| is true then |decode_start| contains the timestamp when | 87 // If |last_packet| is true then |decode_start| contains the timestamp when |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 121 int64 last_sequence_number_; | 117 int64 last_sequence_number_; |
| 122 | 118 |
| 123 ScopedThreadProxy thread_proxy_; | 119 ScopedThreadProxy thread_proxy_; |
| 124 | 120 |
| 125 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 121 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 } // namespace remoting | 124 } // namespace remoting |
| 129 | 125 |
| 130 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 126 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| OLD | NEW |