Commit 0f58446e authored by tzik's avatar tzik Committed by Commit Bot

Use OAuth2 FailCaller after its construction is completed

`new FailCaller` in oauth2_access_token_fetcher_immediate_error.cc may
return a stale pointer if PostTask in its ctor failed, since base::Bind
there increments the ref count, and the callback destruction releases
it.

This CL moves the PostTask after the completion of the ctor call.

Bug: 866456
Change-Id: Id185e46292238955b3da9015903dfa6a8c94e7e9
Reviewed-on: https://chromium-review.googlesource.com/1146345Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578150}
parent 9e1d2ed0
......@@ -12,10 +12,6 @@
OAuth2AccessTokenFetcherImmediateError::FailCaller::FailCaller(
OAuth2AccessTokenFetcherImmediateError* fetcher)
: fetcher_(fetcher) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&OAuth2AccessTokenFetcherImmediateError::FailCaller::run,
this));
}
OAuth2AccessTokenFetcherImmediateError::FailCaller::~FailCaller() {
......@@ -58,6 +54,10 @@ void OAuth2AccessTokenFetcherImmediateError::Start(
const std::string& client_secret,
const std::vector<std::string>& scopes) {
failer_ = new FailCaller(this);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(&OAuth2AccessTokenFetcherImmediateError::FailCaller::run,
failer_));
}
void OAuth2AccessTokenFetcherImmediateError::Fail() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment