OLD | NEW |
---|---|
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 | 8 |
9 #include "base/android/callback_android.h" | 9 #include "base/android/callback_android.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 content_suggestions_service->ntp_snippets_service(); | 85 content_suggestions_service->ntp_snippets_service(); |
86 | 86 |
87 // Can be null if the feature has been disabled but the scheduler has not been | 87 // Can be null if the feature has been disabled but the scheduler has not been |
88 // unregistered yet. The next start should unregister it. | 88 // unregistered yet. The next start should unregister it. |
89 if (!service) | 89 if (!service) |
90 return; | 90 return; |
91 | 91 |
92 service->FetchSnippets(j_force_request); | 92 service->FetchSnippets(j_force_request); |
93 } | 93 } |
94 | 94 |
95 // Reschedules the fetching of snippets. | 95 // Reschedules the fetching of snippets. |
jkrcal
2016/09/23 10:28:34
Maybe expanding the comment? That it does forced r
Marc Treib
2016/09/23 11:19:13
I added the "forced" part. IMO where it is suppose
jkrcal
2016/09/23 11:24:53
Acknowledged.
| |
96 static void RescheduleFetching(JNIEnv* env, | 96 static void RescheduleFetching(JNIEnv* env, |
97 const JavaParamRef<jclass>& caller) { | 97 const JavaParamRef<jclass>& caller) { |
98 Profile* profile = ProfileManager::GetLastUsedProfile(); | 98 Profile* profile = ProfileManager::GetLastUsedProfile(); |
99 // Temporary check while investigating crbug.com/647920. | 99 // Temporary check while investigating crbug.com/647920. |
100 CHECK(profile); | 100 CHECK(profile); |
101 | 101 |
102 ntp_snippets::ContentSuggestionsService* content_suggestions_service = | 102 ntp_snippets::ContentSuggestionsService* content_suggestions_service = |
103 ContentSuggestionsServiceFactory::GetForProfile(profile); | 103 ContentSuggestionsServiceFactory::GetForProfile(profile); |
104 | 104 |
105 // Can maybe be null in some cases? (Incognito profile?) crbug.com/647920 | 105 // Can maybe be null in some cases? (Incognito profile?) crbug.com/647920 |
106 if (!content_suggestions_service) | 106 if (!content_suggestions_service) |
107 return; | 107 return; |
108 | 108 |
109 ntp_snippets::NTPSnippetsService* service = | 109 ntp_snippets::NTPSnippetsService* service = |
110 content_suggestions_service->ntp_snippets_service(); | 110 content_suggestions_service->ntp_snippets_service(); |
111 | 111 |
112 // Can be null if the feature has been disabled but the scheduler has not been | 112 // Can be null if the feature has been disabled but the scheduler has not been |
113 // unregistered yet. The next start should unregister it. | 113 // unregistered yet. The next start should unregister it. |
114 if (!service) | 114 if (!service) |
115 return; | 115 return; |
116 | 116 |
117 service->RescheduleFetching(); | 117 service->RescheduleFetching(/*force=*/true); |
118 } | 118 } |
119 | 119 |
120 static void OnSuggestionTargetVisited(JNIEnv* env, | 120 static void OnSuggestionTargetVisited(JNIEnv* env, |
121 const JavaParamRef<jclass>& caller, | 121 const JavaParamRef<jclass>& caller, |
122 jint category, | 122 jint category, |
123 jlong visit_time_ms) { | 123 jlong visit_time_ms) { |
124 Profile* profile = ProfileManager::GetLastUsedProfile(); | 124 Profile* profile = ProfileManager::GetLastUsedProfile(); |
125 ntp_snippets::ContentSuggestionsService* content_suggestions_service = | 125 ntp_snippets::ContentSuggestionsService* content_suggestions_service = |
126 ContentSuggestionsServiceFactory::GetForProfile(profile); | 126 ContentSuggestionsServiceFactory::GetForProfile(profile); |
127 ntp_snippets::metrics::OnSuggestionTargetVisited( | 127 ntp_snippets::metrics::OnSuggestionTargetVisited( |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 } | 382 } |
383 | 383 |
384 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 384 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
385 return content_suggestions_service_->category_factory()->FromIDValue(id); | 385 return content_suggestions_service_->category_factory()->FromIDValue(id); |
386 } | 386 } |
387 | 387 |
388 // static | 388 // static |
389 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 389 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
390 return RegisterNativesImpl(env); | 390 return RegisterNativesImpl(env); |
391 } | 391 } |
OLD | NEW |