Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3133)

Unified Diff: chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h

Issue 2857333002: [TTS] Write initial Tap-features to Ranker. (Closed)
Patch Set: Updated based on reviews by Roger and Theresa. Some API and doc changes. Handle null base page UR… Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..aeaf6df0a3f6aaa88f966fcfaca78448b9af3e24
--- /dev/null
+++ b/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.h
@@ -0,0 +1,71 @@
+// 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 logging and Ranker for Contextual Search features using the
+ // given details.
+ // |j_base_page_url| is the URL of the Contextual Search base-page (where the
+ // user might tap.
+ // |j_ranker_model_selector| specifies the Ranker model to invoke or train for
+ // Contextual Search.
+ void SetupLoggingAndRanker(
+ JNIEnv* env,
+ jobject obj,
+ const base::android::JavaParamRef<jstring>& j_base_page_url,
+ const base::android::JavaParamRef<jstring>& j_ranker_model_selector);
+
+ // 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);
+
+ // 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_

Powered by Google App Engine
This is Rietveld 408576698