diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-12 23:46:25 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-12 23:46:25 +0000 |
commit | 1f5d83a8f3f7b7c6d93eb7a3aa5362db1a80728f (patch) | |
tree | 68820961d4862a8aee87494d3c30fe376ffb1aa4 /sync/sessions | |
parent | aac3704922b4d2e658a56369e5fdfed63faf46ae (diff) | |
download | chromium_src-1f5d83a8f3f7b7c6d93eb7a3aa5362db1a80728f.zip chromium_src-1f5d83a8f3f7b7c6d93eb7a3aa5362db1a80728f.tar.gz chromium_src-1f5d83a8f3f7b7c6d93eb7a3aa5362db1a80728f.tar.bz2 |
sync: Implement disabling of non blocking types
Adds logic to have the model-thread NonBlockingDataTypeProcessor send
a message to the sync-thread SyncCore when it receives notifcation from
the ui-thread NonBlockingDataTypeController that it should stop syncing.
This message will allow the sync thread to stop requeting updates and
commits on behalf of the now-disabled type.
Fixes the handling of a race in the NonBlockingDataTypeProcessor. The
race is as follows:
1. NBDTP receives a request to enable sync from the UI thread, and sends
a connection request to the sync thread via SyncCoreProxy.
2. NBDTP receives a request to disable sync from the UI thread. It
updates its internal state accordingly.
3. NBDTP receives the connection OK response from the sync thread,
which was genrated in response to its request in step 1.
Previously, the processor would wrongly set itself to the enable state
in step 3. The fix is to use a new WeakPtrFactory and invalidate the
pointers it has issued in step 2 in order to prevent the response seen
in step 3 from being run.
Adds some more tests for this scenario and more. The test framework had
to be made a bit more complicated in order to handle these tests, but
I think the extra complexity is worth it. I don't know of any other
way to reliably defend against these race cases.
BUG=351005
Review URL: https://codereview.chromium.org/272323002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions')
-rw-r--r-- | sync/sessions/model_type_registry_unittest.cc | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/sync/sessions/model_type_registry_unittest.cc b/sync/sessions/model_type_registry_unittest.cc index 375e84b..a5e3c91 100644 --- a/sync/sessions/model_type_registry_unittest.cc +++ b/sync/sessions/model_type_registry_unittest.cc @@ -140,16 +140,12 @@ TEST_F(ModelTypeRegistryTest, NonBlockingTypes) { EXPECT_TRUE(registry()->GetEnabledTypes().Empty()); registry()->InitializeNonBlockingType( - syncer::THEMES, - task_runner, - themes_processor.AsWeakPtr()); + syncer::THEMES, task_runner, themes_processor.AsWeakPtrForUI()); EXPECT_TRUE(registry()->GetEnabledTypes().Equals( ModelTypeSet(syncer::THEMES))); registry()->InitializeNonBlockingType( - syncer::SESSIONS, - task_runner, - sessions_processor.AsWeakPtr()); + syncer::SESSIONS, task_runner, sessions_processor.AsWeakPtrForUI()); EXPECT_TRUE(registry()->GetEnabledTypes().Equals( ModelTypeSet(syncer::THEMES, syncer::SESSIONS))); @@ -177,9 +173,7 @@ TEST_F(ModelTypeRegistryTest, NonBlockingTypesWithDirectoryTypes) { // Add the themes non-blocking type. registry()->InitializeNonBlockingType( - syncer::THEMES, - task_runner, - themes_processor.AsWeakPtr()); + syncer::THEMES, task_runner, themes_processor.AsWeakPtrForUI()); current_types.Put(syncer::THEMES); EXPECT_TRUE(registry()->GetEnabledTypes().Equals(current_types)); @@ -190,9 +184,7 @@ TEST_F(ModelTypeRegistryTest, NonBlockingTypesWithDirectoryTypes) { // Add sessions non-blocking type. registry()->InitializeNonBlockingType( - syncer::SESSIONS, - task_runner, - sessions_processor.AsWeakPtr()); + syncer::SESSIONS, task_runner, sessions_processor.AsWeakPtrForUI()); current_types.Put(syncer::SESSIONS); EXPECT_TRUE(registry()->GetEnabledTypes().Equals(current_types)); @@ -219,13 +211,9 @@ TEST_F(ModelTypeRegistryTest, DeletionOrdering) { EXPECT_TRUE(registry()->GetEnabledTypes().Empty()); registry()->InitializeNonBlockingType( - syncer::THEMES, - task_runner, - themes_processor->AsWeakPtr()); + syncer::THEMES, task_runner, themes_processor->AsWeakPtrForUI()); registry()->InitializeNonBlockingType( - syncer::SESSIONS, - task_runner, - sessions_processor->AsWeakPtr()); + syncer::SESSIONS, task_runner, sessions_processor->AsWeakPtrForUI()); EXPECT_TRUE(registry()->GetEnabledTypes().Equals( ModelTypeSet(syncer::THEMES, syncer::SESSIONS))); |