Apply _RELATIVE relocations ahead of others.
[chromium-blink-merge.git] / content / browser / vibration / vibration_provider_android.cc
blob4694f4ea6d069eb2cb2c730573718a582b8e1626
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
3 // found in the LICENSE file.
5 #include "content/browser/vibration/vibration_provider_android.h"
7 #include <algorithm>
9 #include "content/browser/vibration/vibration_message_filter.h"
10 #include "content/common/view_messages.h"
11 #include "jni/VibrationProvider_jni.h"
12 #include "third_party/WebKit/public/platform/WebVibration.h"
14 using base::android::AttachCurrentThread;
16 namespace content {
18 VibrationProviderAndroid::VibrationProviderAndroid() {
21 VibrationProviderAndroid::~VibrationProviderAndroid() {
24 // static
25 bool VibrationProviderAndroid::Register(JNIEnv* env) {
26 return RegisterNativesImpl(env);
29 void VibrationProviderAndroid::Vibrate(int64 milliseconds) {
30 if (j_vibration_provider_.is_null()) {
31 j_vibration_provider_.Reset(
32 Java_VibrationProvider_create(
33 AttachCurrentThread(),
34 base::android::GetApplicationContext()));
36 Java_VibrationProvider_vibrate(AttachCurrentThread(),
37 j_vibration_provider_.obj(),
38 milliseconds);
41 void VibrationProviderAndroid::CancelVibration() {
42 // If somehow a cancel message is received before this object was
43 // instantiated, it means there is no current vibration anyway. Just return.
44 if (j_vibration_provider_.is_null())
45 return;
47 Java_VibrationProvider_cancelVibration(AttachCurrentThread(),
48 j_vibration_provider_.obj());
51 // static
52 VibrationProvider* VibrationMessageFilter::CreateProvider() {
53 return new VibrationProviderAndroid();
56 } // namespace content