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

Unified Diff: chrome/browser/local_discovery/privetv3_session.cc

Issue 383023002: Partial setup flow with unittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wed 07/16/2014 12:37:42.65 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698