| 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_DOWNLOADER_IMPL_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_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 "google_apis/gaia/oauth2_token_service_request.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // | 35 // |
| 36 // |token_service_provider| provides an OAuth2 token service. | 36 // |token_service_provider| provides an OAuth2 token service. |
| 37 AttachmentDownloaderImpl( | 37 AttachmentDownloaderImpl( |
| 38 const GURL& sync_service_url, | 38 const GURL& sync_service_url, |
| 39 const scoped_refptr<net::URLRequestContextGetter>& | 39 const scoped_refptr<net::URLRequestContextGetter>& |
| 40 url_request_context_getter, | 40 url_request_context_getter, |
| 41 const std::string& account_id, | 41 const std::string& account_id, |
| 42 const OAuth2TokenService::ScopeSet& scopes, | 42 const OAuth2TokenService::ScopeSet& scopes, |
| 43 const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& | 43 const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& |
| 44 token_service_provider); | 44 token_service_provider); |
| 45 virtual ~AttachmentDownloaderImpl(); | 45 ~AttachmentDownloaderImpl() override; |
| 46 | 46 |
| 47 // AttachmentDownloader implementation. | 47 // AttachmentDownloader implementation. |
| 48 virtual void DownloadAttachment(const AttachmentId& attachment_id, | 48 void DownloadAttachment(const AttachmentId& attachment_id, |
| 49 const DownloadCallback& callback) override; | 49 const DownloadCallback& callback) override; |
| 50 | 50 |
| 51 // OAuth2TokenService::Consumer implementation. | 51 // OAuth2TokenService::Consumer implementation. |
| 52 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 52 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 53 const std::string& access_token, | 53 const std::string& access_token, |
| 54 const base::Time& expiration_time) override; | 54 const base::Time& expiration_time) override; |
| 55 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 55 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 56 const GoogleServiceAuthError& error) override; | 56 const GoogleServiceAuthError& error) override; |
| 57 | 57 |
| 58 // net::URLFetcherDelegate implementation. | 58 // net::URLFetcherDelegate implementation. |
| 59 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 59 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_First); | 62 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_First); |
| 63 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_None); | 63 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_None); |
| 64 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_Empty); | 64 FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_Empty); |
| 65 | 65 |
| 66 struct DownloadState; | 66 struct DownloadState; |
| 67 typedef std::string AttachmentUrl; | 67 typedef std::string AttachmentUrl; |
| 68 typedef base::ScopedPtrHashMap<AttachmentUrl, DownloadState> StateMap; | 68 typedef base::ScopedPtrHashMap<AttachmentUrl, DownloadState> StateMap; |
| 69 typedef std::vector<DownloadState*> StateList; | 69 typedef std::vector<DownloadState*> StateList; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // objects while access token request is pending. It doesn't control objects' | 106 // objects while access token request is pending. It doesn't control objects' |
| 107 // lifetime. | 107 // lifetime. |
| 108 StateList requests_waiting_for_access_token_; | 108 StateList requests_waiting_for_access_token_; |
| 109 | 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(AttachmentDownloaderImpl); | 110 DISALLOW_COPY_AND_ASSIGN(AttachmentDownloaderImpl); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 } // namespace syncer | 113 } // namespace syncer |
| 114 | 114 |
| 115 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_ | 115 #endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_ |
| OLD | NEW |