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 |