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

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

Issue 475333004: Remove old Chromoting iOS client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/ios/bridge/DEPS ('k') | remoting/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 2014 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_IOS_BRIDGE_CLIENT_INSTANCE_H_
6 #define REMOTING_IOS_BRIDGE_CLIENT_INSTANCE_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h"
14 #include "net/url_request/url_request_context_getter.h"
15 #include "remoting/base/auto_thread.h"
16 #include "remoting/client/chromoting_client.h"
17 #include "remoting/client/client_context.h"
18 #include "remoting/client/client_user_interface.h"
19 #include "remoting/client/frame_consumer_proxy.h"
20 #include "remoting/client/software_video_renderer.h"
21 #include "remoting/ios/bridge/frame_consumer_bridge.h"
22 #include "remoting/protocol/clipboard_stub.h"
23 #include "remoting/protocol/cursor_shape_stub.h"
24 #include "remoting/protocol/network_settings.h"
25 #include "remoting/signaling/xmpp_signal_strategy.h"
26
27 namespace remoting {
28
29 class ClientProxy;
30
31 // ClientUserInterface that indirectly makes and receives OBJ_C calls from the
32 // UI application
33 class ClientInstance : public ClientUserInterface,
34 public protocol::ClipboardStub,
35 public protocol::CursorShapeStub,
36 public base::RefCountedThreadSafe<ClientInstance> {
37 public:
38 // Initiates a connection with the specified host. Call from the UI thread. To
39 // connect with an unpaired host, pass in |pairing_id| and |pairing_secret| as
40 // empty strings.
41 ClientInstance(const base::WeakPtr<ClientProxy>& proxy,
42 const std::string& username,
43 const std::string& auth_token,
44 const std::string& host_jid,
45 const std::string& host_id,
46 const std::string& host_pubkey,
47 const std::string& pairing_id,
48 const std::string& pairing_secret);
49
50 // Begins the connection process. Should not be called again until after
51 // |CleanUp|
52 void Start();
53
54 // Terminates the current connection (if it hasn't already failed) and cleans
55 // up. Must be called before destruction can occur or a memory leak may occur.
56 void Cleanup();
57
58 // Notifies the user interface that the user needs to enter a PIN. The
59 // current authentication attempt is put on hold until |callback| is invoked.
60 // May be called on any thread.
61 void FetchSecret(bool pairable,
62 const protocol::SecretFetchedCallback& callback);
63
64 // Provides the user's PIN and resumes the host authentication attempt. Call
65 // on the UI thread once the user has finished entering this PIN into the UI,
66 // but only after the UI has been asked to provide a PIN (via FetchSecret()).
67 void ProvideSecret(const std::string& pin, bool create_pair);
68
69 // Moves the host's cursor to the specified coordinates, optionally with some
70 // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made.
71 void PerformMouseAction(
72 const webrtc::DesktopVector& position,
73 const webrtc::DesktopVector& wheel_delta,
74 int /* protocol::MouseEvent_MouseButton */ whichButton,
75 bool button_down);
76
77 // Sends the provided keyboard scan code to the host.
78 void PerformKeyboardAction(int key_code, bool key_down);
79
80 // ClientUserInterface implementation.
81 virtual void OnConnectionState(protocol::ConnectionToHost::State state,
82 protocol::ErrorCode error) OVERRIDE;
83 virtual void OnConnectionReady(bool ready) OVERRIDE;
84 virtual void OnRouteChanged(const std::string& channel_name,
85 const protocol::TransportRoute& route) OVERRIDE;
86 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE;
87 virtual void SetPairingResponse(const protocol::PairingResponse& response)
88 OVERRIDE;
89 virtual void DeliverHostMessage(const protocol::ExtensionMessage& message)
90 OVERRIDE;
91 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE;
92 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE;
93
94 // CursorShapeStub implementation.
95 virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event)
96 OVERRIDE;
97
98 // ClipboardStub implementation.
99 virtual void SetCursorShape(const protocol::CursorShapeInfo& shape) OVERRIDE;
100
101 private:
102 // This object is ref-counted, so it cleans itself up.
103 virtual ~ClientInstance();
104
105 void ConnectToHostOnNetworkThread(
106 scoped_refptr<FrameConsumerProxy> consumer_proxy,
107 const base::Closure& done);
108 void DisconnectFromHostOnNetworkThread(const base::Closure& done);
109
110 // Proxy to exchange messages between the
111 // common Chromoting protocol and UI Application.
112 base::WeakPtr<ClientProxy> proxyToClient_;
113
114 // ID of the host we are connecting to.
115 std::string host_id_;
116 std::string host_jid_;
117
118 // This group of variables is to be used on the display thread.
119 scoped_ptr<SoftwareVideoRenderer> video_renderer_;
120 scoped_ptr<FrameConsumerBridge> view_;
121
122 // This group of variables is to be used on the network thread.
123 scoped_ptr<ClientContext> client_context_;
124 scoped_ptr<protocol::Authenticator> authenticator_;
125 scoped_ptr<ChromotingClient> client_;
126 XmppSignalStrategy::XmppServerConfig xmpp_config_;
127 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_
128
129 // Pass this the user's PIN once we have it. To be assigned and accessed on
130 // the UI thread, but must be posted to the network thread to call it.
131 protocol::SecretFetchedCallback pin_callback_;
132
133 // Indicates whether to establish a new pairing with this host. This is
134 // modified in ProvideSecret(), but thereafter to be used only from the
135 // network thread. (This is safe because ProvideSecret() is invoked at most
136 // once per run, and always before any reference to this flag.)
137 bool create_pairing_;
138
139 // Chromium code's connection to the OBJ_C message loop. Once created the
140 // MessageLoop will live for the life of the program. An attempt was made to
141 // create the primary message loop earlier in the programs life, but a
142 // MessageLoop requires ARC to be disabled.
143 base::MessageLoopForUI* ui_loop_;
144
145 // References to native threads.
146 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
147 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
148
149 scoped_refptr<net::URLRequestContextGetter> url_requester_;
150
151 friend class base::RefCountedThreadSafe<ClientInstance>;
152
153 DISALLOW_COPY_AND_ASSIGN(ClientInstance);
154 };
155
156 } // namespace remoting
157
158 #endif // REMOTING_IOS_BRIDGE_CLIENT_INSTANCE_H_
OLDNEW
« no previous file with comments | « remoting/ios/bridge/DEPS ('k') | remoting/ios/bridge/client_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698