Chromium Code Reviews| Index: chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h |
| diff --git a/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h b/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bfa29c08db1d8baa0da99f55cfac7fc22a009d58 |
| --- /dev/null |
| +++ b/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2017 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_CONTEXTUAL_SEARCH_RANKER_LOGGER_IMPL_H_ |
| +#define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_IMPL_H_ |
| + |
| +#include "base/android/jni_android.h" |
| +#include "components/ukm/ukm_service.h" |
| +#include "url/gurl.h" |
| + |
| +class GURL; |
| + |
| +namespace ukm { |
| +class UkmService; |
| +} // namespace ukm |
| + |
| +class ContextualSearchRankerLoggerImpl { |
| + public: |
| + ContextualSearchRankerLoggerImpl(JNIEnv* env, jobject obj); |
| + ~ContextualSearchRankerLoggerImpl(); |
| + |
| + // Calls the destructor. Should be called when this native object is no |
| + // longer needed. |
| + void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| + |
| + // Sets up the UKM service to log contextual Search features for the given |
|
Theresa
2017/05/12 01:02:25
nit: s/contextual/Contextual
Donn Denman
2017/05/12 23:08:55
Done.
|
| + // base-page URL for the given model URL. |
| + // |j_base_page_url| is the URL of the Contextual Search base-page (where the |
| + // user might tap. |
| + // |j_model_url| is the URL of the Ranker model to invoke or train for |
| + // Contextual Search tap-suppression. |
| + void SetUkmServiceAndUrls( |
| + JNIEnv* env, |
| + jobject obj, |
| + const base::android::JavaParamRef<jstring>& j_base_page_url, |
| + const base::android::JavaParamRef<jstring>& j_model_url); |
| + |
| + // Logs a long value with the given feature name. |
| + void LogLong(JNIEnv* env, |
| + jobject obj, |
| + const base::android::JavaParamRef<jstring>& j_feature, |
| + jlong j_long); |
| + |
| + // Logs a string value with the given feature name. |
| + void LogString(JNIEnv* env, |
| + jobject obj, |
| + const base::android::JavaParamRef<jstring>& j_feature, |
| + const base::android::JavaParamRef<jstring>& j_string); |
| + |
| + // Writes the currently logged data and resets the current builder to be |
| + // ready to start logging the next set of data. |
| + void WriteLogAndReset(JNIEnv* env, jobject obj); |
| + |
| + private: |
| + // Set the UKM service and base-page URL. |
| + // TODO(donnd): write a test, using this to inject a test-ukm-service. |
| + void SetUkmService(ukm::UkmService* ukm_service, const GURL& page_url); |
| + |
| + // Used to log URL-keyed metrics. This pointer will outlive |this|. |
| + ukm::UkmService* ukm_service_; |
| + |
| + // The UKM source ID being used for this session. |
| + int32_t source_id_; |
| + |
| + // The entry builder for the current record. |
| + std::unique_ptr<ukm::UkmEntryBuilder> builder_; |
| + |
| + // The linked Java object. |
| + base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ContextualSearchRankerLoggerImpl); |
| +}; |
| + |
| +bool RegisterContextualSearchRankerLoggerImpl(JNIEnv* env); |
| + |
| +#endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_IMPL_H_ |