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

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

Issue 1117703002: Adjust URLFetcher::Create API so that object is returned as scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded Pass() calls Created 5 years, 7 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_uploader_impl.h" 5 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 const std::string& access_token, 203 const std::string& access_token,
204 const base::Time& expiration_time) { 204 const base::Time& expiration_time) {
205 DCHECK(CalledOnValidThread()); 205 DCHECK(CalledOnValidThread());
206 if (is_stopped_) { 206 if (is_stopped_) {
207 return; 207 return;
208 } 208 }
209 209
210 DCHECK_EQ(access_token_request_.get(), request); 210 DCHECK_EQ(access_token_request_.get(), request);
211 access_token_request_.reset(); 211 access_token_request_.reset();
212 access_token_ = access_token; 212 access_token_ = access_token;
213 fetcher_.reset( 213 fetcher_ = net::URLFetcher::Create(upload_url_, net::URLFetcher::POST, this);
214 net::URLFetcher::Create(upload_url_, net::URLFetcher::POST, this));
215 ConfigureURLFetcherCommon(fetcher_.get(), access_token_, raw_store_birthday_, 214 ConfigureURLFetcherCommon(fetcher_.get(), access_token_, raw_store_birthday_,
216 model_type_, url_request_context_getter_.get()); 215 model_type_, url_request_context_getter_.get());
217 216
218 const uint32_t crc32c = attachment_.GetCrc32c(); 217 const uint32_t crc32c = attachment_.GetCrc32c();
219 fetcher_->AddExtraRequestHeader(base::StringPrintf( 218 fetcher_->AddExtraRequestHeader(base::StringPrintf(
220 "X-Goog-Hash: crc32c=%s", FormatCrc32cHash(crc32c).c_str())); 219 "X-Goog-Hash: crc32c=%s", FormatCrc32cHash(crc32c).c_str()));
221 220
222 // TODO(maniscalco): Is there a better way? Copying the attachment data into 221 // TODO(maniscalco): Is there a better way? Copying the attachment data into
223 // a string feels wrong given how large attachments may be (several MBs). If 222 // a string feels wrong given how large attachments may be (several MBs). If
224 // we may end up switching from URLFetcher to URLRequest, this copy won't be 223 // we may end up switching from URLFetcher to URLRequest, this copy won't be
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 394
396 void AttachmentUploaderImpl::Base64URLSafeEncode(const std::string& input, 395 void AttachmentUploaderImpl::Base64URLSafeEncode(const std::string& input,
397 std::string* output) { 396 std::string* output) {
398 base::Base64Encode(input, output); 397 base::Base64Encode(input, output);
399 base::ReplaceChars(*output, "+", "-", output); 398 base::ReplaceChars(*output, "+", "-", output);
400 base::ReplaceChars(*output, "/", "_", output); 399 base::ReplaceChars(*output, "/", "_", output);
401 base::TrimString(*output, "=", output); 400 base::TrimString(*output, "=", output);
402 } 401 }
403 402
404 } // namespace syncer 403 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/attachment_downloader_impl.cc ('k') | sync/internal_api/http_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698