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

Side by Side Diff: chrome/browser/local_discovery/privetv3_setup_flow.h

Issue 383023002: Partial setup flow with unittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/local_discovery/gcd_api_flow.h" 12 #include "chrome/browser/local_discovery/gcd_api_flow.h"
13 #include "chrome/browser/local_discovery/privet_http.h" 13 #include "chrome/browser/local_discovery/privet_http.h"
14 #include "chrome/browser/local_discovery/privetv3_session.h"
14 15
15 namespace local_discovery { 16 namespace local_discovery {
16 17
17 // Provides complete flow for Privet v3 device setup. 18 // Provides complete flow for Privet v3 device setup.
18 class PrivetV3SetupFlow { 19 class PrivetV3SetupFlow : public PrivetV3Session::Delegate {
19 public: 20 public:
20 // Delegate to be implemented by client code. 21 // Delegate to be implemented by client code.
21 class Delegate { 22 class Delegate {
22 public: 23 public:
23 typedef base::Callback<void(bool success)> ResultCallback; 24 typedef base::Callback<void(bool success)> ResultCallback;
24 // If |ssid| is empty, call failed to get credentials. 25 // If |ssid| is empty, call failed to get credentials.
25 // If |key| is empty, network is open. 26 // If |key| is empty, network is open.
26 typedef base::Callback<void(const std::string& ssid, 27 typedef base::Callback<void(const std::string& ssid,
27 const std::string& key)> CredentialsCallback; 28 const std::string& key)> CredentialsCallback;
28 29
(...skipping 25 matching lines...) Expand all
54 virtual void RestoreWifi(const ResultCallback& callback) = 0; 55 virtual void RestoreWifi(const ResultCallback& callback) = 0;
55 56
56 // Notifies client that device is set up. 57 // Notifies client that device is set up.
57 virtual void OnSetupDone() = 0; 58 virtual void OnSetupDone() = 0;
58 59
59 // Notifies client setup failed. 60 // Notifies client setup failed.
60 virtual void OnSetupError() = 0; 61 virtual void OnSetupError() = 0;
61 }; 62 };
62 63
63 explicit PrivetV3SetupFlow(Delegate* delegate); 64 explicit PrivetV3SetupFlow(Delegate* delegate);
64 ~PrivetV3SetupFlow(); 65 virtual ~PrivetV3SetupFlow();
65 66
66 // Starts registration. 67 // Starts registration.
67 void Register(const std::string& service_name); 68 void Register(const std::string& service_name);
68 69
69 #if defined(ENABLE_WIFI_BOOTSTRAPPING) 70 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
70 void SetupWifiAndRegister(const std::string& device_ssid); 71 void SetupWifiAndRegister(const std::string& device_ssid);
71 #endif // ENABLE_WIFI_BOOTSTRAPPING 72 #endif // ENABLE_WIFI_BOOTSTRAPPING
72 73
74 // PrivetV3Session::Delegate implementation.
75 virtual void OnSetupConfirmationNeeded(
76 const std::string& confirmation_code) OVERRIDE;
77 virtual void OnSessionEstablished() OVERRIDE;
78 virtual void OnCannotEstablishSession() OVERRIDE;
79
80 void OnSetupError();
81 void OnDeviceRegistered();
82
73 private: 83 private:
84 void OnTicketCreated(const std::string& ticket_id);
85 void OnPrivetClientCreated(scoped_ptr<PrivetHTTPClient> privet_http_client);
86 void OnCodeConfirmed(bool success);
87
74 Delegate* delegate_; 88 Delegate* delegate_;
75 std::string service_name_; 89 std::string service_name_;
90 scoped_ptr<GCDApiFlow> ticket_request_;
91 scoped_ptr<PrivetV3Session> session_;
92 scoped_ptr<PrivetV3Session::Request> setup_request_;
76 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_; 93 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_;
77 94
78 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow); 95 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow);
79 }; 96 };
80 97
81 } // namespace local_discovery 98 } // namespace local_discovery
82 99
83 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ 100 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privetv3_session_unittest.cc ('k') | chrome/browser/local_discovery/privetv3_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698