Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_ | |
| 6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/android/jni_android.h" | |
| 11 #include "components/contextual_search/browser/ctr_aggregator.h" | |
| 12 #include "components/contextual_search/browser/weekly_activity_storage.h" | |
| 13 | |
| 14 // Provides a Java conduit to the CTRAggregator in the Contextual Search | |
| 15 // component. This allows Java to access the aggregated CTR values. | |
| 16 // This class also provides device-specific integer storage through its | |
| 17 // associated Java class as required to implement the WeeklyActivityStorage. | |
| 18 class CTRRecorder : public contextual_search::WeeklyActivityStorage { | |
| 19 public: | |
| 20 // Constructs a new CTRRecorder linked to the given Java object. | |
| 21 CTRRecorder(JNIEnv* env, jobject obj); | |
| 22 ~CTRRecorder() override; | |
| 23 | |
| 24 // Calls the destructor. Should be called when this native object is no | |
| 25 // longer needed. | |
| 26 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
| 27 | |
| 28 // Records an impression. Also records a click if |did_click| is true. | |
| 29 void RecordImpression(JNIEnv* env, | |
|
Theresa
2016/09/27 20:53:56
For the methods that just call through to componen
Donn Denman
2016/09/28 00:38:43
Done.
| |
| 30 const base::android::JavaParamRef<jobject>& obj, | |
| 31 jboolean did_click); | |
| 32 // Returns the current week number. | |
| 33 jint GetCurrentWeekNumber(JNIEnv* env, | |
| 34 const base::android::JavaParamRef<jobject>& obj); | |
| 35 // Returns whether there is data recorded for the previous week. | |
| 36 jboolean HasPreviousWeekData(JNIEnv* env, | |
| 37 const base::android::JavaParamRef<jobject>& obj); | |
| 38 // Returns the number of impressions for this user for the previous week. | |
| 39 // If the data for this user is not complete for the previous week, as | |
| 40 // indicated by |HasPreviousWeekData| then NAN is returned. | |
| 41 jint GetPreviousWeekImpressions( | |
| 42 JNIEnv* env, | |
| 43 const base::android::JavaParamRef<jobject>& obj); | |
| 44 // Returns the CTR for this user for the previous week. | |
| 45 // If the data for this user is not complete for the previous week, as | |
| 46 // indicated by |HasPreviousWeekData| then the result is undefined. | |
| 47 jfloat GetPreviousWeekCTR(JNIEnv* env, | |
| 48 const base::android::JavaParamRef<jobject>& obj); | |
| 49 // Returns whether there is data recorded for the previous 28-day period that | |
| 50 // ended in the previous week. | |
| 51 jboolean HasPrevious28DayData( | |
| 52 JNIEnv* env, | |
| 53 const base::android::JavaParamRef<jobject>& obj); | |
| 54 // Returns the number of impressions for this user for the 28-day period that | |
| 55 // ended in the previous week. If the data for this user is not complete for | |
| 56 // the 28-day period that ended in the previous week, as indicated by | |
| 57 // |HasPrevious28DayData| then the result is undefined. | |
| 58 jint GetPrevious28DayImpressions( | |
| 59 JNIEnv* env, | |
| 60 const base::android::JavaParamRef<jobject>& obj); | |
| 61 // Returns the CTR for this user for the 28-day period that ended in the | |
| 62 // previous week. If the data for this user is not complete for the 28-day | |
| 63 // period that ended in the previous week, as indicated by | |
| 64 // |HasPrevious28DayData| then NAN is returned. | |
| 65 jfloat GetPrevious28DayCTR(JNIEnv* env, | |
| 66 const base::android::JavaParamRef<jobject>& obj); | |
| 67 | |
| 68 // WeeklyActivityStorage Overrides. | |
| 69 int ReadStorage(std::string storage_bucket) override; | |
| 70 void WriteStorage(std::string storage_bucket, int value) override; | |
| 71 | |
| 72 private: | |
| 73 // The CTRAggregator that we forward requests to. | |
| 74 std::unique_ptr<contextual_search::CTRAggregator> aggregator_; | |
| 75 | |
| 76 // The linked Java object. | |
| 77 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(CTRRecorder); | |
| 80 }; | |
| 81 | |
| 82 bool RegisterCTRRecorder(JNIEnv* env); | |
| 83 | |
| 84 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_ | |
| OLD | NEW |