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

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: kbhit to _kbhit 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
« no previous file with comments | « cloud_print/gcp20/prototype/gcp20_device.gyp ('k') | cloud_print/gcp20/prototype/printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cloud_print/gcp20/prototype/printer.h
diff --git a/cloud_print/gcp20/prototype/printer.h b/cloud_print/gcp20/prototype/printer.h
index 246e3df32d4f354a34b1efb1aee9173ef0e00cc9..9dba7874a147f572469ae64e5a13e1728387a2a3 100644
--- a/cloud_print/gcp20/prototype/printer.h
+++ b/cloud_print/gcp20/prototype/printer.h
@@ -8,13 +8,15 @@
#include <string>
#include <vector>
+#include "base/memory/weak_ptr.h"
#include "cloud_print/gcp20/prototype/cloud_print_requester.h"
#include "cloud_print/gcp20/prototype/dns_sd_server.h"
#include "cloud_print/gcp20/prototype/privet_http_server.h"
#include "cloud_print/gcp20/prototype/x_privet_token.h"
// This class maintain work of DNS-SD server, HTTP server and others.
-class Printer : public PrivetHttpServer::Delegate,
+class Printer : public base::SupportsWeakPtr<Printer>,
+ public PrivetHttpServer::Delegate,
public CloudPrintRequester::Delegate {
public:
// Constructs uninitialized object.
@@ -35,14 +37,25 @@ class Printer : public PrivetHttpServer::Delegate,
private:
struct RegistrationInfo {
enum RegistrationState {
- DEV_REG_UNREGISTERED = 0,
- DEV_REG_REGISTRATION_STARTED,
- DEV_REG_REGISTRATION_CLAIM_TOKEN_READY,
- DEV_REG_REGISTRATION_COMPLETING,
- DEV_REG_REGISTRATION_ERROR,
+ DEV_REG_UNREGISTERED,
+ DEV_REG_REGISTRATION_STARTED, // |action=start| was called,
+ // request to CloudPrint was sent.
+ DEV_REG_REGISTRATION_CLAIM_TOKEN_READY, // The same as previous,
+ // but request reply is already
+ // received.
+ DEV_REG_REGISTRATION_COMPLETING, // |action=complete| was called,
+ // |complete| request was sent.
+ DEV_REG_REGISTRATION_ERROR, // Is set when server error was occurred.
DEV_REG_REGISTERED,
};
+ enum ConfirmationState {
+ CONFIRMATION_PENDING,
+ CONFIRMATION_CONFIRMED,
+ CONFIRMATION_DISCARDED,
+ CONFIRMATION_TIMEOUT,
+ };
+
RegistrationInfo();
~RegistrationInfo();
@@ -50,6 +63,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;
@@ -100,15 +114,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 base::FilePath& file_path) const;
bool LoadFromFile(const base::FilePath& file_path);
+ // Converts errors.
+ PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError(
+ RegistrationInfo::ConfirmationState state);
+
+ RegistrationInfo reg_info_;
+
// Contains DNS-SD server.
DnsSdServer dns_server_;
« no previous file with comments | « cloud_print/gcp20/prototype/gcp20_device.gyp ('k') | cloud_print/gcp20/prototype/printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698