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

Unified Diff: sync/internal_api/public/attachments/attachment_uploader_impl.h

Issue 278263003: Add a minimal AttachmentUploaderImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Apply 2nd round of CR feedback from pavely. 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
« no previous file with comments | « sync/internal_api/attachments/fake_attachment_uploader.cc ('k') | sync/sync_internal_api.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/public/attachments/attachment_uploader_impl.h
diff --git a/sync/internal_api/public/attachments/attachment_uploader_impl.h b/sync/internal_api/public/attachments/attachment_uploader_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..0720bcb0594334e7da082471f5e90334030e58e4
--- /dev/null
+++ b/sync/internal_api/public/attachments/attachment_uploader_impl.h
@@ -0,0 +1,52 @@
+// 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.
+
+#ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
+#define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
+
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/threading/non_thread_safe.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "sync/api/attachments/attachment_uploader.h"
+
+class GURL;
+
+namespace net {
+class URLRequestContextGetter;
+} // namespace net
+
+namespace syncer {
+
+// An implementation of AttachmentUploader.
+class SYNC_EXPORT AttachmentUploaderImpl : public AttachmentUploader,
+ public base::NonThreadSafe {
+ public:
+ // |url_prefix| is the URL prefix (including trailing slash) to be used when
+ // |uploading attachments.
+ AttachmentUploaderImpl(const std::string& url_prefix,
+ const scoped_refptr<net::URLRequestContextGetter>&
+ url_request_context_getter);
+ virtual ~AttachmentUploaderImpl();
+
+ // AttachmentUploader implementation.
+ virtual void UploadAttachment(const Attachment& attachment,
+ const UploadCallback& callback) OVERRIDE;
+
+ private:
+ class UploadState;
+ typedef std::string UniqueId;
+ typedef base::ScopedPtrHashMap<UniqueId, UploadState> StateMap;
+
+ GURL GetUploadURLForAttachmentId(const AttachmentId& attachment_id) const;
+ void DeleteUploadStateFor(const UniqueId& unique_id);
+
+ std::string url_prefix_;
+ scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
+ StateMap state_map_;
+ DISALLOW_COPY_AND_ASSIGN(AttachmentUploaderImpl);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
« no previous file with comments | « sync/internal_api/attachments/fake_attachment_uploader.cc ('k') | sync/sync_internal_api.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698