OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 // | |
5 // A net::URLRequestJob class that pulls the content and http headers from disk. | |
6 | |
7 #ifndef CHROME_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | |
8 #define CHROME_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | |
9 #pragma once | |
10 | |
11 #include <string> | |
12 | |
13 #include "net/url_request/url_request_file_job.h" | |
14 | |
15 class FilePath; | |
16 | |
17 class URLRequestMockHTTPJob : public net::URLRequestFileJob { | |
18 public: | |
19 URLRequestMockHTTPJob(net::URLRequest* request, const FilePath& file_path); | |
20 | |
21 virtual bool GetMimeType(std::string* mime_type) const; | |
22 virtual bool GetCharset(std::string* charset); | |
23 virtual void GetResponseInfo(net::HttpResponseInfo* info); | |
24 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | |
25 | |
26 static net::URLRequest::ProtocolFactory Factory; | |
27 | |
28 // Adds the testing URLs to the net::URLRequestFilter. | |
29 static void AddUrlHandler(const FilePath& base_path); | |
30 | |
31 // Given the path to a file relative to base_path_, construct a mock URL. | |
32 static GURL GetMockUrl(const FilePath& path); | |
33 | |
34 // Given the path to a file relative to base_path_, | |
35 // construct a mock URL for view source. | |
36 static GURL GetMockViewSourceUrl(const FilePath& path); | |
37 | |
38 protected: | |
39 virtual ~URLRequestMockHTTPJob() { } | |
40 | |
41 static FilePath GetOnDiskPath(const FilePath& base_path, | |
42 net::URLRequest* request, | |
43 const std::string& scheme); | |
44 | |
45 private: | |
46 void GetResponseInfoConst(net::HttpResponseInfo* info) const; | |
47 | |
48 // This is the file path leading to the root of the directory to use as the | |
49 // root of the http server. | |
50 static FilePath base_path_; | |
51 }; | |
52 | |
53 #endif // CHROME_BROWSER_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | |
OLD | NEW |