OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ | 5 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ |
6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ | 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
14 #include "remoting/base/auto_thread.h" | 14 #include "remoting/base/auto_thread.h" |
| 15 #include "remoting/base/telemetry_log_writer.h" |
15 #include "remoting/client/chromoting_client_runtime.h" | 16 #include "remoting/client/chromoting_client_runtime.h" |
16 #include "remoting/client/client_telemetry_logger.h" | |
17 #include "remoting/client/jni/chromoting_jni_instance.h" | 17 #include "remoting/client/jni/chromoting_jni_instance.h" |
18 #include "remoting/protocol/connection_to_host.h" | 18 #include "remoting/protocol/connection_to_host.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 template<typename T> struct DefaultSingletonTraits; | 21 template<typename T> struct DefaultSingletonTraits; |
22 } | 22 } |
23 | 23 |
24 namespace remoting { | 24 namespace remoting { |
25 | 25 |
26 bool RegisterChromotingJniRuntime(JNIEnv* env); | 26 bool RegisterChromotingJniRuntime(JNIEnv* env); |
(...skipping 17 matching lines...) Expand all Loading... |
44 } | 44 } |
45 | 45 |
46 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { | 46 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
47 return runtime_->display_task_runner(); | 47 return runtime_->display_task_runner(); |
48 } | 48 } |
49 | 49 |
50 scoped_refptr<net::URLRequestContextGetter> url_requester() { | 50 scoped_refptr<net::URLRequestContextGetter> url_requester() { |
51 return runtime_->url_requester(); | 51 return runtime_->url_requester(); |
52 } | 52 } |
53 | 53 |
54 // The runtime handles authentication and the caller should not call SetAuth*. | 54 // Returns the log writer that can be used by ClientTelemetryLogger to send |
55 // The runtime itself will not send out any logs. Used on the network thread. | 55 // out logs. |
56 ClientTelemetryLogger* logger() { | 56 // Method must be called and returned object must be used on the network |
57 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread()); | 57 // thread. |
58 DCHECK(logger_); | 58 TelemetryLogWriter* GetLogWriter(); |
59 return logger_.get(); | |
60 } | |
61 | 59 |
62 // Fetch OAuth token for the telemetry logger. Call on UI thread. | 60 // Fetch OAuth token for the telemetry logger. Call on UI thread. |
63 void FetchAuthToken(); | 61 void FetchAuthToken(); |
64 | 62 |
65 private: | 63 private: |
66 ChromotingJniRuntime(); | 64 ChromotingJniRuntime(); |
67 | 65 |
68 // Forces a DisconnectFromHost() in case there is any active or failed | 66 // Forces a DisconnectFromHost() in case there is any active or failed |
69 // connection, then proceeds to tear down the Chromium dependencies on which | 67 // connection, then proceeds to tear down the Chromium dependencies on which |
70 // all sessions depended. Because destruction only occurs at application exit | 68 // all sessions depended. Because destruction only occurs at application exit |
71 // after all connections have terminated, it is safe to make unretained | 69 // after all connections have terminated, it is safe to make unretained |
72 // cross-thread calls on the class. | 70 // cross-thread calls on the class. |
73 virtual ~ChromotingJniRuntime(); | 71 virtual ~ChromotingJniRuntime(); |
74 | 72 |
75 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. | 73 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. |
76 void DetachFromVmAndSignal(base::WaitableEvent* waiter); | 74 void DetachFromVmAndSignal(base::WaitableEvent* waiter); |
77 | 75 |
78 // Starts the logger on the network thread. | 76 // Starts the logger on the network thread. |
79 void StartLoggerOnNetworkThread(); | 77 void StartLoggerOnNetworkThread(); |
80 | 78 |
81 // Chromium code's connection to the app message loop. Once created the | 79 // Chromium code's connection to the app message loop. Once created the |
82 // MessageLoop will live for the life of the program. | 80 // MessageLoop will live for the life of the program. |
83 std::unique_ptr<base::MessageLoopForUI> ui_loop_; | 81 std::unique_ptr<base::MessageLoopForUI> ui_loop_; |
84 | 82 |
85 // Contains threads. | 83 // Contains threads. |
86 // | 84 // |
87 std::unique_ptr<ChromotingClientRuntime> runtime_; | 85 std::unique_ptr<ChromotingClientRuntime> runtime_; |
88 | 86 |
89 // For logging session stage changes and stats. | 87 // For logging session stage changes and stats. |
90 std::unique_ptr<ClientTelemetryLogger> logger_; | 88 std::unique_ptr<TelemetryLogWriter> log_writer_; |
91 | 89 |
92 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; | 90 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; |
93 | 91 |
94 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); | 92 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); |
95 }; | 93 }; |
96 | 94 |
97 } // namespace remoting | 95 } // namespace remoting |
98 | 96 |
99 #endif | 97 #endif |
OLD | NEW |