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 // 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_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 7 #ifndef CONTENT_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
8 #define CONTENT_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 8 #define CONTENT_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "net/url_request/url_request_file_job.h" | 12 #include "net/url_request/url_request_file_job.h" |
13 #include "net/url_request/url_request_job_factory.h" | |
14 | 13 |
15 namespace base { | 14 namespace base { |
16 class FilePath; | 15 class FilePath; |
17 } | 16 } |
18 | 17 |
| 18 namespace net { |
| 19 class URLRequestInterceptor; |
| 20 } |
| 21 |
19 namespace content { | 22 namespace content { |
20 | 23 |
21 class URLRequestMockHTTPJob : public net::URLRequestFileJob { | 24 class URLRequestMockHTTPJob : public net::URLRequestFileJob { |
22 public: | 25 public: |
23 URLRequestMockHTTPJob(net::URLRequest* request, | 26 URLRequestMockHTTPJob(net::URLRequest* request, |
24 net::NetworkDelegate* network_delegate, | 27 net::NetworkDelegate* network_delegate, |
25 const base::FilePath& file_path); | 28 const base::FilePath& file_path); |
26 | 29 |
27 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 30 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
28 virtual int GetResponseCode() const OVERRIDE; | 31 virtual int GetResponseCode() const OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
44 static GURL GetMockUrl(const base::FilePath& path); | 47 static GURL GetMockUrl(const base::FilePath& path); |
45 | 48 |
46 // Given the path to a file relative to the path passed to AddUrlHandler(), | 49 // Given the path to a file relative to the path passed to AddUrlHandler(), |
47 // construct a mock URL for view source. | 50 // construct a mock URL for view source. |
48 static GURL GetMockViewSourceUrl(const base::FilePath& path); | 51 static GURL GetMockViewSourceUrl(const base::FilePath& path); |
49 | 52 |
50 // Returns a net::URLRequestJobFactory::ProtocolHandler that serves | 53 // Returns a net::URLRequestJobFactory::ProtocolHandler that serves |
51 // URLRequestMockHTTPJob's responding like an HTTP server. |base_path| is the | 54 // URLRequestMockHTTPJob's responding like an HTTP server. |base_path| is the |
52 // file path leading to the root of the directory to use as the root of the | 55 // file path leading to the root of the directory to use as the root of the |
53 // HTTP server. | 56 // HTTP server. |
54 static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 57 static scoped_ptr<net::URLRequestInterceptor> |
55 CreateProtocolHandler(const base::FilePath& base_path); | 58 CreateInterceptor(const base::FilePath& base_path); |
56 | 59 |
57 // Returns a net::URLRequestJobFactory::ProtocolHandler that serves | 60 // Returns a net::URLRequestJobFactory::ProtocolHandler that serves |
58 // URLRequestMockHTTPJob's responding like an HTTP server. It responds to all | 61 // URLRequestMockHTTPJob's responding like an HTTP server. It responds to all |
59 // requests with the contents of |file|. | 62 // requests with the contents of |file|. |
60 static scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 63 static scoped_ptr<net::URLRequestInterceptor> |
61 CreateProtocolHandlerForSingleFile(const base::FilePath& file); | 64 CreateInterceptorForSingleFile(const base::FilePath& file); |
62 | 65 |
63 protected: | 66 protected: |
64 virtual ~URLRequestMockHTTPJob(); | 67 virtual ~URLRequestMockHTTPJob(); |
65 | 68 |
66 private: | 69 private: |
67 void GetResponseInfoConst(net::HttpResponseInfo* info) const; | 70 void GetResponseInfoConst(net::HttpResponseInfo* info) const; |
68 }; | 71 }; |
69 | 72 |
70 } // namespace content | 73 } // namespace content |
71 | 74 |
72 #endif // CONTENT_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ | 75 #endif // CONTENT_TEST_NET_URL_REQUEST_MOCK_HTTP_JOB_H_ |
OLD | NEW |