diff options
author | stanisc@chromium.org <stanisc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 00:36:20 +0000 |
---|---|---|
committer | stanisc@chromium.org <stanisc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-22 00:36:20 +0000 |
commit | d85f0ac40f155b13ff9f67f85937112f6a2074de (patch) | |
tree | 8784996593344007e3337720e7d31f8cb93b253d /chrome/browser/sync/profile_sync_service_factory.cc | |
parent | 8b7e37e4ddf9c62eb5e3f01e5d68ab2a77abe091 (diff) | |
download | chromium_src-d85f0ac40f155b13ff9f67f85937112f6a2074de.zip chromium_src-d85f0ac40f155b13ff9f67f85937112f6a2074de.tar.gz chromium_src-d85f0ac40f155b13ff9f67f85937112f6a2074de.tar.bz2 |
Sync: Refactoring of DEVICE_INFO syncable type - Part 1
This reintroduces change 283461 (issue 367153005) that has been reverted due to
memory leaks in some unit tests.
The memory leak was in a mock implementation of ProfileSyncComponentsFactory.
The factory is responsible for creating an instance of LocalDeviceInfoProvider,
which it does on demand and immediately transfer ownership of
LocalDeviceInfoProvider to the caller.
But due to the way mocking was implemented in ProfileSyncComponentsFactoryMock
a mock instance of LocalDeviceInfoProvider was created in the constructor and
if a test never called CreateLocalDeviceInfoProvider(), it would be leaked.
In this change I moved away from using ON_CALL mocking mechanism that resulted
in the leak to a custom implementation that avoids that problem.
See original changes in the patch #1 and the fix in the patch #2.
The original description copied from issue 367153005:
This change introduces a new class LocalDeviceInfoProvider that is responsible
for providing the local device specific DeviceInfo/cache_guid. It initializes
the data asynchronously and allows consumers to get notified when the data
becomes available.
LocalDeviceInfoProvider will allow to remove these responsibilities from
SyncedDeviceTracker / ProfileSyncService and loose coupling between
ProfileSyncService and a number of SyncableService and DataTypeController
derived classes.
LocalDeviceInfoProvider is hosted on the frontend thread. Since it needs
cache_guid to initialize DeviceInfo, which is currently available only on the
backend, I updated SyncBackendHostCore and SyncBackendHostImpl to pass
cache_guid to the frontend via OnBackendInitialized.
For the time being SyncedDeviceTracker remains unchanged
and continues to initialize the local device info too. The entire class will be
removed in the Part 2 of the change which will move SyncedDeviceTracker
functionality to a new SyncableService.
LocalDeviceInfoProvider also replaces SessionsSyncManager::SyncInternalApiDelegate
which was previously used to decouple SessionsSyncManager from the specifics of
of the local device info implementation.
SessionsSyncManager is changed to consume LocalDeviceInfoProvider instead of
SessionsSyncManager::SyncInternalApiDelegate.
SessionDataTypeController now also consumes LocalDeviceInfoProvider to make sure
that SESSIONS type model doesn't start before local device info becomes available.
A very similar approach will be used in the upcoming second part of the change
for DEVICE_INFO DataTypeController and SyncableType.
The change includes new unit tests for LocalDeviceInfoProvider and
SessionDataTypeController.
TBR=maniscalco@chromium.org,sky@chromium.org,zea@chromium.org
BUG=395349
Review URL: https://codereview.chromium.org/398423002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/profile_sync_service_factory.cc')
-rw-r--r-- | chrome/browser/sync/profile_sync_service_factory.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc index 95c911a..b4a0f8a 100644 --- a/chrome/browser/sync/profile_sync_service_factory.cc +++ b/chrome/browser/sync/profile_sync_service_factory.cc @@ -133,11 +133,13 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START : browser_sync::MANUAL_START; ProfileSyncService* pss = new ProfileSyncService( - new ProfileSyncComponentsFactoryImpl(profile, - CommandLine::ForCurrentProcess(), - sync_service_url, - token_service, - url_request_context_getter), + scoped_ptr<ProfileSyncComponentsFactory>( + new ProfileSyncComponentsFactoryImpl( + profile, + CommandLine::ForCurrentProcess(), + sync_service_url, + token_service, + url_request_context_getter)), profile, signin_wrapper.Pass(), token_service, |