Clear preference when reset in gesture config UI
[chromium-blink-merge.git] / remoting / client / chromoting_client.h
blob3ccde00cbec68554d7af4480904618eea5f73dec
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
3 // found in the LICENSE file.
5 // ChromotingClient is the controller for the Client implementation.
7 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_H_
8 #define REMOTING_CLIENT_CHROMOTING_CLIENT_H_
10 #include <string>
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "remoting/client/client_config.h"
16 #include "remoting/client/chromoting_stats.h"
17 #include "remoting/protocol/client_stub.h"
18 #include "remoting/protocol/clipboard_stub.h"
19 #include "remoting/protocol/connection_to_host.h"
20 #include "remoting/protocol/input_stub.h"
21 #include "remoting/protocol/video_stub.h"
23 namespace base {
24 class SingleThreadTaskRunner;
25 } // namespace base
27 namespace remoting {
29 namespace protocol {
30 class TransportFactory;
31 } // namespace protocol
33 class AudioDecodeScheduler;
34 class AudioPlayer;
35 class ClientContext;
36 class ClientUserInterface;
37 class FrameConsumerProxy;
38 class FrameProducer;
39 class RectangleUpdateDecoder;
40 class SignalStrategy;
42 class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback,
43 public protocol::ClientStub {
44 public:
45 ChromotingClient(const ClientConfig& config,
46 ClientContext* client_context,
47 protocol::ConnectionToHost* connection,
48 ClientUserInterface* user_interface,
49 scoped_refptr<FrameConsumerProxy> frame_consumer,
50 scoped_ptr<AudioPlayer> audio_player);
52 virtual ~ChromotingClient();
54 // Start the client. Must be called on the main thread. |signal_strategy|
55 // must outlive the client.
56 void Start(SignalStrategy* signal_strategy,
57 scoped_ptr<protocol::TransportFactory> transport_factory);
59 FrameProducer* GetFrameProducer();
61 // Return the stats recorded by this client.
62 ChromotingStats* GetStats();
64 // ClientStub implementation.
65 virtual void SetCapabilities(
66 const protocol::Capabilities& capabilities) OVERRIDE;
67 virtual void SetPairingResponse(
68 const protocol::PairingResponse& pairing_response) OVERRIDE;
70 // ClipboardStub implementation for receiving clipboard data from host.
71 virtual void InjectClipboardEvent(
72 const protocol::ClipboardEvent& event) OVERRIDE;
74 // CursorShapeStub implementation for receiving cursor shape updates.
75 virtual void SetCursorShape(
76 const protocol::CursorShapeInfo& cursor_shape) OVERRIDE;
78 // ConnectionToHost::HostEventCallback implementation.
79 virtual void OnConnectionState(
80 protocol::ConnectionToHost::State state,
81 protocol::ErrorCode error) OVERRIDE;
82 virtual void OnConnectionReady(bool ready) OVERRIDE;
84 private:
85 // Called when the connection is authenticated.
86 void OnAuthenticated();
88 // Called when all channels are connected.
89 void OnChannelsConnected();
91 // The following are not owned by this class.
92 ClientConfig config_;
93 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
94 protocol::ConnectionToHost* connection_;
95 ClientUserInterface* user_interface_;
96 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_;
98 scoped_ptr<AudioDecodeScheduler> audio_decode_scheduler_;
100 // If non-NULL, this is called when the client is done.
101 base::Closure client_done_;
103 // The set of all capabilities supported by the host.
104 std::string host_capabilities_;
106 // True if |protocol::Capabilities| message has been received.
107 bool host_capabilities_received_;
109 // Record the statistics of the connection.
110 ChromotingStats stats_;
112 // WeakPtr used to avoid tasks accessing the client after it is deleted.
113 base::WeakPtrFactory<ChromotingClient> weak_factory_;
114 base::WeakPtr<ChromotingClient> weak_ptr_;
116 DISALLOW_COPY_AND_ASSIGN(ChromotingClient);
119 } // namespace remoting
121 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_H_