summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 03:49:50 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 03:49:50 +0000
commitb63bfd435c9e7632d9823194291610a29079117c (patch)
tree4f8fb152270a3d5b883424768d3545bb567f666a
parent6c3b950fa92a7e5900ced3913e54ace987c491b3 (diff)
downloadchromium_src-b63bfd435c9e7632d9823194291610a29079117c.zip
chromium_src-b63bfd435c9e7632d9823194291610a29079117c.tar.gz
chromium_src-b63bfd435c9e7632d9823194291610a29079117c.tar.bz2
Updated PrivetV3SetupFlow API.
BUG=372843 Review URL: https://codereview.chromium.org/323563006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275603 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/local_discovery/privetv3_setup_flow.cc26
-rw-r--r--chrome/browser/local_discovery/privetv3_setup_flow.h79
2 files changed, 60 insertions, 45 deletions
diff --git a/chrome/browser/local_discovery/privetv3_setup_flow.cc b/chrome/browser/local_discovery/privetv3_setup_flow.cc
index 879dc28..5cafa93 100644
--- a/chrome/browser/local_discovery/privetv3_setup_flow.cc
+++ b/chrome/browser/local_discovery/privetv3_setup_flow.cc
@@ -8,24 +8,24 @@
namespace local_discovery {
-scoped_ptr<PrivetV3SetupFlow> PrivetV3SetupFlow::CreateMDnsOnlyFlow(
- ServiceDiscoveryClient* service_discovery_client,
- const std::string& service_name) {
+PrivetV3SetupFlow::Delegate::~Delegate() {
+}
+
+PrivetV3SetupFlow::PrivetV3SetupFlow(Delegate* delegate)
+ : delegate_(delegate), weak_ptr_factory_(this) {
+}
+
+PrivetV3SetupFlow::~PrivetV3SetupFlow() {
+}
+
+void PrivetV3SetupFlow::Register(const std::string& service_name) {
NOTIMPLEMENTED();
- return scoped_ptr<PrivetV3SetupFlow>();
}
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
-scoped_ptr<PrivetV3SetupFlow> PrivetV3SetupFlow::CreateWifiFlow(
- ServiceDiscoveryClient* service_discovery_client,
- wifi::WifiManager* wifi_manager,
- // The SSID of the network whose credentials we will be provisioning.
- const std::string& credentials_ssid,
- // The SSID of the device we will be provisioning.
- const std::string& device_ssid) {
+void PrivetV3SetupFlow::SetupWifiAndRegister(const std::string& device_ssid) {
NOTIMPLEMENTED();
- return scoped_ptr<PrivetV3SetupFlow>();
}
-#endif
+#endif // ENABLE_WIFI_BOOTSTRAPPING
} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/privetv3_setup_flow.h b/chrome/browser/local_discovery/privetv3_setup_flow.h
index 405b02c..81e7b44 100644
--- a/chrome/browser/local_discovery/privetv3_setup_flow.h
+++ b/chrome/browser/local_discovery/privetv3_setup_flow.h
@@ -9,57 +9,72 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/local_discovery/gcd_api_flow.h"
+#include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h"
namespace local_discovery {
-class ServiceDiscoveryClient;
-
-#if defined(ENABLE_WIFI_BOOTSTRAPPING)
-namespace wifi {
-class WifiManager;
-};
-#endif
-
+// Provides complete flow for Privet v3 device setup.
class PrivetV3SetupFlow {
public:
+ // Delegate to be implemented by client code.
class Delegate {
public:
- typedef base::Callback<void(bool confirm)> ConfirmationCallback;
- typedef base::Callback<void(const std::string& key)> CredentialsCallback;
+ typedef base::Callback<void(bool success)> ResultCallback;
+ // If |ssid| is empty, call failed to get credentials.
+ // If |key| is empty, network is open.
+ typedef base::Callback<void(const std::string& ssid,
+ const std::string& key)> CredentialsCallback;
- virtual ~Delegate() {}
+ virtual ~Delegate();
-#if defined(ENABLE_WIFI_BOOTSTRAPPING)
- virtual void OnSetupCredentialsNeeded(const std::string& ssid,
- const CredentialsCallback& callback);
-#endif
+ // Creates |GCDApiFlow| for making requests to GCD server.
+ virtual scoped_ptr<GCDApiFlow> CreateApiFlow(
+ scoped_ptr<GCDApiFlow::Request> request) = 0;
+
+ // Requests WiFi credentials.
+ virtual void GetWiFiCredentials(const CredentialsCallback& callback) = 0;
- virtual void OnSetupConfirmationNeeded(
- const std::string& confirmation_code,
- const ConfirmationCallback& callback) = 0;
+ // Switches to setup WiFi network.
+ // If switch was successfully |RestoreWifi| should be called later.
+ virtual void SwitchToSetupWiFi(const ResultCallback& callback) = 0;
+ // Starts device resolution that should callback with ready
+ // |PrivetHTTPClient|.
+ virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP(
+ const std::string& service_name,
+ const PrivetHTTPAsynchronousFactory::ResultCallback& callback) = 0;
+
+ // Requests client to prompt user to check |confirmation_code|.
+ virtual void ConfirmSecurityCode(const std::string& confirmation_code,
+ const ResultCallback& callback) = 0;
+
+ // Restores WiFi network.
+ virtual void RestoreWifi(const ResultCallback& callback) = 0;
+
+ // Notifies client that device is set up.
virtual void OnSetupDone() = 0;
+ // Notifies client setup failed.
virtual void OnSetupError() = 0;
};
- virtual ~PrivetV3SetupFlow() {}
+ explicit PrivetV3SetupFlow(Delegate* delegate);
+ ~PrivetV3SetupFlow();
- static scoped_ptr<PrivetV3SetupFlow> CreateMDnsOnlyFlow(
- ServiceDiscoveryClient* service_discovery_client,
- const std::string& service_name);
+ // Starts registration.
+ void Register(const std::string& service_name);
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
- static scoped_ptr<PrivetV3SetupFlow> CreateWifiFlow(
- ServiceDiscoveryClient* service_discovery_client,
- wifi::WifiManager* wifi_manager,
- // The SSID of the network whose credentials we will be provisioning.
- const std::string& credentials_ssid,
- // The SSID of the device we will be provisioning.
- const std::string& device_ssid);
-#endif
-
- virtual void Start() = 0;
+ void SetupWifiAndRegister(const std::string& device_ssid);
+#endif // ENABLE_WIFI_BOOTSTRAPPING
+
+ private:
+ Delegate* delegate_;
+ std::string service_name_;
+ base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow);
};
} // namespace local_discovery