diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 19:09:35 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 19:09:35 +0000 |
commit | bbbfe21edc00ebb1de075d97577ce17af1ca4e23 (patch) | |
tree | 85a8abd6518693f06e6e79388281c3e26111a80b /chrome/browser/sync/abstract_profile_sync_service_test.cc | |
parent | c88db3db1f8f5ef6a907b3438136f17a27e16298 (diff) | |
download | chromium_src-bbbfe21edc00ebb1de075d97577ce17af1ca4e23.zip chromium_src-bbbfe21edc00ebb1de075d97577ce17af1ca4e23.tar.gz chromium_src-bbbfe21edc00ebb1de075d97577ce17af1ca4e23.tar.bz2 |
This is the problem of the leaking URLRequestContextGetters in the ProfileSyncService tests:
The URLRequestContextGetters implement public base::RefCountedThreadSafe<URLRequestContextGetter, URLRequestContextGetterTraits>. URLRequestContextGetterTraits insists on deleting the URLRequestContextGetters on the IO thread.
URLRequestContextGetter::OnDestruct() executes io_message_loop_proxy->DeleteSoon(FROM_HERE, this);
The test cases stopped the IO message loop before the last reference to all URLRequestContextGetters were destroyed. Therefore, the deletion was never executed.
BUG=78784
TEST=no
Review URL: http://codereview.chromium.org/7787026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100946 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/abstract_profile_sync_service_test.cc')
-rw-r--r-- | chrome/browser/sync/abstract_profile_sync_service_test.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/chrome/browser/sync/abstract_profile_sync_service_test.cc b/chrome/browser/sync/abstract_profile_sync_service_test.cc index 01f379f..f8ada2a 100644 --- a/chrome/browser/sync/abstract_profile_sync_service_test.cc +++ b/chrome/browser/sync/abstract_profile_sync_service_test.cc @@ -72,7 +72,8 @@ bool ProfileSyncServiceTestHelper::CreateRoot( AbstractProfileSyncServiceTest::AbstractProfileSyncServiceTest() : ui_thread_(BrowserThread::UI, &ui_loop_), db_thread_(BrowserThread::DB), - io_thread_(BrowserThread::IO) {} + io_thread_(BrowserThread::IO), + token_service_(new TokenService) {} AbstractProfileSyncServiceTest::~AbstractProfileSyncServiceTest() {} @@ -87,6 +88,12 @@ void AbstractProfileSyncServiceTest::TearDown() { // Pump messages posted by the sync core thread (which may end up // posting on the IO thread). ui_loop_.RunAllPending(); + // We need to destroy the |token_service_| here before we stop the + // |io_thread_| because it holds references to a ref-counted + // URLRequestContext. The deletion is passed to the |io_thread_| + // by scoped_refptr. If |token_service_| is destroyed after stopping + // the |io_thread_|, the deletion never happens. + token_service_.reset(NULL); io_thread_.Stop(); db_thread_.Stop(); ui_loop_.RunAllPending(); |