Chromium Code Reviews| 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; |
| } |