OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // A net::URLRequestJob class that pulls the content and http headers from disk. | 5 // A net::URLRequestJob class that pulls the content and http headers from disk. |
6 | 6 |
7 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 7 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
8 #define CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 8 #define CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "net/url_request/url_request_file_job.h" | 14 #include "net/url_request/url_request_file_job.h" |
15 | 15 |
16 class FilePath; | 16 class FilePath; |
17 | 17 |
18 class CONTENT_EXPORT URLRequestMockHTTPJob : public net::URLRequestFileJob { | 18 class CONTENT_EXPORT URLRequestMockHTTPJob : public net::URLRequestFileJob { |
19 public: | 19 public: |
20 URLRequestMockHTTPJob(net::URLRequest* request, const FilePath& file_path); | 20 URLRequestMockHTTPJob(net::URLRequest* request, const FilePath& file_path); |
21 | 21 |
22 virtual bool GetMimeType(std::string* mime_type) const; | 22 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
23 virtual bool GetCharset(std::string* charset); | 23 virtual bool GetCharset(std::string* charset) OVERRIDE; |
24 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 24 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
25 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 25 virtual bool IsRedirectResponse(GURL* location, |
| 26 int* http_status_code) OVERRIDE; |
26 | 27 |
27 static net::URLRequest::ProtocolFactory Factory; | 28 static net::URLRequest::ProtocolFactory Factory; |
28 | 29 |
29 // Adds the testing URLs to the net::URLRequestFilter. | 30 // Adds the testing URLs to the net::URLRequestFilter. |
30 static void AddUrlHandler(const FilePath& base_path); | 31 static void AddUrlHandler(const FilePath& base_path); |
31 | 32 |
32 // Given the path to a file relative to the path passed to AddUrlHandler(), | 33 // Given the path to a file relative to the path passed to AddUrlHandler(), |
33 // construct a mock URL. | 34 // construct a mock URL. |
34 static GURL GetMockUrl(const FilePath& path); | 35 static GURL GetMockUrl(const FilePath& path); |
35 | 36 |
36 // Given the path to a file relative to the path passed to AddUrlHandler(), | 37 // Given the path to a file relative to the path passed to AddUrlHandler(), |
37 // construct a mock URL for view source. | 38 // construct a mock URL for view source. |
38 static GURL GetMockViewSourceUrl(const FilePath& path); | 39 static GURL GetMockViewSourceUrl(const FilePath& path); |
39 | 40 |
40 protected: | 41 protected: |
41 virtual ~URLRequestMockHTTPJob() { } | 42 virtual ~URLRequestMockHTTPJob() { } |
42 | 43 |
43 static FilePath GetOnDiskPath(const FilePath& base_path, | 44 static FilePath GetOnDiskPath(const FilePath& base_path, |
44 net::URLRequest* request, | 45 net::URLRequest* request, |
45 const std::string& scheme); | 46 const std::string& scheme); |
46 | 47 |
47 private: | 48 private: |
48 void GetResponseInfoConst(net::HttpResponseInfo* info) const; | 49 void GetResponseInfoConst(net::HttpResponseInfo* info) const; |
49 }; | 50 }; |
50 | 51 |
51 #endif // CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 52 #endif // CONTENT_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
OLD | NEW |