Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GCP20_PROTOTYPE_PRINTER_H_ | 5 #ifndef GCP20_PROTOTYPE_PRINTER_H_ |
| 6 #define GCP20_PROTOTYPE_PRINTER_H_ | 6 #define GCP20_PROTOTYPE_PRINTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 virtual void GetRegistrationServerError(std::string* description) OVERRIDE; | 108 virtual void GetRegistrationServerError(std::string* description) OVERRIDE; |
| 109 virtual void CreateInfo(PrivetHttpServer::DeviceInfo* info) OVERRIDE; | 109 virtual void CreateInfo(PrivetHttpServer::DeviceInfo* info) OVERRIDE; |
| 110 virtual bool IsRegistered() const OVERRIDE; | 110 virtual bool IsRegistered() const OVERRIDE; |
| 111 virtual bool CheckXPrivetTokenHeader(const std::string& token) const OVERRIDE; | 111 virtual bool CheckXPrivetTokenHeader(const std::string& token) const OVERRIDE; |
| 112 | 112 |
| 113 // CloudRequester::Delegate methods: | 113 // CloudRequester::Delegate methods: |
| 114 virtual void OnRegistrationStartResponseParsed( | 114 virtual void OnRegistrationStartResponseParsed( |
| 115 const std::string& registration_token, | 115 const std::string& registration_token, |
| 116 const std::string& complete_invite_url, | 116 const std::string& complete_invite_url, |
| 117 const std::string& device_id) OVERRIDE; | 117 const std::string& device_id) OVERRIDE; |
| 118 virtual void OnGetAuthCodeResponseParsed( | 118 virtual void OnRegistrationFinished( |
| 119 const std::string& refresh_token, | 119 const std::string& refresh_token, |
| 120 const std::string& access_token, | 120 const std::string& access_token, |
| 121 int access_token_expires_in_seconds) OVERRIDE; | 121 int access_token_expires_in_seconds) OVERRIDE; |
| 122 virtual void OnXmppJidReceived(const std::string& xmpp_jid) OVERRIDE; | 122 virtual void OnXmppJidReceived(const std::string& xmpp_jid) OVERRIDE; |
| 123 virtual void OnAccesstokenReceviced(const std::string& access_token, | 123 virtual void OnAccesstokenReceviced(const std::string& access_token, |
| 124 int expires_in_seconds) OVERRIDE; | 124 int expires_in_seconds) OVERRIDE; |
| 125 virtual void OnRegistrationError(const std::string& description) OVERRIDE; | 125 virtual void OnRegistrationError(const std::string& description) OVERRIDE; |
| 126 virtual void OnNetworkError() OVERRIDE; | 126 virtual void OnNetworkError() OVERRIDE; |
| 127 virtual void OnServerError(const std::string& description) OVERRIDE; | 127 virtual void OnServerError(const std::string& description) OVERRIDE; |
| 128 virtual void OnAuthError() OVERRIDE; | 128 virtual void OnAuthError() OVERRIDE; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 158 // Ask CloudPrint server for new local sendings. | 158 // Ask CloudPrint server for new local sendings. |
| 159 void GetLocalSettings(); | 159 void GetLocalSettings(); |
| 160 | 160 |
| 161 // Ask CloudPrint server for printjobs. | 161 // Ask CloudPrint server for printjobs. |
| 162 void FetchPrintJobs(); | 162 void FetchPrintJobs(); |
| 163 | 163 |
| 164 // Saves |access_token| and calculates time for next update. | 164 // Saves |access_token| and calculates time for next update. |
| 165 void RememberAccessToken(const std::string& access_token, | 165 void RememberAccessToken(const std::string& access_token, |
| 166 int expires_in_seconds); | 166 int expires_in_seconds); |
| 167 | 167 |
| 168 // Sets registration state to error and adds description. | |
| 169 void SetRegistrationError(const std::string& description); | |
| 170 | |
| 171 // | |
|
Vitaly Buka (NO REVIEWS)
2013/08/15 17:48:06
??
maksymb
2013/08/15 18:39:13
Unnecessary declaration deleted.
| |
| 172 void RegistrationTimeout(); | |
| 173 | |
| 168 // Checks if register call is called correctly (|user| is correct, | 174 // Checks if register call is called correctly (|user| is correct, |
| 169 // error is no set etc). Returns |false| if error status is put into |status|. | 175 // error is no set etc). Returns |false| if error status is put into |status|. |
| 170 // Otherwise no error was occurred. | 176 // Otherwise no error was occurred. |
| 171 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( | 177 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( |
| 172 const std::string& user) const; | 178 const std::string& user); |
| 173 | 179 |
| 174 // Checks if confirmation was received. | 180 // Checks if confirmation was received. |
| 175 void WaitUserConfirmation(base::Time valid_until); | 181 void WaitUserConfirmation(base::Time valid_until); |
| 176 | 182 |
| 177 // Generates ProxyId for this device. | 183 // Generates ProxyId for this device. |
| 178 std::string GenerateProxyId() const; | 184 std::string GenerateProxyId() const; |
| 179 | 185 |
| 180 // Creates data for DNS TXT respond. | 186 // Creates data for DNS TXT respond. |
| 181 std::vector<std::string> CreateTxt() const; | 187 std::vector<std::string> CreateTxt() const; |
| 182 | 188 |
| 183 // Saving and loading registration info from file. | 189 // Saving and loading registration info from file. |
| 184 void SaveToFile() const; | 190 void SaveToFile() const; |
| 185 bool LoadFromFile(); | 191 bool LoadFromFile(); |
| 186 | 192 |
| 187 // Adds |OnIdle| method to the MessageLoop. | 193 // Adds |OnIdle| method to the MessageLoop. |
| 188 void PostOnIdle(); | 194 void PostOnIdle(); |
| 189 | 195 |
| 196 // Registration timeout. | |
| 197 void CheckRegistrationExpiration(); | |
| 198 | |
| 199 // Delays expiration after user action. | |
| 200 void UpdateRegistrationExpiration(); | |
| 201 | |
| 202 // Deletes registration expiration at all. | |
| 203 void InvalidateRegistrationExpiration(); | |
| 204 | |
| 190 // Converts errors. | 205 // Converts errors. |
| 191 PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( | 206 PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( |
| 192 RegistrationInfo::ConfirmationState state); | 207 RegistrationInfo::ConfirmationState state); |
| 193 | 208 |
| 194 std::string ConnectionStateToString(ConnectionState state) const; | 209 std::string ConnectionStateToString(ConnectionState state) const; |
| 195 | 210 |
| 196 // Changes state and update info in DNS server. | 211 // Changes state to OFFLINE and posts TryReconnect. |
| 212 void FallOffline(bool instant_reconnect); | |
| 213 | |
| 214 // Changes state and update info in DNS server. Returns |true| if state | |
| 215 // was changed (otherwise state was the same). | |
| 197 bool ChangeState(ConnectionState new_state); | 216 bool ChangeState(ConnectionState new_state); |
| 198 | 217 |
| 199 RegistrationInfo reg_info_; | 218 RegistrationInfo reg_info_; |
| 200 | 219 |
| 201 // Contains DNS-SD server. | 220 // Contains DNS-SD server. |
| 202 DnsSdServer dns_server_; | 221 DnsSdServer dns_server_; |
| 203 | 222 |
| 204 // Contains Privet HTTP server. | 223 // Contains Privet HTTP server. |
| 205 PrivetHttpServer http_server_; | 224 PrivetHttpServer http_server_; |
| 206 | 225 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 217 | 236 |
| 218 scoped_ptr<PrintJobHandler> print_job_handler_; | 237 scoped_ptr<PrintJobHandler> print_job_handler_; |
| 219 | 238 |
| 220 // Last valid |access_token|. | 239 // Last valid |access_token|. |
| 221 std::string access_token_; | 240 std::string access_token_; |
| 222 base::Time access_token_update_; | 241 base::Time access_token_update_; |
| 223 | 242 |
| 224 // Uses for calculating uptime. | 243 // Uses for calculating uptime. |
| 225 base::Time starttime_; | 244 base::Time starttime_; |
| 226 | 245 |
| 246 // Uses to validate registration timeout. | |
| 247 base::Time registration_expiration_; | |
| 248 | |
| 227 // Used for preventing two and more OnIdle posted in message loop. | 249 // Used for preventing two and more OnIdle posted in message loop. |
| 228 bool on_idle_posted_; | 250 bool on_idle_posted_; |
| 229 | 251 |
| 230 // Contains |true| if Printer has to check pending local settings. | 252 // Contains |true| if Printer has to check pending local settings. |
| 231 bool pending_local_settings_check_; | 253 bool pending_local_settings_check_; |
| 232 | 254 |
| 233 // Contains |true| if Printer has to check available printjobs. | 255 // Contains |true| if Printer has to check available printjobs. |
| 234 bool pending_print_jobs_check_; | 256 bool pending_print_jobs_check_; |
| 235 | 257 |
| 236 DISALLOW_COPY_AND_ASSIGN(Printer); | 258 DISALLOW_COPY_AND_ASSIGN(Printer); |
| 237 }; | 259 }; |
| 238 | 260 |
| 239 #endif // GCP20_PROTOTYPE_PRINTER_H_ | 261 #endif // GCP20_PROTOTYPE_PRINTER_H_ |
| 240 | 262 |
| OLD | NEW |