Commit ae5a6bfd authored by treib's avatar treib Committed by Commit bot

[NTP Snippets] Try to fix crash in NTPSnippetsService::RescheduleFetching

and also in ::FetchSnippets

BUG=647920,648201

Review-Url: https://codereview.chromium.org/2349203002
Cr-Commit-Position: refs/heads/master@{#419451}
parent c153a251
...@@ -71,9 +71,18 @@ static void FetchSnippets(JNIEnv* env, ...@@ -71,9 +71,18 @@ static void FetchSnippets(JNIEnv* env,
const JavaParamRef<jclass>& caller, const JavaParamRef<jclass>& caller,
jboolean j_force_request) { jboolean j_force_request) {
Profile* profile = ProfileManager::GetLastUsedProfile(); Profile* profile = ProfileManager::GetLastUsedProfile();
// Temporary check while investigating crbug.com/647920.
CHECK(profile);
ntp_snippets::ContentSuggestionsService* content_suggestions_service =
ContentSuggestionsServiceFactory::GetForProfile(profile);
// Can maybe be null in some cases? (Incognito profile?) crbug.com/647920
if (!content_suggestions_service)
return;
ntp_snippets::NTPSnippetsService* service = ntp_snippets::NTPSnippetsService* service =
ContentSuggestionsServiceFactory::GetForProfile(profile) content_suggestions_service->ntp_snippets_service();
->ntp_snippets_service();
// Can be null if the feature has been disabled but the scheduler has not been // Can be null if the feature has been disabled but the scheduler has not been
// unregistered yet. The next start should unregister it. // unregistered yet. The next start should unregister it.
...@@ -88,9 +97,18 @@ static void FetchSnippets(JNIEnv* env, ...@@ -88,9 +97,18 @@ static void FetchSnippets(JNIEnv* env,
static void RescheduleFetching(JNIEnv* env, static void RescheduleFetching(JNIEnv* env,
const JavaParamRef<jclass>& caller) { const JavaParamRef<jclass>& caller) {
Profile* profile = ProfileManager::GetLastUsedProfile(); Profile* profile = ProfileManager::GetLastUsedProfile();
// Temporary check while investigating crbug.com/647920.
CHECK(profile);
ntp_snippets::ContentSuggestionsService* content_suggestions_service =
ContentSuggestionsServiceFactory::GetForProfile(profile);
// Can maybe be null in some cases? (Incognito profile?) crbug.com/647920
if (!content_suggestions_service)
return;
ntp_snippets::NTPSnippetsService* service = ntp_snippets::NTPSnippetsService* service =
ContentSuggestionsServiceFactory::GetForProfile(profile) content_suggestions_service->ntp_snippets_service();
->ntp_snippets_service();
// Can be null if the feature has been disabled but the scheduler has not been // Can be null if the feature has been disabled but the scheduler has not been
// unregistered yet. The next start should unregister it. // unregistered yet. The next start should unregister it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment