Chromium Code Reviews| 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/automation/url_request_mock_http_job.h" | 5 #include "chrome/browser/automation/url_request_mock_http_job.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.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 "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 url.append(kMockHostname); | 54 url.append(kMockHostname); |
| 55 url.append("/"); | 55 url.append("/"); |
| 56 url.append(WideToUTF8(path)); | 56 url.append(WideToUTF8(path)); |
| 57 return GURL(url); | 57 return GURL(url); |
| 58 } | 58 } |
| 59 | 59 |
| 60 URLRequestMockHTTPJob::URLRequestMockHTTPJob(URLRequest* request, | 60 URLRequestMockHTTPJob::URLRequestMockHTTPJob(URLRequest* request, |
| 61 const FilePath& file_path) | 61 const FilePath& file_path) |
| 62 : URLRequestFileJob(request, file_path) { } | 62 : URLRequestFileJob(request, file_path) { } |
| 63 | 63 |
| 64 // Public virtual version. | |
| 64 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) { | 65 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) { |
| 66 // Forward to private const version. | |
| 67 GetResponseInfoConst(info); | |
| 68 } | |
| 69 | |
| 70 // Private const version. | |
| 71 void URLRequestMockHTTPJob::GetResponseInfoConst(net::HttpResponseInfo* info) co nst { | |
|
huanr
2009/03/09 17:50:44
this line exceeds 80 characters. same for some oth
jar (doing other things)
2009/03/09 19:00:41
Done.
| |
| 65 std::wstring header_file = file_path_.ToWStringHack() + kMockHeaderFileSuffix; | 72 std::wstring header_file = file_path_.ToWStringHack() + kMockHeaderFileSuffix; |
| 66 std::string raw_headers; | 73 std::string raw_headers; |
| 67 if (!file_util::ReadFileToString(header_file, &raw_headers)) | 74 if (!file_util::ReadFileToString(header_file, &raw_headers)) |
| 68 return; | 75 return; |
| 69 | 76 |
| 70 // ParseRawHeaders expects \0 to end each header line. | 77 // ParseRawHeaders expects \0 to end each header line. |
| 71 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 78 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
| 72 info->headers = new net::HttpResponseHeaders(raw_headers); | 79 info->headers = new net::HttpResponseHeaders(raw_headers); |
| 73 } | 80 } |
| 74 | 81 |
| 75 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) { | 82 bool URLRequestMockHTTPJob::GetMimeType(std::string* mime_type) const { |
| 76 net::HttpResponseInfo info; | 83 net::HttpResponseInfo info; |
| 77 GetResponseInfo(&info); | 84 GetResponseInfoConst(&info); |
| 78 return info.headers && info.headers->GetMimeType(mime_type); | 85 return info.headers && info.headers->GetMimeType(mime_type); |
| 79 } | 86 } |
| 80 | 87 |
| 81 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 88 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
| 82 net::HttpResponseInfo info; | 89 net::HttpResponseInfo info; |
| 83 GetResponseInfo(&info); | 90 GetResponseInfo(&info); |
| 84 return info.headers && info.headers->GetCharset(charset); | 91 return info.headers && info.headers->GetCharset(charset); |
| 85 } | 92 } |
| 86 | 93 |
| OLD | NEW |