Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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_CONTEXTUAL_SEARCH_RANKER_LOGGER_ IMPL_H_ | |
| 6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_ IMPL_H_ | |
| 7 | |
| 8 #include "base/android/jni_android.h" | |
| 9 #include "components/ukm/ukm_service.h" | |
| 10 #include "url/gurl.h" | |
| 11 | |
| 12 class GURL; | |
| 13 | |
| 14 namespace ukm { | |
| 15 class UkmService; | |
| 16 } // namespace ukm | |
| 17 | |
| 18 class ContextualSearchRankerLoggerImpl { | |
| 19 public: | |
| 20 ContextualSearchRankerLoggerImpl(JNIEnv* env, jobject obj); | |
| 21 ~ContextualSearchRankerLoggerImpl(); | |
| 22 | |
| 23 // Calls the destructor. Should be called when this native object is no | |
| 24 // longer needed. | |
| 25 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
| 26 | |
| 27 // 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.
| |
| 28 // base-page URL for the given model URL. | |
| 29 // |j_base_page_url| is the URL of the Contextual Search base-page (where the | |
| 30 // user might tap. | |
| 31 // |j_model_url| is the URL of the Ranker model to invoke or train for | |
| 32 // Contextual Search tap-suppression. | |
| 33 void SetUkmServiceAndUrls( | |
| 34 JNIEnv* env, | |
| 35 jobject obj, | |
| 36 const base::android::JavaParamRef<jstring>& j_base_page_url, | |
| 37 const base::android::JavaParamRef<jstring>& j_model_url); | |
| 38 | |
| 39 // Logs a long value with the given feature name. | |
| 40 void LogLong(JNIEnv* env, | |
| 41 jobject obj, | |
| 42 const base::android::JavaParamRef<jstring>& j_feature, | |
| 43 jlong j_long); | |
| 44 | |
| 45 // Logs a string value with the given feature name. | |
| 46 void LogString(JNIEnv* env, | |
| 47 jobject obj, | |
| 48 const base::android::JavaParamRef<jstring>& j_feature, | |
| 49 const base::android::JavaParamRef<jstring>& j_string); | |
| 50 | |
| 51 // Writes the currently logged data and resets the current builder to be | |
| 52 // ready to start logging the next set of data. | |
| 53 void WriteLogAndReset(JNIEnv* env, jobject obj); | |
| 54 | |
| 55 private: | |
| 56 // Set the UKM service and base-page URL. | |
| 57 // TODO(donnd): write a test, using this to inject a test-ukm-service. | |
| 58 void SetUkmService(ukm::UkmService* ukm_service, const GURL& page_url); | |
| 59 | |
| 60 // Used to log URL-keyed metrics. This pointer will outlive |this|. | |
| 61 ukm::UkmService* ukm_service_; | |
| 62 | |
| 63 // The UKM source ID being used for this session. | |
| 64 int32_t source_id_; | |
| 65 | |
| 66 // The entry builder for the current record. | |
| 67 std::unique_ptr<ukm::UkmEntryBuilder> builder_; | |
| 68 | |
| 69 // The linked Java object. | |
| 70 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(ContextualSearchRankerLoggerImpl); | |
| 73 }; | |
| 74 | |
| 75 bool RegisterContextualSearchRankerLoggerImpl(JNIEnv* env); | |
| 76 | |
| 77 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGG ER_IMPL_H_ | |
| OLD | NEW |