OLD | NEW |
---|---|
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/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 ~AttachmentUploaderImpl() override; | 44 ~AttachmentUploaderImpl() override; |
45 | 45 |
46 // AttachmentUploader implementation. | 46 // AttachmentUploader implementation. |
47 void UploadAttachment(const Attachment& attachment, | 47 void UploadAttachment(const Attachment& attachment, |
48 const UploadCallback& callback) override; | 48 const UploadCallback& callback) override; |
49 | 49 |
50 // Return the URL for the given |sync_service_url| and |attachment_id|. | 50 // Return the URL for the given |sync_service_url| and |attachment_id|. |
51 static GURL GetURLForAttachmentId(const GURL& sync_service_url, | 51 static GURL GetURLForAttachmentId(const GURL& sync_service_url, |
52 const AttachmentId& attachment_id); | 52 const AttachmentId& attachment_id); |
53 | 53 |
54 // Return the crc32c of the memory described by |data| and |size|. | 54 // Format crc32c to pass into X-Goog-Hash header |
maniscalco
2014/11/11 00:44:54
nit: needs a period at the end.
pavely
2014/11/11 22:27:15
Done.
| |
55 // | 55 // |
56 // The value is base64 encoded, big-endian format. Suitable for use in the | 56 // The value is base64 encoded, big-endian format. Suitable for use in the |
57 // X-Goog-Hash header | 57 // X-Goog-Hash header |
58 // (https://cloud.google.com/storage/docs/reference-headers#xgooghash). | 58 // (https://cloud.google.com/storage/docs/reference-headers#xgooghash). |
59 // | 59 static std::string FormatCrc32cHash(uint32_t crc); |
60 // Potentially expensive. | |
61 static std::string ComputeCrc32cHash(const char* data, size_t size); | |
62 | 60 |
63 private: | 61 private: |
64 class UploadState; | 62 class UploadState; |
65 typedef std::string UniqueId; | 63 typedef std::string UniqueId; |
66 typedef base::ScopedPtrHashMap<UniqueId, UploadState> StateMap; | 64 typedef base::ScopedPtrHashMap<UniqueId, UploadState> StateMap; |
67 | 65 |
68 void OnUploadStateStopped(const UniqueId& unique_id); | 66 void OnUploadStateStopped(const UniqueId& unique_id); |
69 | 67 |
70 GURL sync_service_url_; | 68 GURL sync_service_url_; |
71 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 69 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
72 std::string account_id_; | 70 std::string account_id_; |
73 OAuth2TokenService::ScopeSet scopes_; | 71 OAuth2TokenService::ScopeSet scopes_; |
74 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> | 72 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
75 token_service_provider_; | 73 token_service_provider_; |
76 StateMap state_map_; | 74 StateMap state_map_; |
77 | 75 |
78 // Must be last data member. | 76 // Must be last data member. |
79 base::WeakPtrFactory<AttachmentUploaderImpl> weak_ptr_factory_; | 77 base::WeakPtrFactory<AttachmentUploaderImpl> weak_ptr_factory_; |
80 | 78 |
81 DISALLOW_COPY_AND_ASSIGN(AttachmentUploaderImpl); | 79 DISALLOW_COPY_AND_ASSIGN(AttachmentUploaderImpl); |
82 }; | 80 }; |
83 | 81 |
84 } // namespace syncer | 82 } // namespace syncer |
85 | 83 |
86 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_ | 84 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_UPLOADER_IMPL_H_ |
OLD | NEW |