| 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_JNI_CHROMOTING_JNI_RUNTIME_H_ | 5 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ |
| 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ | 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { | 38 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
| 39 return display_task_runner_; | 39 return display_task_runner_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 scoped_refptr<net::URLRequestContextGetter> url_requester() { | 42 scoped_refptr<net::URLRequestContextGetter> url_requester() { |
| 43 return url_requester_; | 43 return url_requester_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // Initiates a connection with the specified host. Only call when a host | 46 // Initiates a connection with the specified host. Only call when a host |
| 47 // connection is active (i.e. between a call to Connect() and the | 47 // connection is active (i.e. between a call to Connect() and the |
| 48 // corresponding call to Disconnect()). | 48 // corresponding call to Disconnect()). To skip the attempt at pair-based |
| 49 // authentication, leave |pairing_id| and |pairing_secret| as empty strings. |
| 49 void ConnectToHost(const char* username, | 50 void ConnectToHost(const char* username, |
| 50 const char* auth_token, | 51 const char* auth_token, |
| 51 const char* host_jid, | 52 const char* host_jid, |
| 52 const char* host_id, | 53 const char* host_id, |
| 53 const char* host_pubkey); | 54 const char* host_pubkey, |
| 55 const char* pairing_id, |
| 56 const char* pairing_secret); |
| 54 | 57 |
| 55 // Terminates any ongoing connection attempt and cleans up by nullifying | 58 // Terminates any ongoing connection attempt and cleans up by nullifying |
| 56 // |session_|. This is a no-op unless |session| is currently non-null. | 59 // |session_|. This is a no-op unless |session| is currently non-null. |
| 57 void DisconnectFromHost(); | 60 void DisconnectFromHost(); |
| 58 | 61 |
| 59 // Returns the client for the currently-active session. Do not call if | 62 // Returns the client for the currently-active session. Do not call if |
| 60 // |session| is null. | 63 // |session| is null. |
| 61 scoped_refptr<ChromotingJniInstance> session() { | 64 scoped_refptr<ChromotingJniInstance> session() { |
| 62 DCHECK(session_); | 65 DCHECK(session_); |
| 63 return session_; | 66 return session_; |
| 64 } | 67 } |
| 65 | 68 |
| 66 // Notifies the user that the connection status has changed. | 69 // Notifies the user of the current connection status. Call on UI thread. |
| 67 void ReportConnectionStatus(protocol::ConnectionToHost::State state, | 70 void ReportConnectionStatus(protocol::ConnectionToHost::State state, |
| 68 protocol::ErrorCode error); | 71 protocol::ErrorCode error); |
| 69 | 72 |
| 70 // Pops up a dialog box asking the user to enter a PIN. | 73 // Pops up a dialog box asking the user to enter a PIN. Call on UI thread. |
| 71 void DisplayAuthenticationPrompt(); | 74 void DisplayAuthenticationPrompt(); |
| 72 | 75 |
| 76 // Saves new pairing credentials to permanent storage. Call on UI thread. |
| 77 void CommitPairingCredentials(const std::string& host, |
| 78 const std::string& id, |
| 79 const std::string& secret); |
| 80 |
| 73 // Updates image dimensions and canvas memory space. Call on display thread. | 81 // Updates image dimensions and canvas memory space. Call on display thread. |
| 74 void UpdateImageBuffer(int width, int height, jobject buffer); | 82 void UpdateImageBuffer(int width, int height, jobject buffer); |
| 75 | 83 |
| 76 // Draws the latest image buffer onto the canvas. Call on the display thread. | 84 // Draws the latest image buffer onto the canvas. Call on the display thread. |
| 77 void RedrawCanvas(); | 85 void RedrawCanvas(); |
| 78 | 86 |
| 79 private: | 87 private: |
| 80 ChromotingJniRuntime(); | 88 ChromotingJniRuntime(); |
| 81 | 89 |
| 82 // Forces a DisconnectFromHost() in case there is any active or failed | 90 // Forces a DisconnectFromHost() in case there is any active or failed |
| (...skipping 24 matching lines...) Expand all Loading... |
| 107 scoped_refptr<ChromotingJniInstance> session_; | 115 scoped_refptr<ChromotingJniInstance> session_; |
| 108 | 116 |
| 109 friend struct DefaultSingletonTraits<ChromotingJniRuntime>; | 117 friend struct DefaultSingletonTraits<ChromotingJniRuntime>; |
| 110 | 118 |
| 111 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); | 119 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); |
| 112 }; | 120 }; |
| 113 | 121 |
| 114 } // namespace remoting | 122 } // namespace remoting |
| 115 | 123 |
| 116 #endif | 124 #endif |
| OLD | NEW |