Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sync/internal_api/public/attachments/attachment_server_url_builder.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/strings/stringprintf.h" | |
| 9 #include "sync/protocol/sync.pb.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 const char kPath[] = "uploads/"; | |
| 14 | |
| 15 } // namespace | |
| 16 | |
| 17 namespace syncer { | |
| 18 | |
| 19 AttachmentServerURLBuilder::AttachmentServerURLBuilder(const Scheme& scheme, | |
| 20 const std::string& host, | |
| 21 const int port) { | |
| 22 std::string scheme_string; | |
| 23 switch (scheme) { | |
| 24 case SCHEME_HTTPS: | |
| 25 scheme_string = "https"; | |
| 26 break; | |
| 27 case SCHEME_HTTP: | |
| 28 scheme_string = "http"; | |
| 29 break; | |
| 30 default: | |
| 31 NOTREACHED(); | |
| 32 }; | |
| 33 url_prefix_ = base::StringPrintf( | |
| 34 "%s://%s:%d/%s", scheme_string.c_str(), host.c_str(), port, kPath); | |
| 35 } | |
| 36 | |
| 37 AttachmentServerURLBuilder::~AttachmentServerURLBuilder() { | |
| 38 } | |
| 39 | |
| 40 GURL AttachmentServerURLBuilder::BuildUploadURLFor( | |
| 41 const AttachmentId& attachment_id) const { | |
| 42 std::string unique_id = attachment_id.GetProto().unique_id(); | |
| 43 DCHECK(!unique_id.empty()); | |
| 44 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
| |
| 45 } | |
| 46 | |
| 47 } // namespace syncer | |
| OLD | NEW |