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

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

Issue 19468002: Added confirmation for printer registration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-api-availability-check
Patch Set: Deleted <iostream> Created 7 years, 5 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.h
diff --git a/cloud_print/gcp20/prototype/printer.h b/cloud_print/gcp20/prototype/printer.h
index 1a23f24ad3d233da313bcd616d85f7e212eb121d..c225d80f85375a51f4ca0f72f9e677bf78d5dc37 100644
--- a/cloud_print/gcp20/prototype/printer.h
+++ b/cloud_print/gcp20/prototype/printer.h
@@ -13,7 +13,7 @@
#include "cloud_print/gcp20/prototype/privet_http_server.h"
#include "cloud_print/gcp20/prototype/x_privet_token.h"
-extern const char* kPrinterStatePath;
+extern const char kPrinterStatePath[];
// This class maintain work of DNS-SD server, HTTP server and others.
class Printer : public PrivetHttpServer::Delegate,
@@ -37,7 +37,7 @@ class Printer : public PrivetHttpServer::Delegate,
private:
struct RegistrationInfo {
enum RegistrationState {
- DEV_REG_UNREGISTERED = 0,
+ DEV_REG_UNREGISTERED,
DEV_REG_REGISTRATION_STARTED,
DEV_REG_REGISTRATION_CLAIM_TOKEN_READY,
DEV_REG_REGISTRATION_COMPLETING,
@@ -45,6 +45,13 @@ class Printer : public PrivetHttpServer::Delegate,
DEV_REG_REGISTERED,
};
+ enum ConfirmationState {
+ CONFIRMATION_PENDING,
+ CONFIRMATION_CONFIRMED,
+ CONFIRMATION_DISCARDED,
+ CONFIRMATION_TIMEOUT,
+ };
+
RegistrationInfo();
~RegistrationInfo();
@@ -52,6 +59,7 @@ class Printer : public PrivetHttpServer::Delegate,
std::string refresh_token;
std::string device_id;
RegistrationState state;
+ ConfirmationState confirmation_state;
std::string registration_token;
std::string complete_invite_url;
@@ -102,15 +110,22 @@ class Printer : public PrivetHttpServer::Delegate,
// Generates ProxyId for this device.
std::string GenerateProxyId() const;
+ // Checks if confirmation was received.
+ void WaitUserConfirmation(base::Time valid_until);
+
// Creates data for DNS TXT respond.
std::vector<std::string> CreateTxt() const;
- RegistrationInfo reg_info_;
-
// Saving and loading registration info from file.
void SaveToFile(const std::string& filename) const;
bool LoadFromFile(const std::string& filename);
+ // Converts errors.
+ PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError(
+ RegistrationInfo::ConfirmationState state);
+
+ RegistrationInfo reg_info_;
+
// Contains DNS-SD server.
DnsSdServer dns_server_;

Powered by Google App Engine
This is Rietveld 408576698