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

Unified Diff: chrome/common/net/gaia/oauth2_mint_token_flow.cc

Issue 10630021: Modify experimental identity flow to display scope descriptions and details. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 6 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: chrome/common/net/gaia/oauth2_mint_token_flow.cc
diff --git a/chrome/common/net/gaia/oauth2_mint_token_flow.cc b/chrome/common/net/gaia/oauth2_mint_token_flow.cc
index b5c9e518d68721cb7cb716f7786e43568e32a943..19fd8a4405a6ad29d944b4481f4bdd700a9799ed 100644
--- a/chrome/common/net/gaia/oauth2_mint_token_flow.cc
+++ b/chrome/common/net/gaia/oauth2_mint_token_flow.cc
@@ -108,7 +108,9 @@ OAuth2MintTokenFlow::OAuth2MintTokenFlow(
"", std::vector<std::string>()),
context_(context),
delegate_(delegate),
- parameters_(parameters) {
+ parameters_(parameters),
+ delete_when_done_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
}
OAuth2MintTokenFlow::~OAuth2MintTokenFlow() { }
@@ -124,37 +126,50 @@ void OAuth2MintTokenFlow::Start() {
if (g_interceptor_for_tests->DoIntercept(this, &auth_token, &error)) {
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&OAuth2MintTokenFlow::Delegate::OnMintTokenSuccess,
- base::Unretained(delegate_), auth_token));
+ base::Bind(&OAuth2MintTokenFlow::ReportSuccess,
+ weak_factory_.GetWeakPtr(), auth_token));
} else {
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&OAuth2MintTokenFlow::Delegate::OnMintTokenFailure,
- base::Unretained(delegate_), error));
+ base::Bind(&OAuth2MintTokenFlow::ReportFailure,
+ weak_factory_.GetWeakPtr(), error));
}
return;
}
+
OAuth2ApiCallFlow::Start();
}
+void OAuth2MintTokenFlow::FireAndForget() {
+ delete_when_done_ = true;
+ Start();
+}
+
void OAuth2MintTokenFlow::ReportSuccess(const std::string& access_token) {
- if (delegate_) {
+ if (delegate_)
delegate_->OnMintTokenSuccess(access_token);
- }
+
+ if (delete_when_done_)
+ delete this;
}
-void OAuth2MintTokenFlow::ReportSuccess(const IssueAdviceInfo& issue_advice) {
- if (delegate_) {
+void OAuth2MintTokenFlow::ReportIssueAdviceSuccess(
+ const IssueAdviceInfo& issue_advice) {
+ if (delegate_)
delegate_->OnIssueAdviceSuccess(issue_advice);
- }
+
+ if (delete_when_done_)
+ delete this;
}
void OAuth2MintTokenFlow::ReportFailure(
const GoogleServiceAuthError& error) {
- if (delegate_) {
+ if (delegate_)
delegate_->OnMintTokenFailure(error);
- }
+
+ if (delete_when_done_)
+ delete this;
}
GURL OAuth2MintTokenFlow::CreateApiCallUrl() {
@@ -201,7 +216,7 @@ void OAuth2MintTokenFlow::ProcessApiCallSuccess(
if (issue_advice == kIssueAdviceValueConsent) {
IssueAdviceInfo issue_advice;
if (ParseIssueAdviceResponse(dict, &issue_advice))
- ReportSuccess(issue_advice);
+ ReportIssueAdviceSuccess(issue_advice);
else
ReportFailure(GoogleServiceAuthError::FromConnectionError(101));
} else {
@@ -211,6 +226,8 @@ void OAuth2MintTokenFlow::ProcessApiCallSuccess(
else
ReportFailure(GoogleServiceAuthError::FromConnectionError(101));
}
+
+ // |this| may be deleted!
}
void OAuth2MintTokenFlow::ProcessApiCallFailure(
« no previous file with comments | « chrome/common/net/gaia/oauth2_mint_token_flow.h ('k') | chrome/test/data/extensions/browsertest/scopes/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698