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

Unified Diff: sync/internal_api/attachments/attachment_server_url_builder.cc

Issue 278263003: Add a minimal AttachmentUploaderImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up after self-review. Created 6 years, 7 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: sync/internal_api/attachments/attachment_server_url_builder.cc
diff --git a/sync/internal_api/attachments/attachment_server_url_builder.cc b/sync/internal_api/attachments/attachment_server_url_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f871dd4dc63d007ad4ed42aa38cbafec2b35eaa
--- /dev/null
+++ b/sync/internal_api/attachments/attachment_server_url_builder.cc
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/internal_api/public/attachments/attachment_server_url_builder.h"
+
+#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+#include "sync/protocol/sync.pb.h"
+
+namespace {
+
+const char kPath[] = "uploads/";
+
+} // namespace
+
+namespace syncer {
+
+AttachmentServerURLBuilder::AttachmentServerURLBuilder(const Scheme& scheme,
+ const std::string& host,
+ const int port) {
+ std::string scheme_string;
+ switch (scheme) {
+ case SCHEME_HTTPS:
+ scheme_string = "https";
+ break;
+ case SCHEME_HTTP:
+ scheme_string = "http";
+ break;
+ default:
+ NOTREACHED();
+ };
+ url_prefix_ = base::StringPrintf(
+ "%s://%s:%d/%s", scheme_string.c_str(), host.c_str(), port, kPath);
+}
+
+AttachmentServerURLBuilder::~AttachmentServerURLBuilder() {
+}
+
+GURL AttachmentServerURLBuilder::BuildUploadURLFor(
+ const AttachmentId& attachment_id) const {
+ std::string unique_id = attachment_id.GetProto().unique_id();
+ DCHECK(!unique_id.empty());
+ return GURL(url_prefix_ + unique_id);
pavely 2014/05/14 18:38:31 Currently unique_id is guid, but it wasn't the cas
maniscalco 2014/05/14 21:59:03 Of course, we'd then need to decode it on the serv
+}
+
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698