Index: remoting/client/jni/jni_runtime_delegate.h |
diff --git a/remoting/client/jni/jni_runtime_delegate.h b/remoting/client/jni/jni_runtime_delegate.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..741937b10f1ce178e81129da03df5c464c0b5ffb |
--- /dev/null |
+++ b/remoting/client/jni/jni_runtime_delegate.h |
@@ -0,0 +1,70 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ |
+#define REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ |
+ |
+#include <jni.h> |
+#include <string> |
+ |
+#include "base/android/scoped_java_ref.h" |
+#include "base/macros.h" |
+#include "net/url_request/url_request_context_getter.h" |
+#include "remoting/base/auto_thread.h" |
+#include "remoting/base/telemetry_log_writer.h" |
+#include "remoting/client/chromoting_client_runtime.h" |
+#include "remoting/client/jni/chromoting_jni_instance.h" |
+#include "remoting/protocol/connection_to_host.h" |
+ |
+namespace base { |
+template <typename T> |
+struct DefaultSingletonTraits; |
+} |
+ |
+namespace remoting { |
+ |
+bool RegisterJniRuntimeDelegate(JNIEnv* env); |
+ |
+// JniRuntimeDelegate is a singleton that hooks into delegate role for |
+// the ChromotingClientRuntime object. This class handles Android specific |
+// integrations for the runtime. Proxies outgoing JNI calls from |
+// ChromotingClientRuntime to Java. All its methods should be invoked |
+// exclusively from the UI thread unless otherwise noted. |
+class JniRuntimeDelegate : public ChromotingClientRuntime::Delegate { |
+ public: |
+ // This class is instantiated at process initialization and persists until |
+ // we close. Its components are reused across |JniRuntimeDelegate|s. |
+ static JniRuntimeDelegate* GetInstance(); |
+ |
+ // Fetch OAuth token for the telemetry logger. Call on UI thread. |
+ void FetchAuthToken(); |
+ |
+ // remoting::ChromotingClientRuntime::Delegate overrides. |
+ void RuntimeWillShutdown() override; |
+ void RuntimeDidShutdown() override; |
+ void RequestAuthTokenForLogger() override; |
+ |
+ private: |
+ JniRuntimeDelegate(); |
+ |
+ // Forces a DisconnectFromHost() in case there is any active or failed |
+ // connection, then proceeds to tear down the Chromium dependencies on which |
+ // all sessions depended. Because destruction only occurs at application exit |
+ // after all connections have terminated, it is safe to make unretained |
+ // cross-thread calls on the class. |
+ ~JniRuntimeDelegate() override; |
+ |
+ // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. |
+ void DetachFromVmAndSignal(base::WaitableEvent* waiter); |
+ |
+ ChromotingClientRuntime* runtime_; |
+ |
+ friend struct base::DefaultSingletonTraits<JniRuntimeDelegate>; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(JniRuntimeDelegate); |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ |