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

Unified Diff: chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc

Issue 14862004: Fix null pointer bug, add better logging to see why pointer is sometimes null. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Synced Notifications null pointer bug fix. Created 7 years, 8 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/notifications/sync_notifier/chrome_notifier_service.cc
diff --git a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc b/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc
index c7bc0b00fd40443b7f5d68dd1faac3842706eb94..5ce35d9bbc2f0b045c9ddae867928ac509588268 100644
--- a/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc
+++ b/chrome/browser/notifications/sync_notifier/chrome_notifier_service.cc
@@ -55,7 +55,12 @@ syncer::SyncMergeResult ChromeNotifierService::MergeDataAndStartSyncing(
// Build a local notification object from the sync data.
scoped_ptr<SyncedNotification> incoming(CreateNotificationFromSyncData(
sync_data));
- DCHECK(incoming.get());
+ if (!incoming) {
+ // TODO(petewil): Turn this into a NOTREACHED() call once we fix the
+ // underlying problem causing bad data.
+ LOG(WARNING) << "Badly formed sync data in incoming notification";
+ continue;
+ }
// Process each incoming remote notification.
const std::string& key = incoming->GetKey();
@@ -187,8 +192,15 @@ scoped_ptr<SyncedNotification>
// Check for mandatory fields in the sync_data object.
if (!specifics.has_coalesced_notification() ||
!specifics.coalesced_notification().has_key() ||
- !specifics.coalesced_notification().has_read_state())
+ !specifics.coalesced_notification().has_read_state()) {
+ DVLOG(1) << "Synced Notification missing mandatory fields "
+ << "has coalesced notification? "
+ << specifics.has_coalesced_notification()
+ << " has key? " << specifics.coalesced_notification().has_key()
+ << " has read state? "
+ << specifics.coalesced_notification().has_read_state();
return scoped_ptr<SyncedNotification>();
+ }
// TODO(petewil): Is this the right set? Should I add more?
bool is_well_formed_unread_notification =
@@ -203,8 +215,14 @@ scoped_ptr<SyncedNotification>
// if the notification is poorly formed, return a null pointer
if (!is_well_formed_unread_notification &&
- !is_well_formed_dismissed_notification)
+ !is_well_formed_dismissed_notification) {
+ DVLOG(1) << "Synced Notification is not well formed."
+ << " unread well formed? "
+ << is_well_formed_unread_notification
+ << " dismissed well formed? "
+ << is_well_formed_dismissed_notification;
return scoped_ptr<SyncedNotification>();
+ }
// Create a new notification object based on the supplied sync_data.
scoped_ptr<SyncedNotification> notification(
« 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