OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_
IMPL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_
IMPL_H_ |
6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_
IMPL_H_ | 6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGGER_
IMPL_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "components/ukm/ukm_service.h" | 9 #include "components/ukm/public/ukm_recorder.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 namespace ukm { | 14 namespace ukm { |
15 class UkmService; | 15 class UkmRecorder; |
16 } // namespace ukm | 16 } // namespace ukm |
17 | 17 |
18 class ContextualSearchRankerLoggerImpl { | 18 class ContextualSearchRankerLoggerImpl { |
19 public: | 19 public: |
20 ContextualSearchRankerLoggerImpl(JNIEnv* env, jobject obj); | 20 ContextualSearchRankerLoggerImpl(JNIEnv* env, jobject obj); |
21 ~ContextualSearchRankerLoggerImpl(); | 21 ~ContextualSearchRankerLoggerImpl(); |
22 | 22 |
23 // Calls the destructor. Should be called when this native object is no | 23 // Calls the destructor. Should be called when this native object is no |
24 // longer needed. | 24 // longer needed. |
25 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 25 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
(...skipping 11 matching lines...) Expand all Loading... |
37 void LogLong(JNIEnv* env, | 37 void LogLong(JNIEnv* env, |
38 jobject obj, | 38 jobject obj, |
39 const base::android::JavaParamRef<jstring>& j_feature, | 39 const base::android::JavaParamRef<jstring>& j_feature, |
40 jlong j_long); | 40 jlong j_long); |
41 | 41 |
42 // Writes the currently logged data and resets the current builder to be | 42 // Writes the currently logged data and resets the current builder to be |
43 // ready to start logging the next set of data. | 43 // ready to start logging the next set of data. |
44 void WriteLogAndReset(JNIEnv* env, jobject obj); | 44 void WriteLogAndReset(JNIEnv* env, jobject obj); |
45 | 45 |
46 private: | 46 private: |
47 // Set the UKM service and base-page URL. | 47 // Set the UKM recorder and base-page URL. |
48 // TODO(donnd): write a test, using this to inject a test-ukm-service. | 48 // TODO(donnd): write a test, using this to inject a test-ukm-recorder. |
49 void SetUkmService(ukm::UkmService* ukm_service, const GURL& page_url); | 49 void SetUkmRecorder(ukm::UkmRecorder* ukm_recorder, const GURL& page_url); |
50 | 50 |
51 // Used to log URL-keyed metrics. This pointer will outlive |this|. | 51 // Used to log URL-keyed metrics. This pointer will outlive |this|. |
52 ukm::UkmService* ukm_service_; | 52 ukm::UkmRecorder* ukm_recorder_; |
53 | 53 |
54 // The UKM source ID being used for this session. | 54 // The UKM source ID being used for this session. |
55 int32_t source_id_; | 55 int32_t source_id_; |
56 | 56 |
57 // The entry builder for the current record. | 57 // The entry builder for the current record. |
58 std::unique_ptr<ukm::UkmEntryBuilder> builder_; | 58 std::unique_ptr<ukm::UkmEntryBuilder> builder_; |
59 | 59 |
60 // The linked Java object. | 60 // The linked Java object. |
61 base::android::ScopedJavaGlobalRef<jobject> java_object_; | 61 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(ContextualSearchRankerLoggerImpl); | 63 DISALLOW_COPY_AND_ASSIGN(ContextualSearchRankerLoggerImpl); |
64 }; | 64 }; |
65 | 65 |
66 bool RegisterContextualSearchRankerLoggerImpl(JNIEnv* env); | 66 bool RegisterContextualSearchRankerLoggerImpl(JNIEnv* env); |
67 | 67 |
68 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGG
ER_IMPL_H_ | 68 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_RANKER_LOGG
ER_IMPL_H_ |
OLD | NEW |