Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ | |
| 6 #define REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/android/scoped_java_ref.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "net/url_request/url_request_context_getter.h" | |
| 14 #include "remoting/base/auto_thread.h" | |
| 15 #include "remoting/base/telemetry_log_writer.h" | |
| 16 #include "remoting/client/chromoting_client_runtime.h" | |
| 17 #include "remoting/client/jni/chromoting_jni_instance.h" | |
| 18 #include "remoting/protocol/connection_to_host.h" | |
| 19 | |
| 20 namespace base { | |
| 21 template <typename T> | |
| 22 struct DefaultSingletonTraits; | |
| 23 } | |
| 24 | |
| 25 namespace remoting { | |
| 26 | |
| 27 bool RegisterJniRuntimeDelegate(JNIEnv* env); | |
| 28 | |
| 29 // JniRuntimeDelegate is a singleton that hooks into delegate role for | |
| 30 // the ChromotingClientRuntime object. This class handles Android specific | |
| 31 // integrations for the runtime. Proxies outgoing JNI calls from | |
| 32 // ChromotingClientRuntime to Java. All its methods should be invoked | |
| 33 // exclusively from the UI thread unless otherwise noted. | |
| 34 class JniRuntimeDelegate : public ChromotingClientRuntime::Delegate { | |
| 35 public: | |
| 36 // This class is instantiated at process initialization and persists until | |
| 37 // we close. Its components are reused across |JniRuntimeDelegate|s. | |
| 38 static JniRuntimeDelegate* GetInstance(); | |
| 39 | |
| 40 // Fetch OAuth token for the telemetry logger. Call on UI thread. | |
| 41 void FetchAuthToken(); | |
| 42 | |
| 43 // remoting::ChromotingClientRuntime::Delegate overrides. | |
| 44 void RuntimeWillShutdown() override; | |
| 45 void RequestAuthTokenForLogger() override; | |
| 46 | |
| 47 private: | |
| 48 JniRuntimeDelegate(); | |
| 49 | |
| 50 // Forces a DisconnectFromHost() in case there is any active or failed | |
| 51 // connection, then proceeds to tear down the Chromium dependencies on which | |
| 52 // all sessions depended. Because destruction only occurs at application exit | |
| 53 // after all connections have terminated, it is safe to make unretained | |
| 54 // cross-thread calls on the class. | |
| 55 virtual ~JniRuntimeDelegate(); | |
| 56 | |
| 57 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. | |
| 58 void DetachFromVmAndSignal(base::WaitableEvent* waiter); | |
| 59 | |
| 60 // Chromium code's connection to the app message loop. Once created the | |
| 61 // MessageLoop will live for the life of the program. | |
| 62 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.
| |
| 63 ChromotingClientRuntime* runtime_; | |
| 64 | |
| 65 friend struct base::DefaultSingletonTraits<JniRuntimeDelegate>; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(JniRuntimeDelegate); | |
| 68 }; | |
| 69 | |
| 70 } // namespace remoting | |
| 71 | |
| 72 #endif // REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ | |
| OLD | NEW |