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

Side by Side Diff: cloud_print/gcp20/prototype/printer.h

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 unified diff | Download patch
OLDNEW
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
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
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
168 // Checks if register call is called correctly (|user| is correct, 171 // 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|. 172 // error is no set etc). Returns |false| if error status is put into |status|.
170 // Otherwise no error was occurred. 173 // Otherwise no error was occurred.
171 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( 174 PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors(
172 const std::string& user) const; 175 const std::string& user);
173 176
174 // Checks if confirmation was received. 177 // Checks if confirmation was received.
175 void WaitUserConfirmation(base::Time valid_until); 178 void WaitUserConfirmation(base::Time valid_until);
176 179
177 // Generates ProxyId for this device. 180 // Generates ProxyId for this device.
178 std::string GenerateProxyId() const; 181 std::string GenerateProxyId() const;
179 182
180 // Creates data for DNS TXT respond. 183 // Creates data for DNS TXT respond.
181 std::vector<std::string> CreateTxt() const; 184 std::vector<std::string> CreateTxt() const;
182 185
183 // Saving and loading registration info from file. 186 // Saving and loading registration info from file.
184 void SaveToFile() const; 187 void SaveToFile() const;
185 bool LoadFromFile(); 188 bool LoadFromFile();
186 189
187 // Adds |OnIdle| method to the MessageLoop. 190 // Adds |OnIdle| method to the MessageLoop.
188 void PostOnIdle(); 191 void PostOnIdle();
189 192
193 // Registration timeout.
194 void CheckRegistrationExpiration();
195
196 // Delays expiration after user action.
197 void UpdateRegistrationExpiration();
198
199 // Deletes registration expiration at all.
200 void InvalidateRegistrationExpiration();
201
190 // Converts errors. 202 // Converts errors.
191 PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( 203 PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError(
192 RegistrationInfo::ConfirmationState state); 204 RegistrationInfo::ConfirmationState state);
193 205
194 std::string ConnectionStateToString(ConnectionState state) const; 206 std::string ConnectionStateToString(ConnectionState state) const;
195 207
196 // Changes state and update info in DNS server. 208 // Changes state to OFFLINE and posts TryReconnect.
209 // For registration reconnect is instant every time.
210 void FallOffline(bool instant_reconnect);
211
212 // Changes state and update info in DNS server. Returns |true| if state
213 // was changed (otherwise state was the same).
197 bool ChangeState(ConnectionState new_state); 214 bool ChangeState(ConnectionState new_state);
198 215
199 RegistrationInfo reg_info_; 216 RegistrationInfo reg_info_;
200 217
201 // Contains DNS-SD server. 218 // Contains DNS-SD server.
202 DnsSdServer dns_server_; 219 DnsSdServer dns_server_;
203 220
204 // Contains Privet HTTP server. 221 // Contains Privet HTTP server.
205 PrivetHttpServer http_server_; 222 PrivetHttpServer http_server_;
206 223
(...skipping 10 matching lines...) Expand all
217 234
218 scoped_ptr<PrintJobHandler> print_job_handler_; 235 scoped_ptr<PrintJobHandler> print_job_handler_;
219 236
220 // Last valid |access_token|. 237 // Last valid |access_token|.
221 std::string access_token_; 238 std::string access_token_;
222 base::Time access_token_update_; 239 base::Time access_token_update_;
223 240
224 // Uses for calculating uptime. 241 // Uses for calculating uptime.
225 base::Time starttime_; 242 base::Time starttime_;
226 243
244 // Uses to validate registration timeout.
245 base::Time registration_expiration_;
246
227 // Used for preventing two and more OnIdle posted in message loop. 247 // Used for preventing two and more OnIdle posted in message loop.
228 bool on_idle_posted_; 248 bool on_idle_posted_;
229 249
230 // Contains |true| if Printer has to check pending local settings. 250 // Contains |true| if Printer has to check pending local settings.
231 bool pending_local_settings_check_; 251 bool pending_local_settings_check_;
232 252
233 // Contains |true| if Printer has to check available printjobs. 253 // Contains |true| if Printer has to check available printjobs.
234 bool pending_print_jobs_check_; 254 bool pending_print_jobs_check_;
235 255
236 DISALLOW_COPY_AND_ASSIGN(Printer); 256 DISALLOW_COPY_AND_ASSIGN(Printer);
237 }; 257 };
238 258
239 #endif // GCP20_PROTOTYPE_PRINTER_H_ 259 #endif // GCP20_PROTOTYPE_PRINTER_H_
240 260
OLDNEW
« no previous file with comments | « cloud_print/gcp20/prototype/cloud_print_requester.cc ('k') | cloud_print/gcp20/prototype/printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698