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

Side by Side Diff: chrome/browser/android/ntp/suggestions_event_reporter_bridge.cc

Issue 2886723002: [Zine] Add a metric to record number of visible sections on NTP. (Closed)
Patch Set: isherman@ nit. 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/android/ntp/suggestions_event_reporter_bridge.h" 5 #include "chrome/browser/android/ntp/suggestions_event_reporter_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 jlong visit_time_ms) { 58 jlong visit_time_ms) {
59 ntp_snippets::metrics::OnSuggestionTargetVisited( 59 ntp_snippets::metrics::OnSuggestionTargetVisited(
60 Category::FromIDValue(j_category_id), 60 Category::FromIDValue(j_category_id),
61 base::TimeDelta::FromMilliseconds(visit_time_ms)); 61 base::TimeDelta::FromMilliseconds(visit_time_ms));
62 } 62 }
63 63
64 static void OnPageShown( 64 static void OnPageShown(
65 JNIEnv* env, 65 JNIEnv* env,
66 const JavaParamRef<jclass>& caller, 66 const JavaParamRef<jclass>& caller,
67 const JavaParamRef<jintArray>& jcategories, 67 const JavaParamRef<jintArray>& jcategories,
68 const JavaParamRef<jintArray>& jsuggestions_per_category) { 68 const JavaParamRef<jintArray>& jsuggestions_per_category,
69 jint j_visible_categories_count) {
69 std::vector<int> categories_int; 70 std::vector<int> categories_int;
70 JavaIntArrayToIntVector(env, jcategories, &categories_int); 71 JavaIntArrayToIntVector(env, jcategories, &categories_int);
71 std::vector<int> suggestions_per_category_int; 72 std::vector<int> suggestions_per_category_int;
72 JavaIntArrayToIntVector(env, jsuggestions_per_category, 73 JavaIntArrayToIntVector(env, jsuggestions_per_category,
73 &suggestions_per_category_int); 74 &suggestions_per_category_int);
74 DCHECK_EQ(categories_int.size(), suggestions_per_category_int.size()); 75 DCHECK_EQ(categories_int.size(), suggestions_per_category_int.size());
75 std::vector<std::pair<Category, int>> suggestions_per_category; 76 std::vector<std::pair<Category, int>> suggestions_per_category;
76 for (size_t i = 0; i < categories_int.size(); i++) { 77 for (size_t i = 0; i < categories_int.size(); i++) {
77 suggestions_per_category.push_back( 78 suggestions_per_category.push_back(
78 std::make_pair(Category::FromIDValue(categories_int[i]), 79 std::make_pair(Category::FromIDValue(categories_int[i]),
79 suggestions_per_category_int[i])); 80 suggestions_per_category_int[i]));
80 } 81 }
81 ntp_snippets::metrics::OnPageShown(suggestions_per_category); 82 ntp_snippets::metrics::OnPageShown(suggestions_per_category,
83 j_visible_categories_count);
82 GetUserClassifier()->OnEvent(UserClassifier::Metric::NTP_OPENED); 84 GetUserClassifier()->OnEvent(UserClassifier::Metric::NTP_OPENED);
83 } 85 }
84 86
85 static void OnSuggestionShown(JNIEnv* env, 87 static void OnSuggestionShown(JNIEnv* env,
86 const JavaParamRef<jclass>& caller, 88 const JavaParamRef<jclass>& caller,
87 jint global_position, 89 jint global_position,
88 jint j_category_id, 90 jint j_category_id,
89 jint position_in_category, 91 jint position_in_category,
90 jlong publish_timestamp_ms, 92 jlong publish_timestamp_ms,
91 jfloat score, 93 jfloat score,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved. 185 // TODO(fhorschig): Remove guard when https://crbug.com/678556 is resolved.
184 if (!scheduler) { 186 if (!scheduler) {
185 return; 187 return;
186 } 188 }
187 scheduler->OnBrowserForegrounded(); 189 scheduler->OnBrowserForegrounded();
188 } 190 }
189 191
190 bool RegisterSuggestionsEventReporterBridge(JNIEnv* env) { 192 bool RegisterSuggestionsEventReporterBridge(JNIEnv* env) {
191 return RegisterNativesImpl(env); 193 return RegisterNativesImpl(env);
192 } 194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698