| Index: chrome/browser/android/contextualsearch/ctr_recorder.h
|
| diff --git a/chrome/browser/android/contextualsearch/ctr_recorder.h b/chrome/browser/android/contextualsearch/ctr_recorder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a6663348affd6aff17150b5e17a670cbed7abdd1
|
| --- /dev/null
|
| +++ b/chrome/browser/android/contextualsearch/ctr_recorder.h
|
| @@ -0,0 +1,66 @@
|
| +// 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.
|
| +
|
| +#ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_
|
| +#define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_
|
| +
|
| +#include <stddef.h>
|
| +
|
| +#include "base/android/jni_android.h"
|
| +#include "components/contextual_search/browser/ctr_aggregator.h"
|
| +
|
| +// Provides a Java conduit to the CTRAggregator in the Contextual Search
|
| +// component. This allows Java to access the aggregated CTR values.
|
| +// This class also provides device-specific integer storage through its
|
| +// associated Java class as required to implement the CTRAggregator.
|
| +class CTRRecorder : public contextual_search::DeviceIntStorage {
|
| + public:
|
| + // Constructs a new CTRRecorder linked to the given Java object.
|
| + CTRRecorder(JNIEnv* env, jobject obj);
|
| + ~CTRRecorder() override;
|
| +
|
| + // Should be called when this native object is no longer needed (calls the
|
| + // destructor).
|
| + void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
|
| +
|
| + // Record an impression. Records a click if |did_click| is true.
|
| + void RecordImpression(JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& obj,
|
| + jboolean did_click);
|
| + // Returns whether there is data recorded for the previous week.
|
| + jboolean HasPreviousWeekData(JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& obj);
|
| + // Returns the CTR for this user for the previous week.
|
| + // If the data for this user is not complete for the previous week then NAN is
|
| + // returned.
|
| + jfloat GetPreviousWeekCTR(JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& obj);
|
| + // Returns whether there is data recorded for the previous 28-day period that
|
| + // ended in the previous week.
|
| + jboolean HasPrevious28DayData(
|
| + JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& obj);
|
| + // Returns the CTR for this user for the 28-day period that ended in the
|
| + // previous week. If the data for this user is not complete for the 28-day
|
| + // period that ended in the previous week then NAN is returned.
|
| + jfloat GetPrevious28DayCTR(JNIEnv* env,
|
| + const base::android::JavaParamRef<jobject>& obj);
|
| +
|
| + // NativeIntStorage Overrides.
|
| + int ReadInt(std::string storage_key) override;
|
| + void WriteInt(std::string storage_key, int value) override;
|
| +
|
| + private:
|
| + // The CTRAggregator that we forward requests to.
|
| + std::unique_ptr<contextual_search::CTRAggregator> aggregator_;
|
| +
|
| + // The linked Java object.
|
| + base::android::ScopedJavaGlobalRef<jobject> java_object_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CTRRecorder);
|
| +};
|
| +
|
| +bool RegisterCTRRecorder(JNIEnv* env);
|
| +
|
| +#endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CTR_RECORDER_H_
|
|
|