Sync: Allow DeviceInfoTracker listener to be set early.
commit77c3c0b325b1154fcf2ec3708217cd34794e904f
authorstanisc <stanisc@chromium.org>
Tue, 13 Jan 2015 16:18:44 +0000 (13 08:18 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 13 Jan 2015 16:20:24 +0000 (13 16:20 +0000)
tree7308654a71fc4bb84542049736fa506634753e11
parent8c61ffcb737c9cb45e15114b117830d58784b19f
Sync: Allow DeviceInfoTracker listener to be set early.

ProfileSyncService::GetDeviceInfoTracker implementation
returns NULL when DeviceInfo datatype isn't syncing.
This makes it impossible to register DeviceInfo observer
in advance.

This problem was introduced during recent refactoring of
DeviceInfo datatype when all functionality related to
consumption of synced DeviceInfo has been moved to a separate
interface called DeviceInfoTracker.

In fact ProfileSyncService doesn't have to return NULL. It
was done primarily to preserve the previously existing
access pattern to DeviceInfo synced data.

Description of the fix:
1) ProfileSyncService::GetDeviceInfoTracker() now returns
a non-NULL pointer to DeviceInfoTracker regardless of
DeviceInfo datatype state.
2) DeviceInfoTracker.IsSyncing method is used to check
whether DeviceInfo data is available.
3) Made minor changes in UI and extensions code depending on
GetDeviceInfoTracker().

Adding a unit test for this particular scenario at
ProfileSyncService turned out to be non-trivial. However
there are already unit tests for this functionality at
DeviceInfoSyncService level.
I've also tested this code with a demo signedInDevices
API extension.

BUG=446493

Review URL: https://codereview.chromium.org/843633002

Cr-Commit-Position: refs/heads/master@{#311276}
chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.cc
chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api_unittest.cc
chrome/browser/extensions/api/signed_in_devices/signed_in_devices_manager.cc
chrome/browser/sync/profile_sync_service.cc
chrome/browser/sync/profile_sync_service.h
chrome/browser/ui/webui/history_ui.cc
components/sync_driver/device_info_sync_service.cc
components/sync_driver/device_info_sync_service.h
components/sync_driver/device_info_sync_service_unittest.cc
components/sync_driver/device_info_tracker.h