Index: chrome/browser/local_discovery/privetv3_session.h |
diff --git a/chrome/browser/local_discovery/privetv3_session.h b/chrome/browser/local_discovery/privetv3_session.h |
index 1d943f2272a4dfe151fbc9ccf3c641023f15c10b..ae2826ff7b6bfa8cfb8ea19f32d15ac7e502631c 100644 |
--- a/chrome/browser/local_discovery/privetv3_session.h |
+++ b/chrome/browser/local_discovery/privetv3_session.h |
@@ -9,6 +9,7 @@ |
#include "base/callback.h" |
#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/local_discovery/privet_url_fetcher.h" |
namespace base { |
class DictionaryValue; |
@@ -21,21 +22,14 @@ class PrivetHTTPClient; |
// Manages secure communication between browser and local Privet device. |
class PrivetV3Session { |
public: |
- typedef base::Callback< |
- void(bool success, const base::DictionaryValue& response)> |
- RequestCallback; |
- |
// Delegate to be implemented by client code. |
class Delegate { |
public: |
- typedef base::Callback<void(bool confirm)> ConfirmationCallback; |
- |
virtual ~Delegate(); |
// Called when client code should prompt user to check |confirmation_code|. |
virtual void OnSetupConfirmationNeeded( |
- const std::string& confirmation_code, |
- const ConfirmationCallback& callback) = 0; |
+ const std::string& confirmation_code) = 0; |
// Called when session successfully establish and client code my call |
// |CreateRequest| method. |
@@ -46,10 +40,19 @@ class PrivetV3Session { |
}; |
// Represents request in progress using secure session. |
- class Request { |
+ class Request : public PrivetURLFetcher::Delegate { |
public: |
+ Request(); |
virtual ~Request(); |
- virtual void Start() = 0; |
+ |
+ virtual std::string GetCallName() = 0; |
+ virtual const base::DictionaryValue& GetInput() = 0; |
+ virtual std::vector<std::string> GetExtraRequestHeaders(); |
+ |
+ private: |
+ friend PrivetV3Session; |
+ |
+ scoped_ptr<PrivetURLFetcher> url_fetcher_; |
}; |
PrivetV3Session(scoped_ptr<PrivetHTTPClient> client, Delegate* delegate); |
@@ -59,13 +62,15 @@ class PrivetV3Session { |
// |OnSessionEstablished|. |
void Start(); |
+ void ConfirmCode(); |
+ |
// Create a single /privet/v3/session/call request. |
- // Must be called only after receiving |OnSessionEstablished|. |
- scoped_ptr<Request> CreateRequest(const std::string& api_name, |
- const base::DictionaryValue& request, |
- const RequestCallback& callback); |
+ void StartRequest(Request* request); |
private: |
+ Delegate* delegate_; |
+ scoped_ptr<PrivetHTTPClient> client_; |
+ bool code_confirmed_; |
DISALLOW_COPY_AND_ASSIGN(PrivetV3Session); |
}; |