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 #include "remoting/client/jni/chromoting_jni_runtime.h" | 5 #include "remoting/client/jni/chromoting_jni_runtime.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/library_loader/library_loader_hooks.h" | 10 #include "base/android/library_loader/library_loader_hooks.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 static void LoadNative(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 42 static void LoadNative(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
43 base::CommandLine::Init(0, nullptr); | 43 base::CommandLine::Init(0, nullptr); |
44 | 44 |
45 // Create the singleton now so that the Chromoting threads will be set up. | 45 // Create the singleton now so that the Chromoting threads will be set up. |
46 remoting::ChromotingJniRuntime::GetInstance(); | 46 remoting::ChromotingJniRuntime::GetInstance(); |
47 } | 47 } |
48 | 48 |
49 static void HandleAuthTokenOnNetworkThread(const std::string& token) { | 49 static void HandleAuthTokenOnNetworkThread(const std::string& token) { |
50 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); | 50 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); |
51 DCHECK(runtime->network_task_runner()->BelongsToCurrentThread()); | 51 DCHECK(runtime->network_task_runner()->BelongsToCurrentThread()); |
52 runtime->logger()->SetAuthToken(token); | 52 runtime->log_writer()->SetAuthToken(token); |
53 } | 53 } |
54 | 54 |
55 static void OnAuthTokenFetched(JNIEnv* env, | 55 static void OnAuthTokenFetched(JNIEnv* env, |
56 const JavaParamRef<jclass>& clazz, | 56 const JavaParamRef<jclass>& clazz, |
57 const JavaParamRef<jstring>& token) { | 57 const JavaParamRef<jstring>& token) { |
58 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); | 58 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); |
59 runtime->network_task_runner()->PostTask( | 59 runtime->network_task_runner()->PostTask( |
60 FROM_HERE, base::Bind(&HandleAuthTokenOnNetworkThread, | 60 FROM_HERE, base::Bind(&HandleAuthTokenOnNetworkThread, |
61 ConvertJavaStringToUTF8(env, token))); | 61 ConvertJavaStringToUTF8(env, token))); |
62 } | 62 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 Java_JniInterface_fetchAuthToken(env); | 122 Java_JniInterface_fetchAuthToken(env); |
123 } | 123 } |
124 | 124 |
125 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { | 125 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { |
126 base::android::DetachFromVM(); | 126 base::android::DetachFromVM(); |
127 waiter->Signal(); | 127 waiter->Signal(); |
128 } | 128 } |
129 | 129 |
130 void ChromotingJniRuntime::StartLoggerOnNetworkThread() { | 130 void ChromotingJniRuntime::StartLoggerOnNetworkThread() { |
131 DCHECK(network_task_runner()->BelongsToCurrentThread()); | 131 DCHECK(network_task_runner()->BelongsToCurrentThread()); |
132 logger_.reset(new ClientTelemetryLogger(ChromotingEvent::Mode::ME2ME)); | 132 log_writer_.reset(new TelemetryLogWriter( |
133 logger_->Start( | 133 kTelemetryBaseUrl, |
134 base::MakeUnique<ChromiumUrlRequestFactory>(runtime_->url_requester()), | 134 base::MakeUnique<ChromiumUrlRequestFactory>(runtime_->url_requester()))); |
135 kTelemetryBaseUrl); | 135 log_writer_->SetAuthClosure( |
136 logger_->SetAuthClosure( | |
137 base::Bind(&ChromotingJniRuntime::FetchAuthToken, | 136 base::Bind(&ChromotingJniRuntime::FetchAuthToken, |
138 base::Unretained(this))); | 137 base::Unretained(this))); |
139 } | 138 } |
140 | 139 |
141 } // namespace remoting | 140 } // namespace remoting |
OLD | NEW |