Chromium Code Reviews| Index: cloud_print/gcp20/prototype/printer.h |
| diff --git a/cloud_print/gcp20/prototype/printer.h b/cloud_print/gcp20/prototype/printer.h |
| index 44f90bfa77b431c34698abd20e07b83a8268094d..7a111dc13ac223ff3b71b2260b807bfbda56aa12 100644 |
| --- a/cloud_print/gcp20/prototype/printer.h |
| +++ b/cloud_print/gcp20/prototype/printer.h |
| @@ -11,10 +11,13 @@ |
| #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/print_job_handler.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. |
| +extern const char kPrinterStatePath[]; |
| + |
| +// This class maintains work of DNS-SD server, HTTP server and others. |
| class Printer : public base::SupportsWeakPtr<Printer>, |
| public PrivetHttpServer::Delegate, |
| public CloudPrintRequester::Delegate { |
| @@ -31,6 +34,9 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
| // Returns true if printer was started. |
| bool IsOnline() const; |
| + // Method for trying to reconnecting to server. |
| + void WakeUp(); |
| + |
| // Stops all servers. |
| void Stop(); |
| @@ -78,6 +84,12 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
| REG_ACTION_COMPLETE, |
| REG_ACTION_CANCEL |
| }; |
|
Vitaly Buka (NO REVIEWS)
2013/07/22 23:46:02
empty line in between
maksymb
2013/07/23 00:40:38
Done.
|
| + enum ConnectionState { |
| + NOT_CONFIGURED, |
| + OFFLINE, |
| + ONLINE, |
| + CONNECTING |
| + }; |
| // PrivetHttpServer::Delegate methods: |
| virtual PrivetHttpServer::RegistrationErrorStatus RegistrationStart( |
| @@ -104,6 +116,13 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
| virtual void OnGetAuthCodeResponseParsed( |
| const std::string& refresh_token) OVERRIDE; |
| virtual void OnRegistrationError(const std::string& description) OVERRIDE; |
| + virtual void OnServerError(const std::string& description) OVERRIDE; |
| + virtual void OnNetworkError() OVERRIDE; |
| + virtual void OnPrintJobsAvailable( |
| + const std::vector<cloud_print_response_parser::Job>& jobs) OVERRIDE; |
| + virtual void OnPrintJobDownloaded( |
| + const cloud_print_response_parser::Job& job) OVERRIDE; |
| + virtual void OnPrintJobDone() OVERRIDE; |
| // Checks if register call is called correctly (|user| is correct, |
| // error is no set etc). Returns |false| if error status is put into |status|. |
| @@ -111,23 +130,37 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
| PrivetHttpServer::RegistrationErrorStatus CheckCommonRegErrors( |
| const std::string& user) const; |
| - // Generates ProxyId for this device. |
| - std::string GenerateProxyId() const; |
| - |
| // Checks if confirmation was received. |
| void WaitUserConfirmation(base::Time valid_until); |
| + // Generates ProxyId for this device. |
| + std::string GenerateProxyId() const; |
| + |
| // Creates data for DNS TXT respond. |
| std::vector<std::string> CreateTxt() const; |
| + // Ask CloudPrint server for printjobs. |
| + void FetchPrintJobs(); |
| + |
| // Saving and loading registration info from file. |
| void SaveToFile(const std::string& filename) const; |
| bool LoadFromFile(const std::string& filename); |
| + // Adds |WakeUp| method to the MessageLoop. |
| + void PostWakeUp(); |
| + |
| + // Adds |WakeUp| method to the MessageLoop with certain |delay|. |
| + void PostDelayedWakeUp(const base::TimeDelta& delay); |
| + |
| // Converts errors. |
| PrivetHttpServer::RegistrationErrorStatus ConfirmationToRegistrationError( |
| RegistrationInfo::ConfirmationState state); |
| + std::string ConnectionStateToString(ConnectionState state) const; |
| + |
| + // Changes state and update info in DNS server. |
| + bool ChangeState(ConnectionState new_state); |
| + |
| RegistrationInfo reg_info_; |
| // Contains DNS-SD server. |
| @@ -136,11 +169,16 @@ class Printer : public base::SupportsWeakPtr<Printer>, |
| // Contains Privet HTTP server. |
| PrivetHttpServer http_server_; |
| - // Contains Cloud Print client. |
| + // Connection state of device. |
| + ConnectionState connection_state_; |
| + |
| + // Contains CloudPrint client. |
| scoped_ptr<CloudPrintRequester> requester_; |
| XPrivetToken xtoken_; |
| + scoped_ptr<PrintJobHandler> print_job_handler_; |
| + |
| // Uses for calculating uptime. |
| base::Time starttime_; |