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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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
Index: sync/internal_api/public/attachments/attachment_downloader_impl.h
diff --git a/sync/internal_api/public/attachments/attachment_downloader_impl.h b/sync/internal_api/public/attachments/attachment_downloader_impl.h
deleted file mode 100644
index d4fbc97d2a458d1b03e86f4ed68da7f0c18828a5..0000000000000000000000000000000000000000
--- a/sync/internal_api/public/attachments/attachment_downloader_impl.h
+++ /dev/null
@@ -1,133 +0,0 @@
-// 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_DOWNLOADER_IMPL_H_
-#define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_
-
-#include <stdint.h>
-
-#include <string>
-#include <unordered_map>
-#include <vector>
-
-#include "base/gtest_prod_util.h"
-#include "base/macros.h"
-#include "base/threading/non_thread_safe.h"
-#include "google_apis/gaia/oauth2_token_service_request.h"
-#include "net/url_request/url_fetcher_delegate.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "sync/internal_api/public/attachments/attachment_downloader.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "url/gurl.h"
-
-namespace base {
-class RefCountedMemory;
-} // namespace base
-
-namespace net {
-class HttpResponseHeaders;
-} // namespace net
-
-namespace syncer {
-
-// An implementation of AttachmentDownloader.
-class AttachmentDownloaderImpl : public AttachmentDownloader,
- public OAuth2TokenService::Consumer,
- public net::URLFetcherDelegate,
- public base::NonThreadSafe {
- public:
- // |sync_service_url| is the URL of the sync service.
- //
- // |url_request_context_getter| provides a URLRequestContext.
- //
- // |account_id| is the account id to use for downloads.
- //
- // |scopes| is the set of scopes to use for downloads.
- //
- // |token_service_provider| provides an OAuth2 token service.
- //
- // |store_birthday| is the raw, sync store birthday.
- //
- // |model_type| is the model type this downloader is used with.
- AttachmentDownloaderImpl(
- const GURL& sync_service_url,
- const scoped_refptr<net::URLRequestContextGetter>&
- url_request_context_getter,
- const std::string& account_id,
- const OAuth2TokenService::ScopeSet& scopes,
- const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>&
- token_service_provider,
- const std::string& store_birthday,
- ModelType model_type);
- ~AttachmentDownloaderImpl() override;
-
- // AttachmentDownloader implementation.
- void DownloadAttachment(const AttachmentId& attachment_id,
- const DownloadCallback& callback) override;
-
- // OAuth2TokenService::Consumer implementation.
- 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.
- void OnURLFetchComplete(const net::URLFetcher* source) override;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest,
- ExtractCrc32c_NoHeaders);
- FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_First);
- FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_TooLong);
- FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_None);
- FRIEND_TEST_ALL_PREFIXES(AttachmentDownloaderImplTest, ExtractCrc32c_Empty);
-
- struct DownloadState;
- typedef std::string AttachmentUrl;
- typedef std::unordered_map<AttachmentUrl, std::unique_ptr<DownloadState>>
- StateMap;
- typedef std::vector<DownloadState*> StateList;
-
- std::unique_ptr<net::URLFetcher> CreateFetcher(
- const AttachmentUrl& url,
- const std::string& access_token);
- void RequestAccessToken(DownloadState* download_state);
- void ReportResult(
- const DownloadState& download_state,
- const DownloadResult& result,
- const scoped_refptr<base::RefCountedString>& attachment_data);
-
- // Extract the crc32c from an X-Goog-Hash header in |headers|.
- //
- // Return true if a crc32c was found and useable for checking data integrity.
- // "Usable" means headers are present, there is "x-goog-hash" header with
- // "crc32c" hash in it, this hash is correctly base64 encoded 32 bit integer.
- SYNC_EXPORT static bool ExtractCrc32c(const net::HttpResponseHeaders* headers,
- uint32_t* crc32c);
-
- GURL sync_service_url_;
- scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
-
- std::string account_id_;
- OAuth2TokenService::ScopeSet oauth2_scopes_;
- scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>
- token_service_provider_;
- std::unique_ptr<OAuth2TokenService::Request> access_token_request_;
- std::string raw_store_birthday_;
-
- StateMap state_map_;
- // |requests_waiting_for_access_token_| only keeps references to DownloadState
- // objects while access token request is pending. It doesn't control objects'
- // lifetime.
- StateList requests_waiting_for_access_token_;
-
- ModelType model_type_;
-
- DISALLOW_COPY_AND_ASSIGN(AttachmentDownloaderImpl);
-};
-
-} // namespace syncer
-
-#endif // SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_ATTACHMENT_DOWNLOADER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698