| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 buffer_ = NULL; // Release the reference. | 187 buffer_ = NULL; // Release the reference. |
| 188 SetStatus(net::URLRequestStatus()); | 188 SetStatus(net::URLRequestStatus()); |
| 189 // Release reference |
| 190 buffer_ = NULL; |
| 189 NotifyReadComplete(bytes_written); | 191 NotifyReadComplete(bytes_written); |
| 190 } else { | 192 } else { |
| 191 MessageLoop::current()->PostDelayedTask( | 193 MessageLoop::current()->PostDelayedTask( |
| 192 FROM_HERE, | 194 FROM_HERE, |
| 193 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, | 195 base::Bind(&URLRequestSlowDownloadJob::CheckDoneStatus, |
| 194 weak_factory_.GetWeakPtr()), | 196 weak_factory_.GetWeakPtr()), |
| 195 base::TimeDelta::FromMilliseconds(100)); | 197 base::TimeDelta::FromMilliseconds(100)); |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 | 200 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // ParseRawHeaders expects \0 to end each header line. | 235 // ParseRawHeaders expects \0 to end each header line. |
| 234 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 236 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 235 info->headers = new net::HttpResponseHeaders(raw_headers); | 237 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 236 } | 238 } |
| 237 | 239 |
| 238 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 240 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 239 net::HttpResponseInfo info; | 241 net::HttpResponseInfo info; |
| 240 GetResponseInfoConst(&info); | 242 GetResponseInfoConst(&info); |
| 241 return info.headers && info.headers->GetMimeType(mime_type); | 243 return info.headers && info.headers->GetMimeType(mime_type); |
| 242 } | 244 } |
| OLD | NEW |