| 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 <chrome/browser/android/contextualsearch/ctr_suppression.h> | 5 #include <chrome/browser/android/contextualsearch/ctr_suppression.h> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "jni/CtrSuppression_jni.h" | 10 #include "jni/CtrSuppression_jni.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 jfloat CtrSuppression::GetPrevious28DayCtr(JNIEnv* env, | 75 jfloat CtrSuppression::GetPrevious28DayCtr(JNIEnv* env, |
| 76 const JavaParamRef<jobject>& obj) { | 76 const JavaParamRef<jobject>& obj) { |
| 77 return aggregator_->GetPrevious28DayCtr(); | 77 return aggregator_->GetPrevious28DayCtr(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // WeeklyActivityStorage overrides | 80 // WeeklyActivityStorage overrides |
| 81 | 81 |
| 82 int CtrSuppression::ReadStorage(std::string storage_bucket) { | 82 int CtrSuppression::ReadStorage(std::string storage_bucket) { |
| 83 JNIEnv* env = AttachCurrentThread(); | 83 JNIEnv* env = AttachCurrentThread(); |
| 84 ScopedJavaLocalRef<jstring> j_storage_bucket = | 84 ScopedJavaLocalRef<jstring> j_storage_bucket = |
| 85 ConvertUTF8ToJavaString(env, storage_bucket.c_str()); | 85 ConvertUTF8ToJavaString(env, storage_bucket); |
| 86 return Java_CtrSuppression_readInt(env, java_object_, j_storage_bucket); | 86 return Java_CtrSuppression_readInt(env, java_object_, j_storage_bucket); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CtrSuppression::WriteStorage(std::string storage_bucket, int value) { | 89 void CtrSuppression::WriteStorage(std::string storage_bucket, int value) { |
| 90 JNIEnv* env = AttachCurrentThread(); | 90 JNIEnv* env = AttachCurrentThread(); |
| 91 ScopedJavaLocalRef<jstring> j_storage_bucket = | 91 ScopedJavaLocalRef<jstring> j_storage_bucket = |
| 92 ConvertUTF8ToJavaString(env, storage_bucket.c_str()); | 92 ConvertUTF8ToJavaString(env, storage_bucket); |
| 93 Java_CtrSuppression_writeInt(env, java_object_, j_storage_bucket, value); | 93 Java_CtrSuppression_writeInt(env, java_object_, j_storage_bucket, value); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Java wrapper boilerplate | 96 // Java wrapper boilerplate |
| 97 | 97 |
| 98 void CtrSuppression::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 98 void CtrSuppression::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 99 delete this; | 99 delete this; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool RegisterCtrSuppression(JNIEnv* env) { | 102 bool RegisterCtrSuppression(JNIEnv* env) { |
| 103 return RegisterNativesImpl(env); | 103 return RegisterNativesImpl(env); |
| 104 } | 104 } |
| 105 | 105 |
| 106 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 106 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 107 CtrSuppression* suppression = new CtrSuppression(env, obj); | 107 CtrSuppression* suppression = new CtrSuppression(env, obj); |
| 108 return reinterpret_cast<intptr_t>(suppression); | 108 return reinterpret_cast<intptr_t>(suppression); |
| 109 } | 109 } |
| OLD | NEW |