OLD | NEW |
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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 DCHECK_EQ(STATE_NONE, state_); | 98 DCHECK_EQ(STATE_NONE, state_); |
99 | 99 |
100 UploadMetadata(); | 100 UploadMetadata(); |
101 } | 101 } |
102 | 102 |
103 void TwoPhaseUploaderImpl::OnURLFetchComplete(const net::URLFetcher* source) { | 103 void TwoPhaseUploaderImpl::OnURLFetchComplete(const net::URLFetcher* source) { |
104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
105 net::URLRequestStatus status = source->GetStatus(); | 105 net::URLRequestStatus status = source->GetStatus(); |
106 int response_code = source->GetResponseCode(); | 106 int response_code = source->GetResponseCode(); |
107 | 107 |
108 DVLOG(1) << __FUNCTION__ << " " << source->GetURL().spec() | 108 DVLOG(1) << __func__ << " " << source->GetURL().spec() << " " |
109 << " " << status.status() << " " << response_code; | 109 << status.status() << " " << response_code; |
110 | 110 |
111 if (!status.is_success()) { | 111 if (!status.is_success()) { |
112 LOG(ERROR) << "URLFetcher failed, status=" << status.status() | 112 LOG(ERROR) << "URLFetcher failed, status=" << status.status() |
113 << " err=" << status.error(); | 113 << " err=" << status.error(); |
114 Finish(status.error(), response_code, std::string()); | 114 Finish(status.error(), response_code, std::string()); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 std::string response; | 118 std::string response; |
119 source->GetResponseAsString(&response); | 119 source->GetResponseAsString(&response); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 default: | 151 default: |
152 NOTREACHED(); | 152 NOTREACHED(); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void TwoPhaseUploaderImpl::OnURLFetchUploadProgress( | 156 void TwoPhaseUploaderImpl::OnURLFetchUploadProgress( |
157 const net::URLFetcher* source, | 157 const net::URLFetcher* source, |
158 int64_t current, | 158 int64_t current, |
159 int64_t total) { | 159 int64_t total) { |
160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
161 DVLOG(3) << __FUNCTION__ << " " << source->GetURL().spec() | 161 DVLOG(3) << __func__ << " " << source->GetURL().spec() << " " << current |
162 << " " << current << "/" << total; | 162 << "/" << total; |
163 if (state_ == UPLOAD_FILE && !progress_callback_.is_null()) | 163 if (state_ == UPLOAD_FILE && !progress_callback_.is_null()) |
164 progress_callback_.Run(current, total); | 164 progress_callback_.Run(current, total); |
165 } | 165 } |
166 | 166 |
167 void TwoPhaseUploaderImpl::UploadMetadata() { | 167 void TwoPhaseUploaderImpl::UploadMetadata() { |
168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
169 state_ = UPLOAD_METADATA; | 169 state_ = UPLOAD_METADATA; |
170 url_fetcher_ = | 170 url_fetcher_ = |
171 net::URLFetcher::Create(base_url_, net::URLFetcher::POST, this); | 171 net::URLFetcher::Create(base_url_, net::URLFetcher::POST, this); |
172 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); | 172 url_fetcher_->SetRequestContext(url_request_context_getter_.get()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 const FinishCallback& finish_callback) { | 211 const FinishCallback& finish_callback) { |
212 if (!factory_) { | 212 if (!factory_) { |
213 return base::WrapUnique(new TwoPhaseUploaderImpl( | 213 return base::WrapUnique(new TwoPhaseUploaderImpl( |
214 url_request_context_getter, file_task_runner, base_url, metadata, | 214 url_request_context_getter, file_task_runner, base_url, metadata, |
215 file_path, progress_callback, finish_callback)); | 215 file_path, progress_callback, finish_callback)); |
216 } | 216 } |
217 return TwoPhaseUploader::factory_->CreateTwoPhaseUploader( | 217 return TwoPhaseUploader::factory_->CreateTwoPhaseUploader( |
218 url_request_context_getter, file_task_runner, base_url, metadata, | 218 url_request_context_getter, file_task_runner, base_url, metadata, |
219 file_path, progress_callback, finish_callback); | 219 file_path, progress_callback, finish_callback); |
220 } | 220 } |
OLD | NEW |