Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Unified Diff: google_apis/gaia/oauth2_token_service_request_unittest.cc

Issue 458753006: Fix use after free bug by calling GetTokenService in Core's ctor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update TSP comment (CANDIDATE). Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/oauth2_token_service_request_unittest.cc
diff --git a/google_apis/gaia/oauth2_token_service_request_unittest.cc b/google_apis/gaia/oauth2_token_service_request_unittest.cc
index 0a86cfd0e2da9a82151574c28ab9747b8bd8694c..c2683a83edae6aa4f139f81876c5e4e44162acea 100644
--- a/google_apis/gaia/oauth2_token_service_request_unittest.cc
+++ b/google_apis/gaia/oauth2_token_service_request_unittest.cc
@@ -159,6 +159,8 @@ class OAuth2TokenServiceRequestTest : public testing::Test {
virtual OAuth2TokenService* GetTokenService() OVERRIDE;
private:
+ virtual ~Provider();
+
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
OAuth2TokenService* token_service_;
};
@@ -166,7 +168,7 @@ class OAuth2TokenServiceRequestTest : public testing::Test {
base::MessageLoop ui_loop_;
OAuth2TokenService::ScopeSet scopes_;
scoped_ptr<MockOAuth2TokenService> oauth2_service_;
- scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> provider_;
+ scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> provider_;
TestingOAuth2TokenServiceConsumer consumer_;
};
@@ -174,8 +176,8 @@ void OAuth2TokenServiceRequestTest::SetUp() {
scopes_.insert(kScope);
oauth2_service_.reset(new MockOAuth2TokenService);
oauth2_service_->AddAccount(kAccountId);
- provider_.reset(
- new Provider(base::MessageLoopProxy::current(), oauth2_service_.get()));
+ provider_ =
+ new Provider(base::MessageLoopProxy::current(), oauth2_service_.get());
}
void OAuth2TokenServiceRequestTest::TearDown() {
@@ -198,6 +200,9 @@ OAuth2TokenService* OAuth2TokenServiceRequestTest::Provider::GetTokenService() {
return token_service_;
}
+OAuth2TokenServiceRequestTest::Provider::~Provider() {
+}
+
TEST_F(OAuth2TokenServiceRequestTest, CreateAndStart_Failure) {
oauth2_service_->SetResponse(
GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE),

Powered by Google App Engine
This is Rietveld 408576698