diff options
author | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 01:44:52 +0000 |
---|---|---|
committer | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-27 01:44:52 +0000 |
commit | af7ef3974cda70afd63a526d43b42e26d76b7652 (patch) | |
tree | a97fdcc514c1d54b7ae0d87868781ded8b0b265e /chrome | |
parent | 22bd1723317e44a327615c32f83fb642e213527d (diff) | |
download | chromium_src-af7ef3974cda70afd63a526d43b42e26d76b7652.zip chromium_src-af7ef3974cda70afd63a526d43b42e26d76b7652.tar.gz chromium_src-af7ef3974cda70afd63a526d43b42e26d76b7652.tar.bz2 |
Ensure ConfigureDataTypes is not called in a re-entrant manner.
BUG=80343
TEST=
Review URL: http://codereview.chromium.org/6904036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/sync/glue/data_type_manager_impl.cc | 8 | ||||
-rw-r--r-- | chrome/browser/sync/glue/data_type_manager_impl2_unittest.cc | 23 |
2 files changed, 29 insertions, 2 deletions
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc index a241184..ef7936b 100644 --- a/chrome/browser/sync/glue/data_type_manager_impl.cc +++ b/chrome/browser/sync/glue/data_type_manager_impl.cc @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" +#include "base/message_loop.h" #include "chrome/browser/sync/glue/data_type_controller.h" #include "chrome/browser/sync/glue/sync_backend_host.h" #include "content/browser/browser_thread.h" @@ -204,7 +205,12 @@ void DataTypeManagerImpl::StartNextType() { needs_reconfigure_ = false; VLOG(1) << "Reconfiguring due to previous configure attempt occuring while" << " busy."; - Configure(last_requested_types_); + + // Unwind the stack before executing configure. The method configure and its + // callees are not re-entrant. + MessageLoop::current()->PostTask(FROM_HERE, + method_factory_.NewRunnableMethod(&DataTypeManagerImpl::Configure, + last_requested_types_)); return; } diff --git a/chrome/browser/sync/glue/data_type_manager_impl2_unittest.cc b/chrome/browser/sync/glue/data_type_manager_impl2_unittest.cc index 9c6c690..999579c 100644 --- a/chrome/browser/sync/glue/data_type_manager_impl2_unittest.cc +++ b/chrome/browser/sync/glue/data_type_manager_impl2_unittest.cc @@ -34,6 +34,9 @@ using testing::AtLeast; using testing::DoAll; using testing::DoDefault; using testing::InSequence; +using testing::Invoke; +using testing::InvokeWithoutArgs; +using testing::InvokeWithoutArgs; using testing::Mock; using testing::Property; using testing::Pointee; @@ -310,6 +313,18 @@ TEST_F(DataTypeManagerImpl2Test, ConfigureOneThenSwitch) { EXPECT_EQ(DataTypeManager::STOPPED, dtm.state()); } +void DoConfigureDataTypes( + const DataTypeController::TypeMap& data_type_controllers, + const syncable::ModelTypeSet& types, + CancelableTask* ready_task) { + ready_task->Run(); + delete ready_task; +} + +void QuitMessageLoop() { + MessageLoop::current()->Quit(); +} + TEST_F(DataTypeManagerImpl2Test, ConfigureWhileOneInFlight) { DataTypeControllerMock* bookmark_dtc = MakeBookmarkDTC(); // Save the callback here so we can interrupt startup. @@ -332,8 +347,12 @@ TEST_F(DataTypeManagerImpl2Test, ConfigureWhileOneInFlight) { SetStartStopExpectations(preference_dtc); controllers_[syncable::PREFERENCES] = preference_dtc; - EXPECT_CALL(backend_, ConfigureDataTypes(_, _, _)).Times(2); DataTypeManagerImpl dtm(&backend_, controllers_); + EXPECT_CALL(backend_, ConfigureDataTypes(_, _, _)) + .WillOnce(Invoke(DoConfigureDataTypes)) + .WillOnce(DoAll(Invoke(DoConfigureDataTypes), + InvokeWithoutArgs(QuitMessageLoop))); + types_.insert(syncable::BOOKMARKS); SetConfigureStartExpectation(); @@ -347,6 +366,8 @@ TEST_F(DataTypeManagerImpl2Test, ConfigureWhileOneInFlight) { callback->Run(DataTypeController::OK, FROM_HERE); delete callback; + MessageLoop::current()->Run(); + EXPECT_EQ(DataTypeManager::CONFIGURED, dtm.state()); dtm.Stop(); |