| Index: components/sync/core_impl/attachments/attachment_downloader_impl.cc
|
| diff --git a/sync/internal_api/attachments/attachment_downloader_impl.cc b/components/sync/core_impl/attachments/attachment_downloader_impl.cc
|
| similarity index 91%
|
| rename from sync/internal_api/attachments/attachment_downloader_impl.cc
|
| rename to components/sync/core_impl/attachments/attachment_downloader_impl.cc
|
| index f0443c1082c8176137176187d0395e6f21b8571b..c28e9181066a2f8be33c57a99198690f3ebf8208 100644
|
| --- a/sync/internal_api/attachments/attachment_downloader_impl.cc
|
| +++ b/components/sync/core_impl/attachments/attachment_downloader_impl.cc
|
| @@ -2,9 +2,10 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "sync/internal_api/public/attachments/attachment_downloader_impl.h"
|
| +#include "components/sync/core/attachments/attachment_downloader_impl.h"
|
|
|
| #include <stdint.h>
|
| +
|
| #include <utility>
|
|
|
| #include "base/base64.h"
|
| @@ -17,15 +18,15 @@
|
| #include "base/sys_byteorder.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "base/time/time.h"
|
| +#include "components/sync/core/attachments/attachment_uploader_impl.h"
|
| +#include "components/sync/core/attachments/attachment_util.h"
|
| +#include "components/sync/protocol/sync.pb.h"
|
| #include "net/base/load_flags.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/http/http_status_code.h"
|
| #include "net/http/http_util.h"
|
| #include "net/url_request/url_fetcher.h"
|
| #include "net/url_request/url_request_status.h"
|
| -#include "sync/internal_api/public/attachments/attachment_uploader_impl.h"
|
| -#include "sync/internal_api/public/attachments/attachment_util.h"
|
| -#include "sync/protocol/sync.pb.h"
|
| #include "url/gurl.h"
|
|
|
| namespace syncer {
|
| @@ -48,8 +49,7 @@ struct AttachmentDownloaderImpl::DownloadState {
|
| AttachmentDownloaderImpl::DownloadState::DownloadState(
|
| const AttachmentId& attachment_id,
|
| const AttachmentUrl& attachment_url)
|
| - : attachment_id(attachment_id), attachment_url(attachment_url) {
|
| -}
|
| + : attachment_id(attachment_id), attachment_url(attachment_url) {}
|
|
|
| AttachmentDownloaderImpl::AttachmentDownloaderImpl(
|
| const GURL& sync_service_url,
|
| @@ -76,8 +76,7 @@ AttachmentDownloaderImpl::AttachmentDownloaderImpl(
|
| DCHECK(!raw_store_birthday_.empty());
|
| }
|
|
|
| -AttachmentDownloaderImpl::~AttachmentDownloaderImpl() {
|
| -}
|
| +AttachmentDownloaderImpl::~AttachmentDownloaderImpl() {}
|
|
|
| void AttachmentDownloaderImpl::DownloadAttachment(
|
| const AttachmentId& attachment_id,
|
| @@ -85,7 +84,8 @@ void AttachmentDownloaderImpl::DownloadAttachment(
|
| DCHECK(CalledOnValidThread());
|
|
|
| AttachmentUrl url = AttachmentUploaderImpl::GetURLForAttachmentId(
|
| - sync_service_url_, attachment_id).spec();
|
| + sync_service_url_, attachment_id)
|
| + .spec();
|
|
|
| StateMap::iterator iter = state_map_.find(url);
|
| DownloadState* download_state =
|
| @@ -113,8 +113,7 @@ void AttachmentDownloaderImpl::OnGetTokenSuccess(
|
| StateList::const_iterator iter;
|
| // Start downloads for all download requests waiting for access token.
|
| for (iter = requests_waiting_for_access_token_.begin();
|
| - iter != requests_waiting_for_access_token_.end();
|
| - ++iter) {
|
| + iter != requests_waiting_for_access_token_.end(); ++iter) {
|
| DownloadState* download_state = *iter;
|
| download_state->access_token = access_token;
|
| download_state->url_fetcher =
|
| @@ -134,8 +133,7 @@ void AttachmentDownloaderImpl::OnGetTokenFailure(
|
| StateList::const_iterator iter;
|
| // Without access token all downloads fail.
|
| for (iter = requests_waiting_for_access_token_.begin();
|
| - iter != requests_waiting_for_access_token_.end();
|
| - ++iter) {
|
| + iter != requests_waiting_for_access_token_.end(); ++iter) {
|
| DownloadState* download_state = *iter;
|
| scoped_refptr<base::RefCountedString> null_attachment_data;
|
| ReportResult(*download_state, DOWNLOAD_TRANSIENT_ERROR,
|
| @@ -166,14 +164,16 @@ void AttachmentDownloaderImpl::OnURLFetchComplete(
|
|
|
| net::URLRequestStatus status = source->GetStatus();
|
| const int response_code = source->GetResponseCode();
|
| - UMA_HISTOGRAM_SPARSE_SLOWLY("Sync.Attachments.DownloadResponseCode",
|
| + UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| + "Sync.Attachments.DownloadResponseCode",
|
| status.is_success() ? response_code : status.error());
|
| if (response_code == net::HTTP_OK) {
|
| std::string data_as_string;
|
| source->GetResponseAsString(&data_as_string);
|
| attachment_data = base::RefCountedString::TakeString(&data_as_string);
|
|
|
| - UMA_HISTOGRAM_LONG_TIMES("Sync.Attachments.DownloadTotalTime",
|
| + UMA_HISTOGRAM_LONG_TIMES(
|
| + "Sync.Attachments.DownloadTotalTime",
|
| base::TimeTicks::Now() - download_state.start_time);
|
|
|
| attachment_crc32c = ComputeCrc32c(attachment_data);
|
| @@ -198,8 +198,7 @@ void AttachmentDownloaderImpl::OnURLFetchComplete(
|
| } else if (response_code == net::HTTP_UNAUTHORIZED) {
|
| // Server tells us we've got a bad token so invalidate it.
|
| OAuth2TokenServiceRequest::InvalidateToken(token_service_provider_.get(),
|
| - account_id_,
|
| - oauth2_scopes_,
|
| + account_id_, oauth2_scopes_,
|
| download_state.access_token);
|
| // Fail the request, but indicate that it may be successful if retried.
|
| result = DOWNLOAD_TRANSIENT_ERROR;
|
| @@ -240,8 +239,7 @@ void AttachmentDownloaderImpl::ReportResult(
|
| const scoped_refptr<base::RefCountedString>& attachment_data) {
|
| std::vector<DownloadCallback>::const_iterator iter;
|
| for (iter = download_state.user_callbacks.begin();
|
| - iter != download_state.user_callbacks.end();
|
| - ++iter) {
|
| + iter != download_state.user_callbacks.end(); ++iter) {
|
| std::unique_ptr<Attachment> attachment;
|
| if (result == DOWNLOAD_SUCCESS) {
|
| attachment.reset(new Attachment(Attachment::CreateFromParts(
|
| @@ -268,8 +266,8 @@ bool AttachmentDownloaderImpl::ExtractCrc32c(
|
| while (headers->EnumerateHeader(&iter, "x-goog-hash", &header_value)) {
|
| // Because EnumerateHeader is smart about list values, header_value will
|
| // either be empty or a single name=value pair.
|
| - net::HttpUtil::NameValuePairsIterator pair_iter(
|
| - header_value.begin(), header_value.end(), ',');
|
| + net::HttpUtil::NameValuePairsIterator pair_iter(header_value.begin(),
|
| + header_value.end(), ',');
|
| if (pair_iter.GetNext()) {
|
| if (pair_iter.name() == "crc32c") {
|
| crc32c_encoded = pair_iter.value();
|
|
|