| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | 5 #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
| 6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | 6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "remoting/client/chromoting_client.h" | 14 #include "remoting/client/chromoting_client.h" |
| 15 #include "remoting/client/client_context.h" | 15 #include "remoting/client/client_context.h" |
| 16 #include "remoting/client/client_user_interface.h" | 16 #include "remoting/client/client_user_interface.h" |
| 17 #include "remoting/client/frame_consumer_proxy.h" | |
| 18 #include "remoting/client/jni/jni_frame_consumer.h" | |
| 19 #include "remoting/protocol/clipboard_stub.h" | 17 #include "remoting/protocol/clipboard_stub.h" |
| 20 #include "remoting/protocol/cursor_shape_stub.h" | 18 #include "remoting/protocol/cursor_shape_stub.h" |
| 21 #include "remoting/signaling/xmpp_signal_strategy.h" | 19 #include "remoting/signaling/xmpp_signal_strategy.h" |
| 22 | 20 |
| 23 namespace remoting { | 21 namespace remoting { |
| 24 | 22 |
| 25 namespace protocol { | 23 namespace protocol { |
| 26 class ClipboardEvent; | 24 class ClipboardEvent; |
| 27 class CursorShapeInfo; | 25 class CursorShapeInfo; |
| 28 } // namespace protocol | 26 } // namespace protocol |
| 29 | 27 |
| 28 class ChromotingJniRuntime; |
| 30 class ClientStatusLogger; | 29 class ClientStatusLogger; |
| 30 class JniFrameConsumer; |
| 31 class TokenFetcherProxy; |
| 31 class VideoRenderer; | 32 class VideoRenderer; |
| 32 class TokenFetcherProxy; | |
| 33 | 33 |
| 34 // ClientUserInterface that indirectly makes and receives JNI calls. | 34 // ClientUserInterface that indirectly makes and receives JNI calls. |
| 35 class ChromotingJniInstance | 35 class ChromotingJniInstance |
| 36 : public ClientUserInterface, | 36 : public ClientUserInterface, |
| 37 public protocol::ClipboardStub, | 37 public protocol::ClipboardStub, |
| 38 public protocol::CursorShapeStub, | 38 public protocol::CursorShapeStub, |
| 39 public base::RefCountedThreadSafe<ChromotingJniInstance> { | 39 public base::RefCountedThreadSafe<ChromotingJniInstance> { |
| 40 public: | 40 public: |
| 41 // Initiates a connection with the specified host. Call from the UI thread. | 41 // Initiates a connection with the specified host. Call from the UI thread. |
| 42 // The instance does not take ownership of |jni_runtime|. To connect with an | 42 // The instance does not take ownership of |jni_runtime|. To connect with an |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // CursorShapeStub implementation. | 111 // CursorShapeStub implementation. |
| 112 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; | 112 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; |
| 113 | 113 |
| 114 // ClipboardStub implementation. | 114 // ClipboardStub implementation. |
| 115 void SetCursorShape(const protocol::CursorShapeInfo& shape) override; | 115 void SetCursorShape(const protocol::CursorShapeInfo& shape) override; |
| 116 | 116 |
| 117 private: | 117 private: |
| 118 // This object is ref-counted, so it cleans itself up. | 118 // This object is ref-counted, so it cleans itself up. |
| 119 ~ChromotingJniInstance() override; | 119 ~ChromotingJniInstance() override; |
| 120 | 120 |
| 121 void ConnectToHostOnDisplayThread(); | 121 void ConnectToHostOnNetworkThread(); |
| 122 void ConnectToHostOnNetworkThread( | |
| 123 scoped_ptr<FrameConsumerProxy> frame_consumer); | |
| 124 void DisconnectFromHostOnNetworkThread(); | |
| 125 | 122 |
| 126 // Notifies the user interface that the user needs to enter a PIN. The | 123 // Notifies the user interface that the user needs to enter a PIN. The |
| 127 // current authentication attempt is put on hold until |callback| is invoked. | 124 // current authentication attempt is put on hold until |callback| is invoked. |
| 128 // May be called on any thread. | 125 // May be called on any thread. |
| 129 void FetchSecret(bool pairable, | 126 void FetchSecret(bool pairable, |
| 130 const protocol::SecretFetchedCallback& callback); | 127 const protocol::SecretFetchedCallback& callback); |
| 131 | 128 |
| 132 // Sets the device name. Can be called on any thread. | 129 // Sets the device name. Can be called on any thread. |
| 133 void SetDeviceName(const std::string& device_name); | 130 void SetDeviceName(const std::string& device_name); |
| 134 | 131 |
| 135 void SendKeyEventInternal(int usb_key_code, bool key_down); | 132 void SendKeyEventInternal(int usb_key_code, bool key_down); |
| 136 | 133 |
| 137 // Enables or disables periodic logging of performance statistics. Called on | 134 // Enables or disables periodic logging of performance statistics. Called on |
| 138 // the network thread. | 135 // the network thread. |
| 139 void EnableStatsLogging(bool enabled); | 136 void EnableStatsLogging(bool enabled); |
| 140 | 137 |
| 141 // If logging is enabled, logs the current connection statistics, and | 138 // If logging is enabled, logs the current connection statistics, and |
| 142 // triggers another call to this function after the logging time interval. | 139 // triggers another call to this function after the logging time interval. |
| 143 // Called on the network thread. | 140 // Called on the network thread. |
| 144 void LogPerfStats(); | 141 void LogPerfStats(); |
| 145 | 142 |
| 146 // Used to obtain task runner references and make calls to Java methods. | 143 // Used to obtain task runner references and make calls to Java methods. |
| 147 ChromotingJniRuntime* jni_runtime_; | 144 ChromotingJniRuntime* jni_runtime_; |
| 148 | 145 |
| 149 // ID of the host we are connecting to. | 146 // ID of the host we are connecting to. |
| 150 std::string host_id_; | 147 std::string host_id_; |
| 151 std::string host_jid_; | 148 std::string host_jid_; |
| 152 | 149 |
| 153 // This group of variables is to be used on the display thread. | |
| 154 scoped_ptr<JniFrameConsumer> view_; | |
| 155 scoped_ptr<base::WeakPtrFactory<JniFrameConsumer>> view_weak_factory_; | |
| 156 | |
| 157 // This group of variables is to be used on the network thread. | 150 // This group of variables is to be used on the network thread. |
| 158 scoped_ptr<ClientContext> client_context_; | 151 scoped_ptr<ClientContext> client_context_; |
| 152 scoped_ptr<JniFrameConsumer> view_; |
| 159 scoped_ptr<VideoRenderer> video_renderer_; | 153 scoped_ptr<VideoRenderer> video_renderer_; |
| 160 scoped_ptr<protocol::Authenticator> authenticator_; | 154 scoped_ptr<protocol::Authenticator> authenticator_; |
| 161 scoped_ptr<ChromotingClient> client_; | 155 scoped_ptr<ChromotingClient> client_; |
| 162 XmppSignalStrategy::XmppServerConfig xmpp_config_; | 156 XmppSignalStrategy::XmppServerConfig xmpp_config_; |
| 163 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ | 157 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ |
| 164 scoped_ptr<ClientStatusLogger> client_status_logger_; | 158 scoped_ptr<ClientStatusLogger> client_status_logger_; |
| 165 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy_; | 159 base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy_; |
| 166 | 160 |
| 167 // Pass this the user's PIN once we have it. To be assigned and accessed on | 161 // Pass this the user's PIN once we have it. To be assigned and accessed on |
| 168 // the UI thread, but must be posted to the network thread to call it. | 162 // the UI thread, but must be posted to the network thread to call it. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 190 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; | 184 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; |
| 191 | 185 |
| 192 base::WeakPtrFactory<ChromotingJniInstance> weak_factory_; | 186 base::WeakPtrFactory<ChromotingJniInstance> weak_factory_; |
| 193 | 187 |
| 194 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); | 188 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); |
| 195 }; | 189 }; |
| 196 | 190 |
| 197 } // namespace remoting | 191 } // namespace remoting |
| 198 | 192 |
| 199 #endif | 193 #endif |
| OLD | NEW |