Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: remoting/client/jni/chromoting_jni_runtime.cc

Issue 2669893002: Initialize TaskScheduler in remoting processes. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/task_scheduler/task_scheduler.h"
17 #include "jni/JniInterface_jni.h" 18 #include "jni/JniInterface_jni.h"
18 #include "remoting/base/chromium_url_request.h" 19 #include "remoting/base/chromium_url_request.h"
19 #include "remoting/base/url_request_context_getter.h" 20 #include "remoting/base/url_request_context_getter.h"
20 #include "remoting/client/jni/jni_touch_event_data.h" 21 #include "remoting/client/jni/jni_touch_event_data.h"
21 22
22 using base::android::ConvertJavaStringToUTF8; 23 using base::android::ConvertJavaStringToUTF8;
23 using base::android::ConvertUTF8ToJavaString; 24 using base::android::ConvertUTF8ToJavaString;
24 using base::android::JavaParamRef; 25 using base::android::JavaParamRef;
25 using base::android::ToJavaByteArray; 26 using base::android::ToJavaByteArray;
26 27
27 namespace { 28 namespace {
28 29
29 const char kTelemetryBaseUrl[] = "https://remoting-pa.googleapis.com/v1/events"; 30 const char kTelemetryBaseUrl[] = "https://remoting-pa.googleapis.com/v1/events";
30 31
31 } // namespace 32 } // namespace
32 33
33 namespace remoting { 34 namespace remoting {
34 35
35 bool RegisterChromotingJniRuntime(JNIEnv* env) { 36 bool RegisterChromotingJniRuntime(JNIEnv* env) {
36 return remoting::RegisterNativesImpl(env); 37 return remoting::RegisterNativesImpl(env);
37 } 38 }
38 39
39 // Implementation of stubs defined in JniInterface_jni.h. These are the entry 40 // Implementation of stubs defined in JniInterface_jni.h. These are the entry
40 // points for JNI calls from Java into C++. 41 // points for JNI calls from Java into C++.
41 42
42 static void LoadNative(JNIEnv* env, const JavaParamRef<jclass>& clazz) { 43 static void LoadNative(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
43 base::CommandLine::Init(0, nullptr); 44 base::CommandLine::Init(0, nullptr);
44 45
46 // TODO(sergeyu): Consider adding separate pools for different task classes.
47 const int kMaxBackgroundThreads = 5;
48 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(kMaxBackgroundThreads);
49
45 // Create the singleton now so that the Chromoting threads will be set up. 50 // Create the singleton now so that the Chromoting threads will be set up.
46 remoting::ChromotingJniRuntime::GetInstance(); 51 remoting::ChromotingJniRuntime::GetInstance();
47 } 52 }
48 53
49 static void HandleAuthTokenOnNetworkThread(const std::string& token) { 54 static void HandleAuthTokenOnNetworkThread(const std::string& token) {
50 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance(); 55 ChromotingJniRuntime* runtime = remoting::ChromotingJniRuntime::GetInstance();
51 DCHECK(runtime->network_task_runner()->BelongsToCurrentThread()); 56 DCHECK(runtime->network_task_runner()->BelongsToCurrentThread());
52 runtime->GetLogWriter()->SetAuthToken(token); 57 runtime->GetLogWriter()->SetAuthToken(token);
53 } 58 }
54 59
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DCHECK(network_task_runner()->BelongsToCurrentThread()); 141 DCHECK(network_task_runner()->BelongsToCurrentThread());
137 log_writer_.reset(new TelemetryLogWriter( 142 log_writer_.reset(new TelemetryLogWriter(
138 kTelemetryBaseUrl, 143 kTelemetryBaseUrl,
139 base::MakeUnique<ChromiumUrlRequestFactory>(runtime_->url_requester()))); 144 base::MakeUnique<ChromiumUrlRequestFactory>(runtime_->url_requester())));
140 log_writer_->SetAuthClosure( 145 log_writer_->SetAuthClosure(
141 base::Bind(&ChromotingJniRuntime::FetchAuthToken, 146 base::Bind(&ChromotingJniRuntime::FetchAuthToken,
142 base::Unretained(this))); 147 base::Unretained(this)));
143 } 148 }
144 149
145 } // namespace remoting 150 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/ios/app_runtime.cc ('k') | remoting/host/it2me/it2me_native_messaging_host_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698