| OLD | NEW |
| 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 "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.
h" | 5 #include "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.
h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "jni/FakeInstanceIDWithSubtype_jni.h" | 8 #include "jni/FakeInstanceIDWithSubtype_jni.h" |
| 9 | 9 |
| 10 using base::android::AttachCurrentThread; | 10 using base::android::AttachCurrentThread; |
| 11 | 11 |
| 12 namespace instance_id { | 12 namespace instance_id { |
| 13 | 13 |
| 14 // static | |
| 15 bool ScopedUseFakeInstanceIDAndroid::RegisterJni(JNIEnv* env) { | |
| 16 return RegisterNativesImpl(env); | |
| 17 } | |
| 18 | |
| 19 ScopedUseFakeInstanceIDAndroid::ScopedUseFakeInstanceIDAndroid() { | 14 ScopedUseFakeInstanceIDAndroid::ScopedUseFakeInstanceIDAndroid() { |
| 20 JNIEnv* env = AttachCurrentThread(); | 15 JNIEnv* env = AttachCurrentThread(); |
| 21 previous_value_ = | 16 previous_value_ = |
| 22 Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, true); | 17 Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, true); |
| 23 } | 18 } |
| 24 | 19 |
| 25 ScopedUseFakeInstanceIDAndroid::~ScopedUseFakeInstanceIDAndroid() { | 20 ScopedUseFakeInstanceIDAndroid::~ScopedUseFakeInstanceIDAndroid() { |
| 26 JNIEnv* env = AttachCurrentThread(); | 21 JNIEnv* env = AttachCurrentThread(); |
| 27 Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, previous_value_); | 22 Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, previous_value_); |
| 28 } | 23 } |
| 29 | 24 |
| 30 } // namespace instance_id | 25 } // namespace instance_id |
| OLD | NEW |