OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/device_orientation/data_fetcher_impl_android.h" | 5 #include "content/browser/device_orientation/data_fetcher_impl_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/browser/device_orientation/orientation.h" | 11 #include "content/browser/device_orientation/orientation.h" |
12 #include "jni/DeviceOrientation_jni.h" | 12 #include "jni/DeviceOrientation_jni.h" |
13 | 13 |
14 using base::android::AttachCurrentThread; | 14 using base::android::AttachCurrentThread; |
15 using base::android::CheckException; | 15 using base::android::CheckException; |
16 using base::android::GetClass; | 16 using base::android::GetClass; |
17 using base::android::GetMethodID; | 17 using base::android::GetMethodID; |
18 using base::android::ScopedJavaGlobalRef; | 18 using base::android::ScopedJavaGlobalRef; |
19 using base::android::ScopedJavaLocalRef; | 19 using base::android::ScopedJavaLocalRef; |
20 | 20 |
21 namespace device_orientation { | 21 namespace content { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // This should match ProviderImpl::kDesiredSamplingIntervalMs. | 25 // This should match ProviderImpl::kDesiredSamplingIntervalMs. |
26 // TODO(husky): Make that constant public so we can use it directly. | 26 // TODO(husky): Make that constant public so we can use it directly. |
27 const int kPeriodInMilliseconds = 100; | 27 const int kPeriodInMilliseconds = 100; |
28 | 28 |
29 base::LazyInstance<ScopedJavaGlobalRef<jobject> > | 29 base::LazyInstance<ScopedJavaGlobalRef<jobject> > |
30 g_jni_obj = LAZY_INSTANCE_INITIALIZER; | 30 g_jni_obj = LAZY_INSTANCE_INITIALIZER; |
31 | 31 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 g_jni_obj.Get().obj(), | 92 g_jni_obj.Get().obj(), |
93 reinterpret_cast<jint>(this), | 93 reinterpret_cast<jint>(this), |
94 rate_in_milliseconds); | 94 rate_in_milliseconds); |
95 } | 95 } |
96 | 96 |
97 void DataFetcherImplAndroid::Stop() { | 97 void DataFetcherImplAndroid::Stop() { |
98 DCHECK(!g_jni_obj.Get().is_null()); | 98 DCHECK(!g_jni_obj.Get().is_null()); |
99 Java_DeviceOrientation_stop(AttachCurrentThread(), g_jni_obj.Get().obj()); | 99 Java_DeviceOrientation_stop(AttachCurrentThread(), g_jni_obj.Get().obj()); |
100 } | 100 } |
101 | 101 |
102 } // namespace device_orientation | 102 } // namespace content |
OLD | NEW |