| 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 | |
| 12 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/macros.h" | 11 #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" | |
| 18 | 12 |
| 19 namespace remoting { | 13 namespace remoting { |
| 20 | 14 |
| 21 class ChromotingHostContext; | 15 class JniHost { |
| 22 class It2MeHostFactory; | |
| 23 | |
| 24 class JniHost : public It2MeHost::Observer { | |
| 25 public: | 16 public: |
| 26 JniHost(); | 17 JniHost(); |
| 27 virtual ~JniHost(); | 18 ~JniHost(); |
| 28 | 19 |
| 29 // Register C++ methods exposed to Java using JNI. | 20 // Register C++ methods exposed to Java using JNI. |
| 30 static bool RegisterJni(JNIEnv* env); | 21 static bool RegisterJni(JNIEnv* env); |
| 31 | 22 |
| 32 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& caller); | 23 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& caller); |
| 33 | 24 |
| 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 | |
| 50 private: | 25 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 | |
| 62 DISALLOW_COPY_AND_ASSIGN(JniHost); | 26 DISALLOW_COPY_AND_ASSIGN(JniHost); |
| 63 }; | 27 }; |
| 64 | 28 |
| 65 } // namespace remoting | 29 } // namespace remoting |
| 66 | 30 |
| 67 #endif // REMOTING_HOST_ANDROID_JNI_HOST_H_ | 31 #endif // REMOTING_HOST_ANDROID_JNI_HOST_H_ |
| OLD | NEW |