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

Side by Side Diff: sync/internal_api/public/attachments/attachment_uploader_impl.h

Issue 304253010: Add authentication support to AttachmentUploaderImpl. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
7 7
8 #include "base/containers/scoped_ptr_hash_map.h" 8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/threading/non_thread_safe.h" 9 #include "base/threading/non_thread_safe.h"
10 #include "google_apis/gaia/oauth2_token_service_request.h"
10 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
11 #include "sync/api/attachments/attachment_uploader.h" 12 #include "sync/api/attachments/attachment_uploader.h"
12 13
13 class GURL; 14 class GURL;
14 15
15 namespace net { 16 namespace net {
16 class URLRequestContextGetter; 17 class URLRequestContextGetter;
17 } // namespace net 18 } // namespace net
18 19
19 namespace syncer { 20 namespace syncer {
20 21
21 // An implementation of AttachmentUploader. 22 // An implementation of AttachmentUploader.
22 class SYNC_EXPORT AttachmentUploaderImpl : public AttachmentUploader, 23 class SYNC_EXPORT AttachmentUploaderImpl : public AttachmentUploader,
23 public base::NonThreadSafe { 24 public base::NonThreadSafe {
24 public: 25 public:
25 // |url_prefix| is the URL prefix (including trailing slash) to be used when 26 // |url_prefix| is the URL prefix (including trailing slash) to be used when
26 // |uploading attachments. 27 // uploading attachments.
27 AttachmentUploaderImpl(const std::string& url_prefix, 28 //
28 const scoped_refptr<net::URLRequestContextGetter>& 29 // |url_request_context_getter| provides a URLRequestContext.
29 url_request_context_getter); 30 //
31 // |account_id| is the account id to use for uploads.
32 //
33 // |token_service_provider| provides an OAuth2 token service.
34 AttachmentUploaderImpl(
35 const std::string& url_prefix,
36 const scoped_refptr<net::URLRequestContextGetter>&
37 url_request_context_getter,
38 const std::string& account_id,
39 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider>
40 token_service_provider);
30 virtual ~AttachmentUploaderImpl(); 41 virtual ~AttachmentUploaderImpl();
31 42
32 // AttachmentUploader implementation. 43 // AttachmentUploader implementation.
33 virtual void UploadAttachment(const Attachment& attachment, 44 virtual void UploadAttachment(const Attachment& attachment,
34 const UploadCallback& callback) OVERRIDE; 45 const UploadCallback& callback) OVERRIDE;
35 46
36 private: 47 private:
37 class UploadState; 48 class UploadState;
38 typedef std::string UniqueId; 49 typedef std::string UniqueId;
39 typedef base::ScopedPtrHashMap<UniqueId, UploadState> StateMap; 50 typedef base::ScopedPtrHashMap<UniqueId, UploadState> StateMap;
40 51
41 GURL GetUploadURLForAttachmentId(const AttachmentId& attachment_id) const; 52 GURL GetUploadURLForAttachmentId(const AttachmentId& attachment_id) const;
42 void DeleteUploadStateFor(const UniqueId& unique_id); 53 void DeleteUploadStateFor(const UniqueId& unique_id);
43 54
44 std::string url_prefix_; 55 std::string url_prefix_;
45 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 56 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
57 std::string account_id_;
58 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider>
59 token_service_provider_;
46 StateMap state_map_; 60 StateMap state_map_;
47 DISALLOW_COPY_AND_ASSIGN(AttachmentUploaderImpl); 61 DISALLOW_COPY_AND_ASSIGN(AttachmentUploaderImpl);
48 }; 62 };
49 63
50 } // namespace syncer 64 } // namespace syncer
51 65
52 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_ 66 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698