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

Side by Side Diff: device/generic_sensor/platform_sensor_android.cc

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « content/public/test/test_renderer_host.cc ('k') | ipc/ipc_channel_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "device/generic_sensor/platform_sensor_android.h" 5 #include "device/generic_sensor/platform_sensor_android.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "jni/PlatformSensor_jni.h" 10 #include "jni/PlatformSensor_jni.h"
11 11
12 using base::android::AttachCurrentThread; 12 using base::android::AttachCurrentThread;
13 using base::android::JavaRef; 13 using base::android::JavaRef;
14 14
15 namespace device { 15 namespace device {
16 16
17 // static 17 // static
18 bool PlatformSensorAndroid::RegisterJNI(JNIEnv* env) { 18 bool PlatformSensorAndroid::RegisterJNI(JNIEnv* env) {
19 return RegisterNativesImpl(env); 19 return RegisterNativesImpl(env);
20 } 20 }
21 21
22 PlatformSensorAndroid::PlatformSensorAndroid( 22 PlatformSensorAndroid::PlatformSensorAndroid(
23 mojom::SensorType type, 23 mojom::SensorType type,
24 mojo::ScopedSharedBufferMapping mapping, 24 mojo::ScopedSharedBufferMapping mapping,
25 uint64_t buffer_size, 25 uint64_t buffer_size,
26 PlatformSensorProvider* provider, 26 PlatformSensorProvider* provider,
27 const JavaRef<jobject>& java_sensor) 27 const JavaRef<jobject>& java_sensor)
28 : PlatformSensor(type, std::move(mapping), provider), 28 : PlatformSensor(type, std::move(mapping), provider),
29 task_runner_(base::MessageLoop::current()->task_runner()) { 29 task_runner_(base::ThreadTaskRunnerHandle::Get()) {
30 JNIEnv* env = AttachCurrentThread(); 30 JNIEnv* env = AttachCurrentThread();
31 j_object_.Reset(java_sensor); 31 j_object_.Reset(java_sensor);
32 32
33 jobject byte_buffer = 33 jobject byte_buffer =
34 env->NewDirectByteBuffer(shared_buffer_mapping_.get(), buffer_size); 34 env->NewDirectByteBuffer(shared_buffer_mapping_.get(), buffer_size);
35 Java_PlatformSensor_initPlatformSensorAndroid( 35 Java_PlatformSensor_initPlatformSensorAndroid(
36 env, j_object_.obj(), reinterpret_cast<jlong>(this), byte_buffer); 36 env, j_object_.obj(), reinterpret_cast<jlong>(this), byte_buffer);
37 } 37 }
38 38
39 PlatformSensorAndroid::~PlatformSensorAndroid() { 39 PlatformSensorAndroid::~PlatformSensorAndroid() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 void PlatformSensorAndroid::NotifyPlatformSensorError( 83 void PlatformSensorAndroid::NotifyPlatformSensorError(
84 JNIEnv*, 84 JNIEnv*,
85 const JavaRef<jobject>& caller) { 85 const JavaRef<jobject>& caller) {
86 task_runner_->PostTask( 86 task_runner_->PostTask(
87 FROM_HERE, base::Bind(&PlatformSensorAndroid::NotifySensorError, this)); 87 FROM_HERE, base::Bind(&PlatformSensorAndroid::NotifySensorError, this));
88 } 88 }
89 89
90 } // namespace device 90 } // namespace device
OLDNEW
« no previous file with comments | « content/public/test/test_renderer_host.cc ('k') | ipc/ipc_channel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698