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

Unified Diff: cloud_print/gcp20/prototype/printer.cc

Issue 22184007: GCP2.0 Device: Instant AccessToken update on AuthFailed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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: cloud_print/gcp20/prototype/printer.cc
diff --git a/cloud_print/gcp20/prototype/printer.cc b/cloud_print/gcp20/prototype/printer.cc
index 5a252c05645529dedf7f3aada60c5dd42b9fbeac..f483b72644b2017f776a0d1d0e77256980cc5c7d 100644
--- a/cloud_print/gcp20/prototype/printer.cc
+++ b/cloud_print/gcp20/prototype/printer.cc
@@ -182,9 +182,8 @@ void Printer::Stop() {
}
void Printer::OnAuthError() {
- access_token_update_ = base::Time::Now();
- ChangeState(OFFLINE);
- // TODO(maksymb): Implement *instant* updating of access_token.
+ access_token_update_ = base::Time::UnixEpoch();
+ ReconnectIn(base::TimeDelta::FromSeconds(0));
}
std::string Printer::GetAccessToken() {
@@ -756,6 +755,15 @@ std::string Printer::ConnectionStateToString(ConnectionState state) const {
}
}
+void Printer::ReconnectIn(const base::TimeDelta& delay) {
+ requester_.reset();
+ xmpp_listener_.reset();
+ base::MessageLoop::current()->PostDelayedTask(
gene 2013/08/05 20:56:28 Since this is a post task, it is possible you can
maksymb 2013/08/06 21:45:54 Done.
gene 2013/08/08 02:01:55 Could you please explain how this has been fixed?
maksymb 2013/08/08 18:35:46 /privet/accesstoken can be processed only in OnIdl
+ FROM_HERE,
+ base::Bind(&Printer::TryConnect, AsWeakPtr()),
+ delay);
+}
+
bool Printer::ChangeState(ConnectionState new_state) {
if (connection_state_ == new_state)
return false;
@@ -768,27 +776,8 @@ bool Printer::ChangeState(ConnectionState new_state) {
dns_server_.UpdateMetadata(CreateTxt());
- switch (connection_state_) {
- case CONNECTING:
- break;
-
- case ONLINE:
- break;
-
- case OFFLINE:
- requester_.reset();
- xmpp_listener_.reset();
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&Printer::TryConnect, AsWeakPtr()),
- base::TimeDelta::FromSeconds(kReconnectTimeout));
-
- case NOT_CONFIGURED:
- break;
-
- default:
- NOTREACHED();
- }
+ if (connection_state_ == OFFLINE)
+ ReconnectIn(base::TimeDelta::FromSeconds(kReconnectTimeout));
return true;
}
« cloud_print/gcp20/prototype/cloud_print_requester.cc ('K') | « cloud_print/gcp20/prototype/printer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698