diff options
author | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 19:47:40 +0000 |
---|---|---|
committer | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 19:47:40 +0000 |
commit | 973c215d4dae02dbcf9adf525bb73fcfed1ea8dd (patch) | |
tree | 4b812b1d478f853500cd6a46a0d265aa588123ec | |
parent | a9a8940821a359d966f564b2f1da00801172c7a6 (diff) | |
download | chromium_src-973c215d4dae02dbcf9adf525bb73fcfed1ea8dd.zip chromium_src-973c215d4dae02dbcf9adf525bb73fcfed1ea8dd.tar.gz chromium_src-973c215d4dae02dbcf9adf525bb73fcfed1ea8dd.tar.bz2 |
Vibration: don't instantiate Java object only to cancel vibration
This could happen when starting and then immediately cancelling a vibration. The first IPC message to make it to the browser process would be for cancel, and hit the uninitialized java pointer.
Review URL: https://codereview.chromium.org/42633003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231091 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/android/vibration_message_filter.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/content/browser/android/vibration_message_filter.cc b/content/browser/android/vibration_message_filter.cc index 578fbfd..6792db1 100644 --- a/content/browser/android/vibration_message_filter.cc +++ b/content/browser/android/vibration_message_filter.cc @@ -57,13 +57,17 @@ void VibrationMessageFilter::OnVibrate(int64 milliseconds) { base::android::GetApplicationContext())); } Java_VibrationMessageFilter_vibrate(AttachCurrentThread(), - j_vibration_message_filter_.obj(), - milliseconds); + j_vibration_message_filter_.obj(), + milliseconds); } void VibrationMessageFilter::OnCancelVibration() { + // If somehow a cancel message is received before this object was + // instantiated, it means there is no current vibration anyway. Just return. + if (j_vibration_message_filter_.is_null()) + return; Java_VibrationMessageFilter_cancelVibration(AttachCurrentThread(), - j_vibration_message_filter_.obj()); + j_vibration_message_filter_.obj()); } } // namespace content |