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

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

Issue 2627603002: [NTP::SectionOrder] Propagate category rank from UI through the bridge. (Closed)
Patch Set: java tests. 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
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_rank,
350 jint category_position, 351 jint category_position,
351 jlong publish_timestamp_ms, 352 jlong publish_timestamp_ms,
352 jfloat score, 353 jfloat score,
353 int windowOpenDisposition) { 354 int windowOpenDisposition) {
355 DCHECK_GT(category_rank, 0);
Marc Treib 2017/01/16 11:23:05 Is this 1-based?!
vitaliii 2017/01/16 11:36:17 Yes, is this unusual? It is not called "index". I
Marc Treib 2017/01/16 12:28:52 Well, most things we deal with are 0-based, includ
vitaliii 2017/01/16 12:48:37 I like the consistency. However, I do not want to
tschumann 2017/01/16 13:45:41 +mastiz: What's the usual way ranks get handled in
mastiz 2017/01/16 15:22:53 The term 'rank' suggests 1-based, otherwise logs u
354 ntp_snippets::metrics::OnSuggestionOpened( 356 ntp_snippets::metrics::OnSuggestionOpened(
355 global_position, Category::FromIDValue(j_category_id), category_position, 357 global_position, Category::FromIDValue(j_category_id), category_position,
356 base::Time::FromJavaTime(publish_timestamp_ms), score, 358 base::Time::FromJavaTime(publish_timestamp_ms), score,
357 static_cast<WindowOpenDisposition>(windowOpenDisposition)); 359 static_cast<WindowOpenDisposition>(windowOpenDisposition));
358 // TODO(vitaliii): Add ContentSuggestionsService::OnSuggestionOpened and 360 // TODO(vitaliii): Add ContentSuggestionsService::OnSuggestionOpened and
359 // 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
360 // them at all. See crbug.com/674080. 362 // them at all. See crbug.com/674080.
361 content_suggestions_service_->category_ranker()->OnSuggestionOpened( 363 content_suggestions_service_->category_ranker()->OnSuggestionOpened(
362 Category::FromIDValue(j_category_id)); 364 Category::FromIDValue(j_category_id));
363 content_suggestions_service_->user_classifier()->OnEvent( 365 content_suggestions_service_->user_classifier()->OnEvent(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 JNIEnv* env = AttachCurrentThread(); 485 JNIEnv* env = AttachCurrentThread();
484 Java_SnippetsBridge_onMoreSuggestions( 486 Java_SnippetsBridge_onMoreSuggestions(
485 env, bridge_, category.id(), 487 env, bridge_, category.id(),
486 ToJavaSuggestionList(env, category, suggestions)); 488 ToJavaSuggestionList(env, category, suggestions));
487 } 489 }
488 490
489 // static 491 // static
490 bool NTPSnippetsBridge::Register(JNIEnv* env) { 492 bool NTPSnippetsBridge::Register(JNIEnv* env) {
491 return RegisterNativesImpl(env); 493 return RegisterNativesImpl(env);
492 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/ntp_snippets_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698