• skym's avatar
    [Sync] Actively guard against provider being cleared in DeviceInfoSyncBridge. · 24268f79
    skym authored
    When a user signs out and Sync starts to shut down, we immediately
    clear the LocalDeviceInfoProvider. Many methods in DeviceInfoSyncBridge
    depend on being able to access information in the provider, and can
    crash at this point. The bridge should be disabled momentarily, but
    this will require threads hops UI->Sync->UI. Meanwhile, various other
    posted tasks can call into the bridge and hit this race condition.
    
    We were previously guarding against this scenario when the pulse timer
    would fire, but we were not guarding against processor's Merge/Apply
    calls or ModelTypeStore async initialization. I've added nullptr checks
    to all async entry points that mostly no-op when they detect this
    scenario.
    
    One slight hiccup is that the bridge currently leaves the pulse timer
    running even when disabled. My intention is that this change will be
    merged back into M56 so I wanted to keep this CL as small as possible.
    When crbug.com/672600 is addressed I think it will make the most sense
    to disable the pulse timer while disabled, since it should always be
    re-enabled with an accurate timer when things are working again.
    
    Additionally, some state tracking such as has_provider_initialized_
    should probably just be removed at this point. This should be caught in
    crbug.com/659263
    
    BUG=672534
    
    Review-Url: https://codereview.chromium.org/2568543003
    Cr-Commit-Position: refs/heads/master@{#437902}
    24268f79
device_info_sync_bridge.cc 17 KB