| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_ANDROID_JNI_HOST_H_ | |
| 6 #define REMOTING_HOST_ANDROID_JNI_HOST_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/android/scoped_java_ref.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" | |
| 18 | |
| 19 namespace remoting { | |
| 20 | |
| 21 class ChromotingHostContext; | |
| 22 class It2MeHostFactory; | |
| 23 | |
| 24 class JniHost : public It2MeHost::Observer { | |
| 25 public: | |
| 26 JniHost(JNIEnv* env, jobject java_host); | |
| 27 virtual ~JniHost(); | |
| 28 | |
| 29 // Register C++ methods exposed to Java using JNI. | |
| 30 static bool RegisterJni(JNIEnv* env); | |
| 31 | |
| 32 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& caller); | |
| 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 | |
| 50 private: | |
| 51 base::android::ScopedJavaGlobalRef<jobject> java_host_; | |
| 52 | |
| 53 std::unique_ptr<base::MessageLoopForUI> ui_loop_; | |
| 54 std::unique_ptr<ChromotingHostContext> host_context_; | |
| 55 std::unique_ptr<It2MeHostFactory> factory_; | |
| 56 scoped_refptr<It2MeHost> it2me_host_; | |
| 57 | |
| 58 // IT2Me Talk server configuration used by |it2me_host_| to connect. | |
| 59 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | |
| 60 | |
| 61 base::WeakPtr<JniHost> weak_ptr_; | |
| 62 base::WeakPtrFactory<JniHost> weak_factory_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(JniHost); | |
| 65 }; | |
| 66 | |
| 67 } // namespace remoting | |
| 68 | |
| 69 #endif // REMOTING_HOST_ANDROID_JNI_HOST_H_ | |
| OLD | NEW |