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

Unified Diff: components/sync/device_info/device_info_sync_service.cc

Issue 2810873005: [Sync] Always check the device info provider for being null before using it. (Closed)
Patch Set: Created 3 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: components/sync/device_info/device_info_sync_service.cc
diff --git a/components/sync/device_info/device_info_sync_service.cc b/components/sync/device_info/device_info_sync_service.cc
index 3bad31fd4ea04524ba776c1084a42e5545c9b5af..f6f239891064cd8e1c5e6b46cfee19a787da0135 100644
--- a/components/sync/device_info/device_info_sync_service.cc
+++ b/components/sync/device_info/device_info_sync_service.cc
@@ -285,12 +285,18 @@ void DeviceInfoSyncService::SendLocalData(
const DeviceInfo* device_info =
local_device_info_provider_->GetLocalDeviceInfo();
- const SyncData& data = CreateLocalData(device_info);
- StoreSyncData(device_info->guid(), data);
- SyncChangeList change_list;
- change_list.push_back(SyncChange(FROM_HERE, change_type, data));
- sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
+ // While the |pulse_timer_| is shutdown eventually in StopSyncing(), our
+ // device info provider is ripped out from underneath us before that happens,
+ // and we need to guard against this.
+ if (device_info != nullptr) {
+ const SyncData& data = CreateLocalData(device_info);
+ StoreSyncData(device_info->guid(), data);
+
+ SyncChangeList change_list;
+ change_list.push_back(SyncChange(FROM_HERE, change_type, data));
+ sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
+ }
pulse_timer_.Start(
FROM_HERE, DeviceInfoUtil::kPulseInterval,
« 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