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

Side by Side Diff: chrome/browser/safe_browsing/two_phase_uploader.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/safe_browsing/two_phase_uploader.h" 5 #include "chrome/browser/safe_browsing/two_phase_uploader.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/task_runner.h" 9 #include "base/task_runner.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 DCHECK(CalledOnValidThread()); 153 DCHECK(CalledOnValidThread());
154 DVLOG(3) << __FUNCTION__ << " " << source->GetURL().spec() 154 DVLOG(3) << __FUNCTION__ << " " << source->GetURL().spec()
155 << " " << current << "/" << total; 155 << " " << current << "/" << total;
156 if (state_ == UPLOAD_FILE && !progress_callback_.is_null()) 156 if (state_ == UPLOAD_FILE && !progress_callback_.is_null())
157 progress_callback_.Run(current, total); 157 progress_callback_.Run(current, total);
158 } 158 }
159 159
160 void TwoPhaseUploaderImpl::UploadMetadata() { 160 void TwoPhaseUploaderImpl::UploadMetadata() {
161 DCHECK(CalledOnValidThread()); 161 DCHECK(CalledOnValidThread());
162 state_ = UPLOAD_METADATA; 162 state_ = UPLOAD_METADATA;
163 url_fetcher_.reset(net::URLFetcher::Create(base_url_, net::URLFetcher::POST, 163 url_fetcher_ =
164 this)); 164 net::URLFetcher::Create(base_url_, net::URLFetcher::POST, this);
165 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); 165 url_fetcher_->SetRequestContext(url_request_context_getter_.get());
166 url_fetcher_->SetExtraRequestHeaders(kStartHeader); 166 url_fetcher_->SetExtraRequestHeaders(kStartHeader);
167 url_fetcher_->SetUploadData(kUploadContentType, metadata_); 167 url_fetcher_->SetUploadData(kUploadContentType, metadata_);
168 url_fetcher_->Start(); 168 url_fetcher_->Start();
169 } 169 }
170 170
171 void TwoPhaseUploaderImpl::UploadFile() { 171 void TwoPhaseUploaderImpl::UploadFile() {
172 DCHECK(CalledOnValidThread()); 172 DCHECK(CalledOnValidThread());
173 state_ = UPLOAD_FILE; 173 state_ = UPLOAD_FILE;
174 174
175 url_fetcher_.reset(net::URLFetcher::Create(upload_url_, net::URLFetcher::PUT, 175 url_fetcher_ =
176 this)); 176 net::URLFetcher::Create(upload_url_, net::URLFetcher::PUT, this);
177 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); 177 url_fetcher_->SetRequestContext(url_request_context_getter_.get());
178 url_fetcher_->SetUploadFilePath( 178 url_fetcher_->SetUploadFilePath(
179 kUploadContentType, file_path_, 0, kuint64max, file_task_runner_); 179 kUploadContentType, file_path_, 0, kuint64max, file_task_runner_);
180 url_fetcher_->Start(); 180 url_fetcher_->Start();
181 } 181 }
182 182
183 void TwoPhaseUploaderImpl::Finish(int net_error, 183 void TwoPhaseUploaderImpl::Finish(int net_error,
184 int response_code, 184 int response_code,
185 const std::string& response) { 185 const std::string& response) {
186 DCHECK(CalledOnValidThread()); 186 DCHECK(CalledOnValidThread());
(...skipping 15 matching lines...) Expand all
202 const ProgressCallback& progress_callback, 202 const ProgressCallback& progress_callback,
203 const FinishCallback& finish_callback) { 203 const FinishCallback& finish_callback) {
204 if (!TwoPhaseUploader::factory_) 204 if (!TwoPhaseUploader::factory_)
205 return new TwoPhaseUploaderImpl( 205 return new TwoPhaseUploaderImpl(
206 url_request_context_getter, file_task_runner, base_url, metadata, 206 url_request_context_getter, file_task_runner, base_url, metadata,
207 file_path, progress_callback, finish_callback); 207 file_path, progress_callback, finish_callback);
208 return TwoPhaseUploader::factory_->CreateTwoPhaseUploader( 208 return TwoPhaseUploader::factory_->CreateTwoPhaseUploader(
209 url_request_context_getter, file_task_runner, base_url, metadata, 209 url_request_context_getter, file_task_runner, base_url, metadata,
210 file_path, progress_callback, finish_callback); 210 file_path, progress_callback, finish_callback);
211 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_test.cc ('k') | chrome/browser/spellchecker/feedback_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698