| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/net/url_request_slow_download_job.h" | 5 #include "chrome/browser/net/url_request_slow_download_job.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 this, &URLRequestSlowDownloadJob::CheckDoneStatus), 100); | 135 this, &URLRequestSlowDownloadJob::CheckDoneStatus), 100); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Public virtual version. | 139 // Public virtual version. |
| 140 void URLRequestSlowDownloadJob::GetResponseInfo(net::HttpResponseInfo* info) { | 140 void URLRequestSlowDownloadJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 141 // Forward to private const version. | 141 // Forward to private const version. |
| 142 GetResponseInfoConst(info); | 142 GetResponseInfoConst(info); |
| 143 } | 143 } |
| 144 | 144 |
| 145 URLRequestSlowDownloadJob::~URLRequestSlowDownloadJob() {} |
| 146 |
| 145 // Private const version. | 147 // Private const version. |
| 146 void URLRequestSlowDownloadJob::GetResponseInfoConst( | 148 void URLRequestSlowDownloadJob::GetResponseInfoConst( |
| 147 net::HttpResponseInfo* info) const { | 149 net::HttpResponseInfo* info) const { |
| 148 // Send back mock headers. | 150 // Send back mock headers. |
| 149 std::string raw_headers; | 151 std::string raw_headers; |
| 150 if (LowerCaseEqualsASCII(kFinishDownloadUrl, | 152 if (LowerCaseEqualsASCII(kFinishDownloadUrl, |
| 151 request_->url().spec().c_str())) { | 153 request_->url().spec().c_str())) { |
| 152 raw_headers.append( | 154 raw_headers.append( |
| 153 "HTTP/1.1 200 OK\n" | 155 "HTTP/1.1 200 OK\n" |
| 154 "Content-type: text/plain\n"); | 156 "Content-type: text/plain\n"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 167 // ParseRawHeaders expects \0 to end each header line. | 169 // ParseRawHeaders expects \0 to end each header line. |
| 168 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 170 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 169 info->headers = new net::HttpResponseHeaders(raw_headers); | 171 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 170 } | 172 } |
| 171 | 173 |
| 172 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { | 174 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { |
| 173 net::HttpResponseInfo info; | 175 net::HttpResponseInfo info; |
| 174 GetResponseInfoConst(&info); | 176 GetResponseInfoConst(&info); |
| 175 return info.headers && info.headers->GetMimeType(mime_type); | 177 return info.headers && info.headers->GetMimeType(mime_type); |
| 176 } | 178 } |
| OLD | NEW |