| Index: components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
|
| diff --git a/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc b/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..206b2900f03ce4bec97065e486b1701cf211968a
|
| --- /dev/null
|
| +++ b/components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.cc
|
| @@ -0,0 +1,30 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/gcm_driver/instance_id/scoped_use_fake_instance_id_android.h"
|
| +
|
| +#include "base/android/jni_android.h"
|
| +#include "jni/FakeInstanceIDWithSubtype_jni.h"
|
| +
|
| +using base::android::AttachCurrentThread;
|
| +
|
| +namespace instance_id {
|
| +
|
| +// static
|
| +bool ScopedUseFakeInstanceIDAndroid::RegisterJni(JNIEnv* env) {
|
| + return RegisterNativesImpl(env);
|
| +}
|
| +
|
| +ScopedUseFakeInstanceIDAndroid::ScopedUseFakeInstanceIDAndroid() {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + previous_value_ =
|
| + Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, true);
|
| +}
|
| +
|
| +ScopedUseFakeInstanceIDAndroid::~ScopedUseFakeInstanceIDAndroid() {
|
| + JNIEnv* env = AttachCurrentThread();
|
| + Java_FakeInstanceIDWithSubtype_clearDataAndSetEnabled(env, previous_value_);
|
| +}
|
| +
|
| +} // namespace instance_id
|
|
|