X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fsync%2Finternal_api%2Fpublic%2Fattachments%2Fattachment_downloader_impl.h;h=363d805a9d226b94994fbd797076272ca0557255;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=8b62ec34dc1604255279e8175057d933bd58e775;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/sync/internal_api/public/attachments/attachment_downloader_impl.h b/src/sync/internal_api/public/attachments/attachment_downloader_impl.h index 8b62ec3..363d805 100644 --- a/src/sync/internal_api/public/attachments/attachment_downloader_impl.h +++ b/src/sync/internal_api/public/attachments/attachment_downloader_impl.h @@ -13,6 +13,10 @@ #include "sync/internal_api/public/attachments/attachment_downloader.h" #include "url/gurl.h" +namespace net { +class HttpResponseHeaders; +} // namespace net + namespace syncer { // An implementation of AttachmentDownloader. @@ -38,23 +42,27 @@ class AttachmentDownloaderImpl : public AttachmentDownloader, const OAuth2TokenService::ScopeSet& scopes, const scoped_refptr& token_service_provider); - virtual ~AttachmentDownloaderImpl(); + ~AttachmentDownloaderImpl() override; // AttachmentDownloader implementation. - virtual void DownloadAttachment(const AttachmentId& attachment_id, - const DownloadCallback& callback) OVERRIDE; + void DownloadAttachment(const AttachmentId& attachment_id, + const DownloadCallback& callback) override; // OAuth2TokenService::Consumer implementation. - virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, - const std::string& access_token, - const base::Time& expiration_time) OVERRIDE; - virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, - const GoogleServiceAuthError& error) OVERRIDE; + void OnGetTokenSuccess(const OAuth2TokenService::Request* request, + const std::string& access_token, + const base::Time& expiration_time) override; + void OnGetTokenFailure(const OAuth2TokenService::Request* request, + const GoogleServiceAuthError& error) override; // net::URLFetcherDelegate implementation. - virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; + void OnURLFetchComplete(const net::URLFetcher* source) override; private: + FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_First); + FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_None); + FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_Empty); + struct DownloadState; typedef std::string AttachmentUrl; typedef base::ScopedPtrHashMap StateMap; @@ -68,6 +76,22 @@ class AttachmentDownloaderImpl : public AttachmentDownloader, const DownloadResult& result, const scoped_refptr& attachment_data); + // Verify the integrity of |data| using the hash received in |fetcher|. + // + // Assumes that the request in |fetcher| has completed. + // + // Returns true if the hash of |data| matches the hash contained in |fetcher| + // or if |fetcher| contains no hash (no hash, no problem). + static bool VerifyHashIfPresent(const net::URLFetcher& fetcher, + const std::string& data); + + // Extract the crc32c from an X-Goog-Hash header in |headers|. + // + // Return true if a crc32c was found and set |crc32c|. + SYNC_EXPORT_PRIVATE static bool ExtractCrc32c( + const net::HttpResponseHeaders& headers, + std::string* crc32c); + GURL sync_service_url_; scoped_refptr url_request_context_getter_;