OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/test/net/url_request_slow_download_job.h" | 5 #include "content/test/net/url_request_slow_download_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 *bytes_read = 0; | 196 *bytes_read = 0; |
197 return true; | 197 return true; |
198 } | 198 } |
199 NOTREACHED(); | 199 NOTREACHED(); |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 void URLRequestSlowDownloadJob::CheckDoneStatus() { | 203 void URLRequestSlowDownloadJob::CheckDoneStatus() { |
204 if (should_finish_download_) { | 204 if (should_finish_download_) { |
205 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; | 205 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; |
206 DCHECK(NULL != buffer_); | 206 DCHECK(NULL != buffer_.get()); |
207 int bytes_written = 0; | 207 int bytes_written = 0; |
208 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written); | 208 ReadStatus status = |
| 209 FillBufferHelper(buffer_.get(), buffer_size_, &bytes_written); |
209 DCHECK_EQ(BUFFER_FILLED, status); | 210 DCHECK_EQ(BUFFER_FILLED, status); |
210 buffer_ = NULL; // Release the reference. | 211 buffer_ = NULL; // Release the reference. |
211 SetStatus(net::URLRequestStatus()); | 212 SetStatus(net::URLRequestStatus()); |
212 NotifyReadComplete(bytes_written); | 213 NotifyReadComplete(bytes_written); |
213 } else if (should_error_download_) { | 214 } else if (should_error_download_) { |
214 VLOG(10) << __FUNCTION__ << " called w/ should_finish_ownload_ set."; | 215 VLOG(10) << __FUNCTION__ << " called w/ should_finish_ownload_ set."; |
215 NotifyDone(net::URLRequestStatus( | 216 NotifyDone(net::URLRequestStatus( |
216 net::URLRequestStatus::FAILED, net::ERR_CONNECTION_RESET)); | 217 net::URLRequestStatus::FAILED, net::ERR_CONNECTION_RESET)); |
217 } else { | 218 } else { |
218 base::MessageLoop::current()->PostDelayedTask( | 219 base::MessageLoop::current()->PostDelayedTask( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 261 } |
261 | 262 |
262 // ParseRawHeaders expects \0 to end each header line. | 263 // ParseRawHeaders expects \0 to end each header line. |
263 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 264 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
264 info->headers = new net::HttpResponseHeaders(raw_headers); | 265 info->headers = new net::HttpResponseHeaders(raw_headers); |
265 } | 266 } |
266 | 267 |
267 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 268 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
268 net::HttpResponseInfo info; | 269 net::HttpResponseInfo info; |
269 GetResponseInfoConst(&info); | 270 GetResponseInfoConst(&info); |
270 return info.headers && info.headers->GetMimeType(mime_type); | 271 return info.headers.get() && info.headers->GetMimeType(mime_type); |
271 } | 272 } |
272 | 273 |
273 } // namespace content | 274 } // namespace content |
OLD | NEW |