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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 *bytes_read = 0; | 176 *bytes_read = 0; |
177 return true; | 177 return true; |
178 } | 178 } |
179 NOTREACHED(); | 179 NOTREACHED(); |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 void URLRequestSlowDownloadJob::CheckDoneStatus() { | 183 void URLRequestSlowDownloadJob::CheckDoneStatus() { |
184 if (should_finish_download_) { | 184 if (should_finish_download_) { |
185 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; | 185 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; |
186 DCHECK(NULL != buffer_); | 186 DCHECK(NULL != buffer_.get()); |
187 int bytes_written = 0; | 187 int bytes_written = 0; |
188 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written); | 188 ReadStatus status = |
| 189 FillBufferHelper(buffer_.get(), buffer_size_, &bytes_written); |
189 DCHECK_EQ(BUFFER_FILLED, status); | 190 DCHECK_EQ(BUFFER_FILLED, status); |
190 buffer_ = NULL; // Release the reference. | 191 buffer_ = NULL; // Release the reference. |
191 SetStatus(net::URLRequestStatus()); | 192 SetStatus(net::URLRequestStatus()); |
192 NotifyReadComplete(bytes_written); | 193 NotifyReadComplete(bytes_written); |
193 } else { | 194 } else { |
194 MessageLoop::current()->PostDelayedTask( | 195 MessageLoop::current()->PostDelayedTask( |
195 FROM_HERE, | 196 FROM_HERE, |
196 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, | 197 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, |
197 weak_factory_.GetWeakPtr()), | 198 weak_factory_.GetWeakPtr()), |
198 base::TimeDelta::FromMilliseconds(100)); | 199 base::TimeDelta::FromMilliseconds(100)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 235 } |
235 | 236 |
236 // ParseRawHeaders expects \0 to end each header line. | 237 // ParseRawHeaders expects \0 to end each header line. |
237 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 238 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
238 info->headers = new net::HttpResponseHeaders(raw_headers); | 239 info->headers = new net::HttpResponseHeaders(raw_headers); |
239 } | 240 } |
240 | 241 |
241 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 242 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
242 net::HttpResponseInfo info; | 243 net::HttpResponseInfo info; |
243 GetResponseInfoConst(&info); | 244 GetResponseInfoConst(&info); |
244 return info.headers && info.headers->GetMimeType(mime_type); | 245 return info.headers.get() && info.headers->GetMimeType(mime_type); |
245 } | 246 } |
246 | 247 |
247 } // namespace content | 248 } // namespace content |
OLD | NEW |