Index: cloud_print/gcp20/prototype/printer.h |
diff --git a/cloud_print/gcp20/prototype/printer.h b/cloud_print/gcp20/prototype/printer.h |
index fab918956f0cf7905b5f18ce6c48d4886591cb9d..d0aed95e44761e9833322fb031d493ece4f97ca4 100644 |
--- a/cloud_print/gcp20/prototype/printer.h |
+++ b/cloud_print/gcp20/prototype/printer.h |
@@ -107,7 +107,7 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
const std::string& user) OVERRIDE; |
virtual void GetRegistrationServerError(std::string* description) OVERRIDE; |
virtual void CreateInfo(PrivetHttpServer::DeviceInfo* info) OVERRIDE; |
- virtual bool IsRegistered() const OVERRIDE; |
+ virtual bool IsRegistered() OVERRIDE; |
virtual bool CheckXPrivetTokenHeader(const std::string& token) const OVERRIDE; |
// CloudRequester::Delegate methods: |
@@ -115,7 +115,7 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
const std::string& registration_token, |
const std::string& complete_invite_url, |
const std::string& device_id) OVERRIDE; |
- virtual void OnGetAuthCodeResponseParsed( |
+ virtual void OnRegistrationFinished( |
const std::string& refresh_token, |
const std::string& access_token, |
int access_token_expires_in_seconds) OVERRIDE; |
@@ -165,11 +165,17 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
void RememberAccessToken(const std::string& access_token, |
int expires_in_seconds); |
+ // Sets registration state to error and adds description. |
+ void SetRegistrationError(const std::string& description); |
+ |
+ // |
+ void RegistrationTimeout(); |
+ |
// Checks if register call is called correctly (|user| is correct, |
// error is no set etc). Returns |false| if error status is put into |status|. |
// Otherwise no error was occurred. |
PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( |
- const std::string& user) const; |
+ const std::string& user); |
// Checks if confirmation was received. |
void WaitUserConfirmation(base::Time valid_until); |
@@ -181,19 +187,32 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
std::vector<std::string> CreateTxt() const; |
// Saving and loading registration info from file. |
- void SaveToFile() const; |
+ void SaveToFile(); |
bool LoadFromFile(); |
// Adds |OnIdle| method to the MessageLoop. |
void PostOnIdle(); |
+ // Registration timeout. |
+ void CheckRegistrationExpiration(); |
+ |
+ // Delays expiration after user action. |
+ void UpdateRegistrationExpiration(); |
+ |
+ // Deletes registration expiration at all. |
+ void InvalidateRegistrationExpiration(); |
+ |
// Converts errors. |
PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( |
RegistrationInfo::ConfirmationState state); |
std::string ConnectionStateToString(ConnectionState state) const; |
- // Changes state and update info in DNS server. |
+ // Stops all Internet-services and boots them again in |delay| time. |
+ void ReconnectIn(const base::TimeDelta& delay); |
+ |
+ // Changes state and update info in DNS server. Returns |true| if state |
+ // was changed (otherwise state was the same). |
bool ChangeState(ConnectionState new_state); |
RegistrationInfo reg_info_; |
@@ -224,6 +243,9 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
// Uses for calculating uptime. |
base::Time starttime_; |
+ // Uses to validate registration timeout. |
+ base::Time registration_expiration_; |
+ |
// Used for preventing two and more OnIdle posted in message loop. |
bool on_idle_posted_; |