Index: chrome/browser/local_discovery/privetv3_session.cc |
diff --git a/chrome/browser/local_discovery/privetv3_session.cc b/chrome/browser/local_discovery/privetv3_session.cc |
index 64c8d1fe59d2ad39c1bdb393b19560a8d909803e..36a57186b77b546580123afa4e691aa658f02ba8 100644 |
--- a/chrome/browser/local_discovery/privetv3_session.cc |
+++ b/chrome/browser/local_discovery/privetv3_session.cc |
@@ -4,25 +4,67 @@ |
#include "chrome/browser/local_discovery/privetv3_session.h" |
+#include "base/json/json_writer.h" |
#include "base/logging.h" |
#include "chrome/browser/local_discovery/privet_http.h" |
+#include "chrome/common/cloud_print/cloud_print_constants.h" |
namespace local_discovery { |
+namespace { |
+ |
+const char kUrlPlaceHolder[] = "http://host/"; |
+ |
+GURL CreatePrivetURL(const std::string& path) { |
+ GURL url(kUrlPlaceHolder); |
+ GURL::Replacements replacements; |
+ replacements.SetPathStr(path); |
+ return url.ReplaceComponents(replacements); |
+} |
+ |
+} // namespace |
+ |
PrivetV3Session::Delegate::~Delegate() { |
} |
+PrivetV3Session::Request::Request() { |
+} |
+ |
PrivetV3Session::Request::~Request() { |
} |
+std::vector<std::string> PrivetV3Session::Request::GetExtraRequestHeaders() { |
+ return std::vector<std::string>(); |
+} |
+ |
PrivetV3Session::PrivetV3Session(scoped_ptr<PrivetHTTPClient> client, |
- Delegate* delegate) { |
+ Delegate* delegate) |
+ : delegate_(delegate), client_(client.Pass()), code_confirmed_(false) { |
} |
PrivetV3Session::~PrivetV3Session() { |
} |
void PrivetV3Session::Start() { |
+ delegate_->OnSetupConfirmationNeeded("01234"); |
+} |
+ |
+void PrivetV3Session::ConfirmCode() { |
+ code_confirmed_ = true; |
+ delegate_->OnSessionEstablished(); |
+} |
+ |
+void PrivetV3Session::StartRequest(Request* request) { |
+ CHECK(code_confirmed_); |
+ request->url_fetcher_ = client_->CreateURLFetcher( |
+ CreatePrivetURL(request->GetCallName()), net::URLFetcher::POST, request); |
+ request->url_fetcher_->SendEmptyPrivetToken(); |
Noam Samuel
2014/07/16 20:48:23
Please remove this line.
Vitaly Buka (NO REVIEWS)
2014/07/16 20:53:23
Done.
|
+ |
+ std::string json; |
+ base::JSONWriter::WriteWithOptions( |
+ &request->GetInput(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); |
+ request->url_fetcher_->SetUploadData(cloud_print::kContentTypeJSON, json); |
+ request->url_fetcher_->Start(); |
} |
} // namespace local_discovery |