Index: net/ssl/server_bound_cert_service_unittest.cc |
diff --git a/net/ssl/server_bound_cert_service_unittest.cc b/net/ssl/server_bound_cert_service_unittest.cc |
index 0063f496036854c4c3a1ae2be4cbc1dea394ae66..f1d45d03e0d082abba4b9c89f6e2523b7c09cae2 100644 |
--- a/net/ssl/server_bound_cert_service_unittest.cc |
+++ b/net/ssl/server_bound_cert_service_unittest.cc |
@@ -536,7 +536,16 @@ TEST_F(ServerBoundCertServiceTest, AsyncStoreGetNoCertsInStore) { |
EXPECT_FALSE(private_key_info.empty()); |
EXPECT_FALSE(der_cert.empty()); |
EXPECT_FALSE(request_handle.is_active()); |
-} |
+ |
+ // Wait for any posted ServerBoundCertServiceWorkers to finish, in order to |
+ // ensure that the workers are cleared by the time service_'s destructor is |
+ // called. This prevents a leak of the SequencedWorkerPool, which by default |
+ // continues on shutdown. (By calling |
+ // CallGetServerBoundCertCallbackWithResult, callbacks are called directly, |
+ // short-circuiting ServerBoundCertService's usual bookkeeping, so existing |
+ // tasks must be both cleared and waited for to ensure proper memory freeing.) |
+ sequenced_worker_pool_->FlushForTesting(); |
Ryan Sleevi
2013/08/09 00:45:10
I can't help but keep reading this comment and cod
juanlang
2013/08/09 04:48:52
Yeah, that big comment should have been a clue to
juanlang
2013/08/09 16:25:28
Yep, PostTask is the right thing here. Thanks. I d
|
+ base::MessageLoop::current()->RunUntilIdle(); } |
TEST_F(ServerBoundCertServiceTest, AsyncStoreGetOneCertInStore) { |
MockServerBoundCertStoreWithAsyncGet* mock_store = |
@@ -560,7 +569,6 @@ TEST_F(ServerBoundCertServiceTest, AsyncStoreGetOneCertInStore) { |
mock_store->CallGetServerBoundCertCallbackWithResult( |
OK, base::Time(), "ab", "cd"); |
- |
error = callback.WaitForResult(); |
EXPECT_EQ(OK, error); |
EXPECT_EQ(1, service_->cert_count()); |
@@ -572,6 +580,16 @@ TEST_F(ServerBoundCertServiceTest, AsyncStoreGetOneCertInStore) { |
EXPECT_STREQ("ab", private_key_info.c_str()); |
EXPECT_STREQ("cd", der_cert.c_str()); |
EXPECT_FALSE(request_handle.is_active()); |
+ |
+ // Wait for any posted ServerBoundCertServiceWorkers to finish, in order to |
+ // ensure that the workers are cleared by the time service_'s destructor is |
+ // called. This prevents a leak of the SequencedWorkerPool, which by default |
+ // continues on shutdown. (By calling |
+ // CallGetServerBoundCertCallbackWithResult, callbacks are called directly, |
+ // short-circuiting ServerBoundCertService's usual bookkeeping, so existing |
+ // tasks must be both cleared and waited for to ensure proper memory freeing.) |
+ sequenced_worker_pool_->FlushForTesting(); |
+ base::MessageLoop::current()->RunUntilIdle(); } |
} |
#endif // !defined(USE_OPENSSL) |