OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_HOST_ANDROID_JNI_HOST_H_ | 5 #ifndef REMOTING_HOST_ANDROID_JNI_HOST_H_ |
6 #define REMOTING_HOST_ANDROID_JNI_HOST_H_ | 6 #define REMOTING_HOST_ANDROID_JNI_HOST_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" |
| 17 #include "remoting/host/it2me/it2me_host.h" |
12 | 18 |
13 namespace remoting { | 19 namespace remoting { |
14 | 20 |
15 class JniHost { | 21 class ChromotingHostContext; |
| 22 class It2MeHostFactory; |
| 23 |
| 24 class JniHost : public It2MeHost::Observer { |
16 public: | 25 public: |
17 JniHost(); | 26 JniHost(); |
18 ~JniHost(); | 27 virtual ~JniHost(); |
19 | 28 |
20 // Register C++ methods exposed to Java using JNI. | 29 // Register C++ methods exposed to Java using JNI. |
21 static bool RegisterJni(JNIEnv* env); | 30 static bool RegisterJni(JNIEnv* env); |
22 | 31 |
23 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& caller); | 32 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& caller); |
24 | 33 |
| 34 void Connect(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& caller, |
| 36 const base::android::JavaParamRef<jstring>& user_name, |
| 37 const base::android::JavaParamRef<jstring>& auth_token); |
| 38 |
| 39 void Disconnect(JNIEnv* env, |
| 40 const base::android::JavaParamRef<jobject>& caller); |
| 41 |
| 42 // It2MeHost::Observer implementation. |
| 43 void OnClientAuthenticated(const std::string& client_username) override; |
| 44 void OnStoreAccessCode(const std::string& access_code, |
| 45 base::TimeDelta access_code_lifetime) override; |
| 46 void OnNatPolicyChanged(bool nat_traversal_enabled) override; |
| 47 void OnStateChanged(It2MeHostState state, |
| 48 const std::string& error_message) override; |
| 49 |
25 private: | 50 private: |
| 51 std::unique_ptr<base::MessageLoopForUI> ui_loop_; |
| 52 std::unique_ptr<ChromotingHostContext> host_context_; |
| 53 std::unique_ptr<It2MeHostFactory> factory_; |
| 54 scoped_refptr<It2MeHost> it2me_host_; |
| 55 |
| 56 // IT2Me Talk server configuration used by |it2me_host_| to connect. |
| 57 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
| 58 |
| 59 base::WeakPtr<JniHost> weak_ptr_; |
| 60 base::WeakPtrFactory<JniHost> weak_factory_; |
| 61 |
26 DISALLOW_COPY_AND_ASSIGN(JniHost); | 62 DISALLOW_COPY_AND_ASSIGN(JniHost); |
27 }; | 63 }; |
28 | 64 |
29 } // namespace remoting | 65 } // namespace remoting |
30 | 66 |
31 #endif // REMOTING_HOST_ANDROID_JNI_HOST_H_ | 67 #endif // REMOTING_HOST_ANDROID_JNI_HOST_H_ |
OLD | NEW |