Chromium Code Reviews| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 } | 178 } |
| 179 | 179 |
| 180 void URLRequestSlowDownloadJob::CheckDoneStatus() { | 180 void URLRequestSlowDownloadJob::CheckDoneStatus() { |
| 181 if (should_finish_download_) { | 181 if (should_finish_download_) { |
| 182 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; | 182 VLOG(10) << __FUNCTION__ << " called w/ should_finish_download_ set."; |
| 183 DCHECK(NULL != buffer_); | 183 DCHECK(NULL != buffer_); |
| 184 int bytes_written = 0; | 184 int bytes_written = 0; |
| 185 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written); | 185 ReadStatus status = FillBufferHelper(buffer_, buffer_size_, &bytes_written); |
| 186 DCHECK_EQ(BUFFER_FILLED, status); | 186 DCHECK_EQ(BUFFER_FILLED, status); |
| 187 SetStatus(net::URLRequestStatus()); | 187 SetStatus(net::URLRequestStatus()); |
| 188 // Release reference | |
|
ahendrickson
2012/04/16 15:14:27
Is this related to this CL?
Randy Smith (Not in Mondays)
2012/04/18 19:10:38
Sorta-not-really. It's an already existing proble
| |
| 189 buffer_ = NULL; | |
| 188 NotifyReadComplete(bytes_written); | 190 NotifyReadComplete(bytes_written); |
| 189 } else { | 191 } else { |
| 190 MessageLoop::current()->PostDelayedTask( | 192 MessageLoop::current()->PostDelayedTask( |
| 191 FROM_HERE, | 193 FROM_HERE, |
| 192 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, | 194 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, |
| 193 weak_factory_.GetWeakPtr()), | 195 weak_factory_.GetWeakPtr()), |
| 194 base::TimeDelta::FromMilliseconds(100)); | 196 base::TimeDelta::FromMilliseconds(100)); |
| 195 } | 197 } |
| 196 } | 198 } |
| 197 | 199 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 // ParseRawHeaders expects \0 to end each header line. | 234 // ParseRawHeaders expects \0 to end each header line. |
| 233 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 235 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 234 info->headers = new net::HttpResponseHeaders(raw_headers); | 236 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 235 } | 237 } |
| 236 | 238 |
| 237 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 239 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 238 net::HttpResponseInfo info; | 240 net::HttpResponseInfo info; |
| 239 GetResponseInfoConst(&info); | 241 GetResponseInfoConst(&info); |
| 240 return info.headers && info.headers->GetMimeType(mime_type); | 242 return info.headers && info.headers->GetMimeType(mime_type); |
| 241 } | 243 } |
| OLD | NEW |