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

Side by Side Diff: sync/internal_api/attachments/attachment_downloader_impl.cc

Issue 1539843002: Convert Pass()→std::move() in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up Created 4 years, 12 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 unified diff | Download patch
OLDNEW
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 #include "sync/internal_api/public/attachments/attachment_downloader_impl.h" 5 #include "sync/internal_api/public/attachments/attachment_downloader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility>
8 9
9 #include "base/base64.h" 10 #include "base/base64.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
14 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.h"
15 #include "base/sys_byteorder.h" 16 #include "base/sys_byteorder.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 AttachmentUrl url = AttachmentUploaderImpl::GetURLForAttachmentId( 85 AttachmentUrl url = AttachmentUploaderImpl::GetURLForAttachmentId(
85 sync_service_url_, attachment_id).spec(); 86 sync_service_url_, attachment_id).spec();
86 87
87 StateMap::iterator iter = state_map_.find(url); 88 StateMap::iterator iter = state_map_.find(url);
88 if (iter == state_map_.end()) { 89 if (iter == state_map_.end()) {
89 // There is no request started for this attachment id. Let's create 90 // There is no request started for this attachment id. Let's create
90 // DownloadState and request access token for it. 91 // DownloadState and request access token for it.
91 scoped_ptr<DownloadState> new_download_state( 92 scoped_ptr<DownloadState> new_download_state(
92 new DownloadState(attachment_id, url)); 93 new DownloadState(attachment_id, url));
93 iter = state_map_.add(url, new_download_state.Pass()).first; 94 iter = state_map_.add(url, std::move(new_download_state)).first;
94 RequestAccessToken(iter->second); 95 RequestAccessToken(iter->second);
95 } 96 }
96 DownloadState* download_state = iter->second; 97 DownloadState* download_state = iter->second;
97 DCHECK(download_state->attachment_id == attachment_id); 98 DCHECK(download_state->attachment_id == attachment_id);
98 download_state->user_callbacks.push_back(callback); 99 download_state->user_callbacks.push_back(callback);
99 } 100 }
100 101
101 void AttachmentDownloaderImpl::OnGetTokenSuccess( 102 void AttachmentDownloaderImpl::OnGetTokenSuccess(
102 const OAuth2TokenService::Request* request, 103 const OAuth2TokenService::Request* request,
103 const std::string& access_token, 104 const std::string& access_token,
104 const base::Time& expiration_time) { 105 const base::Time& expiration_time) {
105 DCHECK(CalledOnValidThread()); 106 DCHECK(CalledOnValidThread());
106 DCHECK(request == access_token_request_.get()); 107 DCHECK(request == access_token_request_.get());
107 access_token_request_.reset(); 108 access_token_request_.reset();
108 StateList::const_iterator iter; 109 StateList::const_iterator iter;
109 // Start downloads for all download requests waiting for access token. 110 // Start downloads for all download requests waiting for access token.
110 for (iter = requests_waiting_for_access_token_.begin(); 111 for (iter = requests_waiting_for_access_token_.begin();
111 iter != requests_waiting_for_access_token_.end(); 112 iter != requests_waiting_for_access_token_.end();
112 ++iter) { 113 ++iter) {
113 DownloadState* download_state = *iter; 114 DownloadState* download_state = *iter;
114 download_state->access_token = access_token; 115 download_state->access_token = access_token;
115 download_state->url_fetcher = 116 download_state->url_fetcher =
116 CreateFetcher(download_state->attachment_url, access_token).Pass(); 117 CreateFetcher(download_state->attachment_url, access_token);
117 download_state->start_time = base::TimeTicks::Now(); 118 download_state->start_time = base::TimeTicks::Now();
118 download_state->url_fetcher->Start(); 119 download_state->url_fetcher->Start();
119 } 120 }
120 requests_waiting_for_access_token_.clear(); 121 requests_waiting_for_access_token_.clear();
121 } 122 }
122 123
123 void AttachmentDownloaderImpl::OnGetTokenFailure( 124 void AttachmentDownloaderImpl::OnGetTokenFailure(
124 const OAuth2TokenService::Request* request, 125 const OAuth2TokenService::Request* request,
125 const GoogleServiceAuthError& error) { 126 const GoogleServiceAuthError& error) {
126 DCHECK(CalledOnValidThread()); 127 DCHECK(CalledOnValidThread());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 207 }
207 208
208 scoped_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher( 209 scoped_ptr<net::URLFetcher> AttachmentDownloaderImpl::CreateFetcher(
209 const AttachmentUrl& url, 210 const AttachmentUrl& url,
210 const std::string& access_token) { 211 const std::string& access_token) {
211 scoped_ptr<net::URLFetcher> url_fetcher = 212 scoped_ptr<net::URLFetcher> url_fetcher =
212 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this); 213 net::URLFetcher::Create(GURL(url), net::URLFetcher::GET, this);
213 AttachmentUploaderImpl::ConfigureURLFetcherCommon( 214 AttachmentUploaderImpl::ConfigureURLFetcherCommon(
214 url_fetcher.get(), access_token, raw_store_birthday_, model_type_, 215 url_fetcher.get(), access_token, raw_store_birthday_, model_type_,
215 url_request_context_getter_.get()); 216 url_request_context_getter_.get());
216 return url_fetcher.Pass(); 217 return url_fetcher;
217 } 218 }
218 219
219 void AttachmentDownloaderImpl::RequestAccessToken( 220 void AttachmentDownloaderImpl::RequestAccessToken(
220 DownloadState* download_state) { 221 DownloadState* download_state) {
221 requests_waiting_for_access_token_.push_back(download_state); 222 requests_waiting_for_access_token_.push_back(download_state);
222 // Start access token request if there is no active one. 223 // Start access token request if there is no active one.
223 if (access_token_request_ == NULL) { 224 if (access_token_request_ == NULL) {
224 access_token_request_ = OAuth2TokenServiceRequest::CreateAndStart( 225 access_token_request_ = OAuth2TokenServiceRequest::CreateAndStart(
225 token_service_provider_.get(), account_id_, oauth2_scopes_, this); 226 token_service_provider_.get(), account_id_, oauth2_scopes_, this);
226 } 227 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 280
280 if (crc32c_raw.size() != sizeof(*crc32c)) 281 if (crc32c_raw.size() != sizeof(*crc32c))
281 return false; 282 return false;
282 283
283 *crc32c = 284 *crc32c =
284 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str())); 285 base::NetToHost32(*reinterpret_cast<const uint32_t*>(crc32c_raw.c_str()));
285 return true; 286 return true;
286 } 287 }
287 288
288 } // namespace syncer 289 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler_impl.cc ('k') | sync/internal_api/attachments/attachment_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698