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/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.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 |
| 47 // Start/stop the client. Must be called on the main thread. | |
| 50 void Start(scoped_refptr<XmppProxy> xmpp_proxy, | 48 void Start(scoped_refptr<XmppProxy> xmpp_proxy, |
| 51 scoped_ptr<protocol::TransportFactory> transport_factory); | 49 scoped_ptr<protocol::TransportFactory> transport_factory); |
| 52 void Stop(const base::Closure& shutdown_task); | 50 void Stop(const base::Closure& shutdown_task); |
| 53 void ClientDone(); | |
| 54 | 51 |
| 55 // Return the stats recorded by this client. | 52 // Return the stats recorded by this client. |
| 56 ChromotingStats* GetStats(); | 53 ChromotingStats* GetStats(); |
| 57 | 54 |
| 58 // ClipboardStub implementation for receiving clipboard data from host. | 55 // ClipboardStub implementation for receiving clipboard data from host. |
| 59 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) | 56 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) |
| 60 OVERRIDE; | 57 OVERRIDE; |
| 61 | 58 |
| 62 // CursorShapeStub implementation for receiving cursor shape updates. | 59 // CursorShapeStub implementation for receiving cursor shape updates. |
| 63 virtual void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) | 60 virtual void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 75 | 72 |
| 76 private: | 73 private: |
| 77 struct QueuedVideoPacket { | 74 struct QueuedVideoPacket { |
| 78 QueuedVideoPacket(scoped_ptr<VideoPacket> packet, | 75 QueuedVideoPacket(scoped_ptr<VideoPacket> packet, |
| 79 const base::Closure& done); | 76 const base::Closure& done); |
| 80 ~QueuedVideoPacket(); | 77 ~QueuedVideoPacket(); |
| 81 VideoPacket* packet; | 78 VideoPacket* packet; |
| 82 base::Closure done; | 79 base::Closure done; |
| 83 }; | 80 }; |
| 84 | 81 |
| 85 base::MessageLoopProxy* message_loop(); | 82 base::SingleThreadTaskRunner* task_runner(); |
|
Wez
2012/06/11 22:32:44
nit: It would be simpler to just take a scoped_ref
Wez
2012/06/11 22:32:44
nit: Where is SingleThreadTaskRunner defined in th
Sergey Ulanov
2012/06/11 23:35:56
Done.
Sergey Ulanov
2012/06/11 23:35:56
Done.
| |
| 86 | 83 |
| 87 // Initializes connection. | 84 // Initializes connection. |
| 88 void Initialize(); | 85 void Initialize(); |
| 89 | 86 |
| 90 // If a packet is not being processed, dispatches a single message from the | 87 // If a packet is not being processed, dispatches a single message from the |
| 91 // |received_packets_| queue. | 88 // |received_packets_| queue. |
| 92 void DispatchPacket(); | 89 void DispatchPacket(); |
| 93 | 90 |
| 94 // Callback method when a VideoPacket is processed. | 91 // Callback method when a VideoPacket is processed. |
| 95 // If |last_packet| is true then |decode_start| contains the timestamp when | 92 // If |last_packet| is true then |decode_start| contains the timestamp when |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 // WeakPtr used to avoid tasks accessing the client after it is deleted. | 124 // WeakPtr used to avoid tasks accessing the client after it is deleted. |
| 128 base::WeakPtrFactory<ChromotingClient> weak_factory_; | 125 base::WeakPtrFactory<ChromotingClient> weak_factory_; |
| 129 base::WeakPtr<ChromotingClient> weak_ptr_; | 126 base::WeakPtr<ChromotingClient> weak_ptr_; |
| 130 | 127 |
| 131 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); | 128 DISALLOW_COPY_AND_ASSIGN(ChromotingClient); |
| 132 }; | 129 }; |
| 133 | 130 |
| 134 } // namespace remoting | 131 } // namespace remoting |
| 135 | 132 |
| 136 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ | 133 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_ |
| OLD | NEW |