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 logging and Ranker for Contextual Search features using the |
| 28 // given details. |
| 29 // |j_base_page_url| is the URL of the Contextual Search base-page (where the |
| 30 // user might tap. |
| 31 void SetupLoggingAndRanker( |
| 32 JNIEnv* env, |
| 33 jobject obj, |
| 34 const base::android::JavaParamRef<jstring>& j_base_page_url); |
| 35 |
| 36 // Logs a long value with the given feature name. |
| 37 void LogLong(JNIEnv* env, |
| 38 jobject obj, |
| 39 const base::android::JavaParamRef<jstring>& j_feature, |
| 40 jlong j_long); |
| 41 |
| 42 // Writes the currently logged data and resets the current builder to be |
| 43 // ready to start logging the next set of data. |
| 44 void WriteLogAndReset(JNIEnv* env, jobject obj); |
| 45 |
| 46 private: |
| 47 // Set the UKM service and base-page URL. |
| 48 // TODO(donnd): write a test, using this to inject a test-ukm-service. |
| 49 void SetUkmService(ukm::UkmService* ukm_service, const GURL& page_url); |
| 50 |
| 51 // Used to log URL-keyed metrics. This pointer will outlive |this|. |
| 52 ukm::UkmService* ukm_service_; |
| 53 |
| 54 // The UKM source ID being used for this session. |
| 55 int32_t source_id_; |
| 56 |
| 57 // The entry builder for the current record. |
| 58 std::unique_ptr<ukm::UkmEntryBuilder> builder_; |
| 59 |
| 60 // The linked Java object. |
| 61 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ContextualSearchRankerLoggerImpl); |
| 64 }; |
| 65 |
| 66 bool RegisterContextualSearchRankerLoggerImpl(JNIEnv* env); |
| 67 |
| 68 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGG
ER_IMPL_H_ |
OLD | NEW |