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

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

Issue 2609413005: [NTP::SectionOrder] Add category position metric for opened suggestions. (Closed)
Patch Set: rebase. Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_snippets_bridge.h" 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const base::android::JavaParamRef<jobject>& obj) { 255 const base::android::JavaParamRef<jobject>& obj) {
256 content_suggestions_service_->ReloadSuggestions(); 256 content_suggestions_service_->ReloadSuggestions();
257 } 257 }
258 258
259 void NTPSnippetsBridge::DismissSuggestion( 259 void NTPSnippetsBridge::DismissSuggestion(
260 JNIEnv* env, 260 JNIEnv* env,
261 const JavaParamRef<jobject>& obj, 261 const JavaParamRef<jobject>& obj,
262 const JavaParamRef<jstring>& jurl, 262 const JavaParamRef<jstring>& jurl,
263 jint global_position, 263 jint global_position,
264 jint j_category_id, 264 jint j_category_id,
265 jint category_position, 265 jint position_in_category,
266 const JavaParamRef<jstring>& id_within_category) { 266 const JavaParamRef<jstring>& id_within_category) {
267 Category category = Category::FromIDValue(j_category_id); 267 Category category = Category::FromIDValue(j_category_id);
268 268
269 content_suggestions_service_->DismissSuggestion(ContentSuggestion::ID( 269 content_suggestions_service_->DismissSuggestion(ContentSuggestion::ID(
270 category, ConvertJavaStringToUTF8(env, id_within_category))); 270 category, ConvertJavaStringToUTF8(env, id_within_category)));
271 271
272 history_service_->QueryURL( 272 history_service_->QueryURL(
273 GURL(ConvertJavaStringToUTF8(env, jurl)), /*want_visits=*/false, 273 GURL(ConvertJavaStringToUTF8(env, jurl)), /*want_visits=*/false,
274 base::Bind( 274 base::Bind(
275 [](int global_position, Category category, int category_position, 275 [](int global_position, Category category, int position_in_category,
276 bool success, const history::URLRow& row, 276 bool success, const history::URLRow& row,
277 const history::VisitVector& visit_vector) { 277 const history::VisitVector& visit_vector) {
278 bool visited = success && row.visit_count() != 0; 278 bool visited = success && row.visit_count() != 0;
279 ntp_snippets::metrics::OnSuggestionDismissed( 279 ntp_snippets::metrics::OnSuggestionDismissed(
280 global_position, category, category_position, visited); 280 global_position, category, position_in_category, visited);
281 }, 281 },
282 global_position, category, category_position), 282 global_position, category, position_in_category),
283 &tracker_); 283 &tracker_);
284 } 284 }
285 285
286 void NTPSnippetsBridge::DismissCategory(JNIEnv* env, 286 void NTPSnippetsBridge::DismissCategory(JNIEnv* env,
287 const JavaParamRef<jobject>& obj, 287 const JavaParamRef<jobject>& obj,
288 jint j_category_id) { 288 jint j_category_id) {
289 Category category = Category::FromIDValue(j_category_id); 289 Category category = Category::FromIDValue(j_category_id);
290 290
291 content_suggestions_service_->DismissCategory(category); 291 content_suggestions_service_->DismissCategory(category);
292 292
(...skipping 25 matching lines...) Expand all
318 } 318 }
319 ntp_snippets::metrics::OnPageShown(suggestions_per_category); 319 ntp_snippets::metrics::OnPageShown(suggestions_per_category);
320 content_suggestions_service_->user_classifier()->OnEvent( 320 content_suggestions_service_->user_classifier()->OnEvent(
321 ntp_snippets::UserClassifier::Metric::NTP_OPENED); 321 ntp_snippets::UserClassifier::Metric::NTP_OPENED);
322 } 322 }
323 323
324 void NTPSnippetsBridge::OnSuggestionShown(JNIEnv* env, 324 void NTPSnippetsBridge::OnSuggestionShown(JNIEnv* env,
325 const JavaParamRef<jobject>& obj, 325 const JavaParamRef<jobject>& obj,
326 jint global_position, 326 jint global_position,
327 jint j_category_id, 327 jint j_category_id,
328 jint category_position, 328 jint position_in_category,
329 jlong publish_timestamp_ms, 329 jlong publish_timestamp_ms,
330 jfloat score) { 330 jfloat score) {
331 PrefService* pref_service = ProfileManager::GetLastUsedProfile()->GetPrefs(); 331 PrefService* pref_service = ProfileManager::GetLastUsedProfile()->GetPrefs();
332 base::Time last_background_fetch_time = 332 base::Time last_background_fetch_time =
333 base::Time::FromInternalValue(pref_service->GetInt64( 333 base::Time::FromInternalValue(pref_service->GetInt64(
334 ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime)); 334 ntp_snippets::prefs::kLastSuccessfulBackgroundFetchTime));
335 335
336 ntp_snippets::metrics::OnSuggestionShown( 336 ntp_snippets::metrics::OnSuggestionShown(
337 global_position, Category::FromIDValue(j_category_id), category_position, 337 global_position, Category::FromIDValue(j_category_id),
338 base::Time::FromJavaTime(publish_timestamp_ms), 338 position_in_category, base::Time::FromJavaTime(publish_timestamp_ms),
339 last_background_fetch_time, score); 339 last_background_fetch_time, score);
340 if (global_position == 0) { 340 if (global_position == 0) {
341 content_suggestions_service_->user_classifier()->OnEvent( 341 content_suggestions_service_->user_classifier()->OnEvent(
342 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_SHOWN); 342 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_SHOWN);
343 } 343 }
344 } 344 }
345 345
346 void NTPSnippetsBridge::OnSuggestionOpened(JNIEnv* env, 346 void NTPSnippetsBridge::OnSuggestionOpened(JNIEnv* env,
347 const JavaParamRef<jobject>& obj, 347 const JavaParamRef<jobject>& obj,
348 jint global_position, 348 jint global_position,
349 jint j_category_id, 349 jint j_category_id,
350 jint category_index, 350 jint category_index,
351 jint category_position, 351 jint position_in_category,
352 jlong publish_timestamp_ms, 352 jlong publish_timestamp_ms,
353 jfloat score, 353 jfloat score,
354 int windowOpenDisposition) { 354 int windowOpenDisposition) {
355 const Category category = Category::FromIDValue(j_category_id);
355 ntp_snippets::metrics::OnSuggestionOpened( 356 ntp_snippets::metrics::OnSuggestionOpened(
356 global_position, Category::FromIDValue(j_category_id), category_position, 357 global_position, category, category_index, position_in_category,
357 base::Time::FromJavaTime(publish_timestamp_ms), score, 358 base::Time::FromJavaTime(publish_timestamp_ms), score,
358 static_cast<WindowOpenDisposition>(windowOpenDisposition)); 359 static_cast<WindowOpenDisposition>(windowOpenDisposition));
359 // TODO(vitaliii): Add ContentSuggestionsService::OnSuggestionOpened and 360 // TODO(vitaliii): Add ContentSuggestionsService::OnSuggestionOpened and
360 // notify the ranker and the classifier there instead. Do not expose both of 361 // notify the ranker and the classifier there instead. Do not expose both of
361 // them at all. See crbug.com/674080. 362 // them at all. See crbug.com/674080.
362 content_suggestions_service_->category_ranker()->OnSuggestionOpened( 363 content_suggestions_service_->category_ranker()->OnSuggestionOpened(category);
363 Category::FromIDValue(j_category_id));
364 content_suggestions_service_->user_classifier()->OnEvent( 364 content_suggestions_service_->user_classifier()->OnEvent(
365 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_USED); 365 ntp_snippets::UserClassifier::Metric::SUGGESTIONS_USED);
366 } 366 }
367 367
368 void NTPSnippetsBridge::OnSuggestionMenuOpened(JNIEnv* env, 368 void NTPSnippetsBridge::OnSuggestionMenuOpened(JNIEnv* env,
369 const JavaParamRef<jobject>& obj, 369 const JavaParamRef<jobject>& obj,
370 jint global_position, 370 jint global_position,
371 jint j_category_id, 371 jint j_category_id,
372 jint category_position, 372 jint position_in_category,
373 jlong publish_timestamp_ms, 373 jlong publish_timestamp_ms,
374 jfloat score) { 374 jfloat score) {
375 ntp_snippets::metrics::OnSuggestionMenuOpened( 375 ntp_snippets::metrics::OnSuggestionMenuOpened(
376 global_position, Category::FromIDValue(j_category_id), category_position, 376 global_position, Category::FromIDValue(j_category_id),
377 base::Time::FromJavaTime(publish_timestamp_ms), score); 377 position_in_category, base::Time::FromJavaTime(publish_timestamp_ms),
378 score);
378 } 379 }
379 380
380 void NTPSnippetsBridge::OnMoreButtonShown(JNIEnv* env, 381 void NTPSnippetsBridge::OnMoreButtonShown(JNIEnv* env,
381 const JavaParamRef<jobject>& obj, 382 const JavaParamRef<jobject>& obj,
382 jint j_category_id, 383 jint j_category_id,
383 jint position) { 384 jint position) {
384 ntp_snippets::metrics::OnMoreButtonShown(Category::FromIDValue(j_category_id), 385 ntp_snippets::metrics::OnMoreButtonShown(Category::FromIDValue(j_category_id),
385 position); 386 position);
386 } 387 }
387 388
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 JNIEnv* env = AttachCurrentThread(); 485 JNIEnv* env = AttachCurrentThread();
485 Java_SnippetsBridge_onMoreSuggestions( 486 Java_SnippetsBridge_onMoreSuggestions(
486 env, bridge_, category.id(), 487 env, bridge_, category.id(),
487 ToJavaSuggestionList(env, category, suggestions)); 488 ToJavaSuggestionList(env, category, suggestions));
488 } 489 }
489 490
490 // static 491 // static
491 bool NTPSnippetsBridge::Register(JNIEnv* env) { 492 bool NTPSnippetsBridge::Register(JNIEnv* env) {
492 return RegisterNativesImpl(env); 493 return RegisterNativesImpl(env);
493 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.h ('k') | components/ntp_snippets/content_suggestions_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698