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

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

Issue 356953009: Revert of Consolidate attachment URL construction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_uploader_impl.cc
diff --git a/sync/internal_api/attachments/attachment_uploader_impl.cc b/sync/internal_api/attachments/attachment_uploader_impl.cc
index 9048b206d9f08eae30efa23cc6dd291ac6277c22..90c620e5802864cba4629bdfff72ec57cac32596 100644
--- a/sync/internal_api/attachments/attachment_uploader_impl.cc
+++ b/sync/internal_api/attachments/attachment_uploader_impl.cc
@@ -14,11 +14,11 @@
#include "net/url_request/url_fetcher_delegate.h"
#include "sync/api/attachments/attachment.h"
#include "sync/protocol/sync.pb.h"
+#include "url/gurl.h"
namespace {
const char kContentType[] = "application/octet-stream";
-const char kAttachments[] = "attachments/";
} // namespace
@@ -209,14 +209,14 @@
}
AttachmentUploaderImpl::AttachmentUploaderImpl(
- const GURL& sync_service_url,
+ const std::string& url_prefix,
const scoped_refptr<net::URLRequestContextGetter>&
url_request_context_getter,
const std::string& account_id,
const OAuth2TokenService::ScopeSet& scopes,
scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider>
token_service_provider)
- : sync_service_url_(sync_service_url),
+ : url_prefix_(url_prefix),
url_request_context_getter_(url_request_context_getter),
account_id_(account_id),
scopes_(scopes),
@@ -237,7 +237,7 @@
DCHECK(!unique_id.empty());
StateMap::iterator iter = state_map_.find(unique_id);
if (iter == state_map_.end()) {
- const GURL url = GetURLForAttachmentId(sync_service_url_, attachment_id);
+ const GURL url = GetUploadURLForAttachmentId(attachment_id);
scoped_ptr<UploadState> upload_state(
new UploadState(url,
url_request_context_getter_,
@@ -256,19 +256,9 @@
}
}
-// Static.
-GURL AttachmentUploaderImpl::GetURLForAttachmentId(
- const GURL& sync_service_url,
- const AttachmentId& attachment_id) {
- std::string path = sync_service_url.path();
- if (path.empty() || *path.rbegin() != '/') {
- path += '/';
- }
- path += kAttachments;
- path += attachment_id.GetProto().unique_id();
- GURL::Replacements replacements;
- replacements.SetPathStr(path);
- return sync_service_url.ReplaceComponents(replacements);
+GURL AttachmentUploaderImpl::GetUploadURLForAttachmentId(
+ const AttachmentId& attachment_id) const {
+ return GURL(url_prefix_ + attachment_id.GetProto().unique_id());
}
void AttachmentUploaderImpl::DeleteUploadStateFor(const UniqueId& unique_id) {

Powered by Google App Engine
This is Rietveld 408576698