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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698