Chromium Code Reviews| 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..6afd4ba06de8208a31e5ab36c3df424f65a50109 |
| --- /dev/null |
| +++ b/remoting/client/jni/jni_runtime_delegate.h |
| @@ -0,0 +1,72 @@ |
| +// 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 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. |
| + virtual ~JniRuntimeDelegate(); |
| + |
| + // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. |
| + void DetachFromVmAndSignal(base::WaitableEvent* waiter); |
| + |
| + // Chromium code's connection to the app message loop. Once created the |
| + // MessageLoop will live for the life of the program. |
| + std::unique_ptr<base::MessageLoopForUI> ui_loop_; |
|
Yuwei
2017/03/10 20:18:53
Looks like this is not used anywhere.
But I do pr
nicholss
2017/03/10 20:53:11
Removed.
|
| + ChromotingClientRuntime* runtime_; |
| + |
| + friend struct base::DefaultSingletonTraits<JniRuntimeDelegate>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(JniRuntimeDelegate); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ |