Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: remoting/client/ios/bridge/client_instance.h

Issue 2829853003: Remove crufty bridge code from old CRD iOS app. (Closed)
Patch Set: Fix remoting/display proto import issue. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/client/ios/bridge/DEPS ('k') | remoting/client/ios/bridge/client_instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef REMOTING_CLIENT_IOS_BRIDGE_CLIENT_INSTANCE_H_
6 #define REMOTING_CLIENT_IOS_BRIDGE_CLIENT_INSTANCE_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/bind.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/message_loop/message_loop.h"
16 #include "net/url_request/url_request_context_getter.h"
17 #include "remoting/base/auto_thread.h"
18 #include "remoting/client/chromoting_client.h"
19 #include "remoting/client/client_context.h"
20 #include "remoting/client/client_user_interface.h"
21 #include "remoting/client/ios/bridge/frame_consumer_bridge.h"
22 #include "remoting/client/software_video_renderer.h"
23 #include "remoting/proto/control.pb.h"
24 #include "remoting/proto/event.pb.h"
25 #include "remoting/protocol/audio_stub.h"
26 #include "remoting/protocol/clipboard_stub.h"
27 #include "remoting/protocol/cursor_shape_stub.h"
28 #include "remoting/protocol/network_settings.h"
29 #include "remoting/protocol/performance_tracker.h"
30 #include "remoting/protocol/transport_context.h"
31 #include "remoting/signaling/xmpp_signal_strategy.h"
32
33 //#include "remoting/client/ios/audio_player_ios.h"
34
35 namespace remoting {
36
37 // class AudioPlayerIos;
38 class ClientProxy;
39 // class ClientStatusLogger;
40 class FrameConsumerBridge;
41
42 // TODO(nicholss): Delete this Class. It needs to use the client version of
43 // ClientInstance. ClientUserInterface that indirectly makes and receives OBJ_C
44 // calls from the UI application.
45 class ClientInstance : public ClientUserInterface,
46 public protocol::ClipboardStub,
47 public protocol::CursorShapeStub,
48 public base::RefCountedThreadSafe<ClientInstance> {
49 public:
50 // Initiates a connection with the specified host. Call from the UI thread. To
51 // connect with an unpaired host, pass in |pairing_id| and |pairing_secret| as
52 // empty strings.
53 ClientInstance(const base::WeakPtr<ClientProxy>& proxy,
54 const std::string& username,
55 const std::string& auth_token,
56 const std::string& host_jid,
57 const std::string& host_id,
58 const std::string& host_pubkey);
59
60 // Begins the connection process. Should not be called again until after
61 // |CleanUp|.
62 void Start(const std::string& pairing_id, const std::string& pairing_secret);
63
64 // Terminates the current connection (if it hasn't already failed) and cleans
65 // up. Must be called before destruction can occur or a memory leak may occur.
66 void Cleanup();
67
68 // Notifies the user interface that the user needs to enter a PIN. The
69 // current authentication attempt is put on hold until |callback| is invoked.
70 // May be called on any thread.
71 void FetchSecret(bool pairable,
72 const protocol::SecretFetchedCallback& callback);
73
74 // Provides the user's PIN and resumes the host authentication attempt. Call
75 // on the UI thread once the user has finished entering this PIN into the UI,
76 // but only after the UI has been asked to provide a PIN (via FetchSecret()).
77 void ProvideSecret(const std::string& pin,
78 bool create_pair,
79 const std::string& device_id);
80
81 // Moves the host's cursor to the specified coordinates, optionally with some
82 // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made.
83 void PerformMouseAction(const webrtc::DesktopVector& position,
84 const webrtc::DesktopVector& wheel_delta,
85 protocol::MouseEvent_MouseButton button,
86 bool button_down);
87
88 // Sends the provided keyboard scan code to the host.
89 void PerformKeyboardAction(int key_code, bool key_down);
90
91 // ClientUserInterface implementation.
92 void OnConnectionState(protocol::ConnectionToHost::State state,
93 protocol::ErrorCode error) override;
94 void OnConnectionReady(bool ready) override;
95 void OnRouteChanged(const std::string& channel_name,
96 const protocol::TransportRoute& route) override;
97 void SetCapabilities(const std::string& capabilities) override;
98 void SetPairingResponse(const protocol::PairingResponse& response) override;
99 void DeliverHostMessage(const protocol::ExtensionMessage& message) override;
100 protocol::ClipboardStub* GetClipboardStub() override;
101 protocol::CursorShapeStub* GetCursorShapeStub() override;
102
103 // CursorShapeStub implementation.
104 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
105
106 // ClipboardStub implementation.
107 void SetCursorShape(const protocol::CursorShapeInfo& shape) override;
108
109 void SetDesktopSize(const webrtc::DesktopSize& size,
110 const webrtc::DesktopVector& dpi) override;
111
112 scoped_refptr<AutoThreadTaskRunner> display_task_runner() {
113 return ui_task_runner_;
114 }
115
116 scoped_refptr<AutoThreadTaskRunner> network_task_runner() {
117 return network_task_runner_;
118 }
119
120 scoped_refptr<AutoThreadTaskRunner> file_task_runner() {
121 return file_task_runner_;
122 }
123
124 scoped_refptr<AutoThreadTaskRunner> audio_task_runner() {
125 return audio_task_runner_;
126 }
127
128 private:
129 // This object is ref-counted, so it cleans itself up.
130 ~ClientInstance() override;
131
132 void ConnectToHostOnNetworkThread();
133 void DisconnectFromHostOnNetworkThread();
134
135 void HandleConnectionStateOnUIThread(protocol::ConnectionToHost::State state,
136 protocol::ErrorCode error);
137
138 // Request pairing from the host.
139 void DoPairing();
140
141 // base::WeakPtr<protocol::AudioStub> GetAudioConsumer();
142
143 // Proxy to exchange messages between the
144 // common Chromoting protocol and UI Application.
145 base::WeakPtr<ClientProxy> proxyToClient_;
146
147 // ID of the host we are connecting to.
148 std::string host_jid_;
149
150 protocol::ClientAuthenticationConfig client_auth_config_;
151
152 // This group of variables is to be used on the display thread.
153 std::unique_ptr<SoftwareVideoRenderer> video_renderer_;
154 std::unique_ptr<FrameConsumerBridge> view_;
155
156 // This group of variables is to be used on the network thread.
157 std::unique_ptr<ClientContext> client_context_;
158 std::unique_ptr<protocol::PerformanceTracker> perf_tracker_;
159 std::unique_ptr<ChromotingClient> client_;
160 XmppSignalStrategy::XmppServerConfig xmpp_config_;
161 std::unique_ptr<XmppSignalStrategy> signaling_; // Must outlive client_
162
163 // TODO(nicholss): Migrate to ClientTelemetryLogger
164 // std::unique_ptr<ClientStatusLogger> client_status_logger_;
165
166 // This group of variables is to be used on the audio thread.
167 // std::unique_ptr<AudioPlayerIos> audio_player_;
168
169 // Pass this the user's PIN once we have it. To be assigned and accessed on
170 // the UI thread, but must be posted to the network thread to call it.
171 protocol::SecretFetchedCallback pin_callback_;
172
173 // Indicates whether to establish a new pairing with this host. This is
174 // modified in ProvideSecret(), but thereafter to be used only from the
175 // network thread. (This is safe because ProvideSecret() is invoked at most
176 // once per run, and always before any reference to this flag.)
177 bool create_pairing_ = false;
178
179 // A unique identifier for the user's device.
180 // Only to be used when a pairing is created.
181 std::string device_id_;
182
183 // Chromium code's connection to the OBJ_C message loop. Once created the
184 // MessageLoop will live for the life of the program. An attempt was made to
185 // create the primary message loop earlier in the programs life, but a
186 // MessageLoop requires ARC to be disabled.
187 base::MessageLoop* ui_loop_;
188
189 // References to native threads.
190 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
191 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
192 scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
193 scoped_refptr<AutoThreadTaskRunner> audio_task_runner_;
194
195 scoped_refptr<net::URLRequestContextGetter> url_requester_;
196
197 friend class base::RefCountedThreadSafe<ClientInstance>;
198
199 DISALLOW_COPY_AND_ASSIGN(ClientInstance);
200 };
201
202 } // namespace remoting
203
204 #endif // REMOTING_CLIENT_IOS_BRIDGE_CLIENT_INSTANCE_H_
OLDNEW
« no previous file with comments | « remoting/client/ios/bridge/DEPS ('k') | remoting/client/ios/bridge/client_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698