Chromium Code Reviews| Index: remoting/client/jni/chromoting_jni_instance.h |
| diff --git a/remoting/client/jni/chromoting_jni_instance.h b/remoting/client/jni/chromoting_jni_instance.h |
| index ab9db60d354503d5f70c5a9a26e3edb4fccf0b3e..f733a4769c7f6f34d011331391b677f9b5a83b6e 100644 |
| --- a/remoting/client/jni/chromoting_jni_instance.h |
| +++ b/remoting/client/jni/chromoting_jni_instance.h |
| @@ -5,6 +5,7 @@ |
| #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
| #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
| +#include <remoting/client/jni/jni_secret_fetcher.h> |
|
Yuwei
2016/05/27 19:14:13
Oops... Autogenerated code. Should use double quot
Lambros
2016/05/28 00:43:05
Move this to the lower block of #includes.
Yuwei
2016/06/01 21:30:10
Done.
|
| #include <memory> |
| #include <string> |
| @@ -32,20 +33,24 @@ class VideoRenderer; |
| class ChromotingJniRuntime; |
| class JniClient; |
| +class JniDisplayHandler; |
| class JniFrameConsumer; |
| +class JniSecretFetcher; |
| -// ClientUserInterface that indirectly makes and receives JNI calls. |
| +// ChromotingJniInstance is scoped to the session. It must be deleted on the |
| +// network thread. |
|
Lambros
2016/05/28 00:43:05
Give a little more information here about threadin
Yuwei
2016/06/01 21:30:10
Done.
|
| class ChromotingJniInstance |
| : public ClientUserInterface, |
| public protocol::ClipboardStub, |
| - public protocol::CursorShapeStub, |
| - public base::RefCountedThreadSafe<ChromotingJniInstance> { |
| + public protocol::CursorShapeStub { |
| public: |
| // Initiates a connection with the specified host. Call from the UI thread. |
| // The instance does not take ownership of |jni_runtime|. To connect with an |
| // unpaired host, pass in |pairing_id| and |pairing_secret| as empty strings. |
| ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, |
| - JniClient* jni_client, |
| + base::WeakPtr<JniClient> jni_client, |
| + base::WeakPtr<JniDisplayHandler> display, |
| + base::WeakPtr<JniSecretFetcher> secret_fetcher, |
| const std::string& username, |
| const std::string& auth_token, |
| const std::string& host_jid, |
| @@ -56,6 +61,8 @@ class ChromotingJniInstance |
| const std::string& capabilities, |
| const std::string& flags); |
| + ~ChromotingJniInstance() override; |
| + |
| // Terminates the current connection (if it hasn't already failed) and cleans |
| // up. The instance will no longer be valid after calling this function. |
| // Must be called before destruction. |
| @@ -78,9 +85,6 @@ class ChromotingJniInstance |
| void ProvideSecret(const std::string& pin, bool create_pair, |
| const std::string& device_name); |
| - // Schedules a redraw on the display thread. May be called from any thread. |
| - void RedrawDesktop(); |
| - |
| // Moves the host's cursor to the specified coordinates, optionally with some |
| // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made. |
| void SendMouseEvent(int x, int y, |
| @@ -121,10 +125,11 @@ class ChromotingJniInstance |
| // ClipboardStub implementation. |
| void SetCursorShape(const protocol::CursorShapeInfo& shape) override; |
| - private: |
| - // This object is ref-counted, so it cleans itself up. |
| - ~ChromotingJniInstance() override; |
| + // Get the weak pointer of the instance. Please only use it on the network |
| + // thread. |
| + base::WeakPtr<ChromotingJniInstance> GetWeakPtr(); |
| + private: |
| void ConnectToHostOnNetworkThread(); |
| // Notifies the user interface that the user needs to enter a PIN. The |
| @@ -147,10 +152,17 @@ class ChromotingJniInstance |
| // Called on the network thread. |
| void LogPerfStats(); |
| + // Releases the resource in the right order. |
| + void Destroy(); |
| + |
| // Used to obtain task runner references and make calls to Java methods. |
| ChromotingJniRuntime* jni_runtime_; |
| - JniClient* jni_client_; |
| + base::WeakPtr<JniClient> jni_client_; |
| + |
| + base::WeakPtr<JniDisplayHandler> display_handler_; |
| + |
| + base::WeakPtr<JniSecretFetcher> secret_fetcher_; |
| // ID of the host we are connecting to. |
| std::string host_jid_; |
| @@ -169,10 +181,6 @@ class ChromotingJniInstance |
| std::unique_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ |
| protocol::ThirdPartyTokenFetchedCallback third_party_token_fetched_callback_; |
| - // Pass this the user's PIN once we have it. To be assigned and accessed on |
| - // the UI thread, but must be posted to the network thread to call it. |
| - protocol::SecretFetchedCallback pin_callback_; |
| - |
| // Indicates whether to establish a new pairing with this host. This is |
| // modified in ProvideSecret(), but thereafter to be used only from the |
| // network thread. (This is safe because ProvideSecret() is invoked at most |
| @@ -196,8 +204,6 @@ class ChromotingJniInstance |
| // thread. |
| bool connected_ = false; |
| - friend class base::RefCountedThreadSafe<ChromotingJniInstance>; |
| - |
| base::WeakPtrFactory<ChromotingJniInstance> weak_factory_; |
| DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); |