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

Unified Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 2349203002: [NTP Snippets] Try to fix crash in NTPSnippetsService::RescheduleFetching (Closed)
Patch Set: . Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/ntp/ntp_snippets_bridge.cc
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
index 96731edd97c22b61d835ead1fb2888e0983d44b1..348e5e95402663c4490ef19e4cd3896e48749ee9 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -71,9 +71,18 @@ static void FetchSnippets(JNIEnv* env,
const JavaParamRef<jclass>& caller,
jboolean j_force_request) {
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 =
- ContentSuggestionsServiceFactory::GetForProfile(profile)
- ->ntp_snippets_service();
+ content_suggestions_service->ntp_snippets_service();
// Can be null if the feature has been disabled but the scheduler has not been
// unregistered yet. The next start should unregister it.
@@ -88,9 +97,18 @@ static void FetchSnippets(JNIEnv* env,
static void RescheduleFetching(JNIEnv* env,
const JavaParamRef<jclass>& caller) {
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 =
- ContentSuggestionsServiceFactory::GetForProfile(profile)
- ->ntp_snippets_service();
+ content_suggestions_service->ntp_snippets_service();
// Can be null if the feature has been disabled but the scheduler has not been
// unregistered yet. The next start should unregister it.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698