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

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

Issue 138983002: Added privet storage list operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/privet_http_impl.cc
diff --git a/chrome/browser/local_discovery/privet_http_impl.cc b/chrome/browser/local_discovery/privet_http_impl.cc
index c5bc7c953d03d72fa57d54e362bec3d85b157c7b..c7eac78c58a12372dd8891652b4df9d124d288a3 100644
--- a/chrome/browser/local_discovery/privet_http_impl.cc
+++ b/chrome/browser/local_discovery/privet_http_impl.cc
@@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
@@ -32,6 +33,9 @@ const char kPrivetContentTypePWGRaster[] = "image/pwg-raster";
const char kPrivetContentTypeAny[] = "*/*";
const char kPrivetContentTypeCJT[] = "application/json";
+const char kPrivetStorageListPath[] = "/privet/storage/list";
+const char kPrivetStorageParamPathFormat[] = "path=%s";
+
const char kPrivetCDDKeySupportedContentTypes[] =
"printer.supported_content_type";
@@ -59,6 +63,17 @@ GURL CreatePrivetRegisterURL(const std::string& action,
return net::AppendQueryParameter(url, kPrivetRegisterUserArgName, user);
}
+GURL CreatePrivetParamURL(const std::string& path,
+ const std::string& query_params) {
+ GURL url(kUrlPlaceHolder);
+ GURL::Replacements replacements;
+ replacements.SetPathStr(path);
+ if (!query_params.empty()) {
+ replacements.SetQueryStr(query_params);
+ }
+ return url.ReplaceComponents(replacements);
+}
+
} // namespace
PrivetInfoOperationImpl::PrivetInfoOperationImpl(
@@ -324,8 +339,10 @@ void PrivetRegisterOperationImpl::Cancelation::Cleanup() {
PrivetJSONOperationImpl::PrivetJSONOperationImpl(
PrivetHTTPClientImpl* privet_client,
const std::string& path,
+ const std::string& query_params,
const PrivetJSONOperation::ResultCallback& callback)
- : privet_client_(privet_client), path_(path), callback_(callback) {
+ : privet_client_(privet_client), path_(path), query_params_(query_params),
+ callback_(callback) {
}
PrivetJSONOperationImpl::~PrivetJSONOperationImpl() {
@@ -333,7 +350,7 @@ PrivetJSONOperationImpl::~PrivetJSONOperationImpl() {
void PrivetJSONOperationImpl::Start() {
url_fetcher_ = privet_client_->CreateURLFetcher(
- CreatePrivetURL(path_), net::URLFetcher::GET, this);
+ CreatePrivetParamURL(path_, query_params_), net::URLFetcher::GET, this);
url_fetcher_->DoNotRetryOnTransientError();
url_fetcher_->Start();
}
@@ -717,7 +734,7 @@ scoped_ptr<PrivetJSONOperation>
PrivetHTTPClientImpl::CreateCapabilitiesOperation(
const PrivetJSONOperation::ResultCallback& callback) {
return scoped_ptr<PrivetJSONOperation>(
- new PrivetJSONOperationImpl(this, kPrivetCapabilitiesPath, callback));
+ new PrivetJSONOperationImpl(this, kPrivetCapabilitiesPath, "", callback));
}
scoped_ptr<PrivetLocalPrintOperation>
@@ -727,6 +744,17 @@ PrivetHTTPClientImpl::CreateLocalPrintOperation(
new PrivetLocalPrintOperationImpl(this, delegate));
}
+scoped_ptr<PrivetJSONOperation>
+PrivetHTTPClientImpl::CreateStorageListOperation(
+ const std::string& path,
+ const PrivetJSONOperation::ResultCallback& callback) {
+ std::string url_param = base::StringPrintf(kPrivetStorageParamPathFormat,
+ path.c_str());
+ return scoped_ptr<PrivetJSONOperation>(
+ new PrivetJSONOperationImpl(this, kPrivetStorageListPath, url_param,
+ callback));
+}
+
const std::string& PrivetHTTPClientImpl::GetName() {
return name_;
}
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.h ('k') | chrome/browser/local_discovery/privet_http_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698