| 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 URLRequestJob class that pulls the net and http headers from disk. | 5 // A URLRequestJob class that pulls the net and http headers from disk. |
| 6 | 6 |
| 7 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ | 7 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ |
| 8 #define NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ | 8 #define NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 int GetResponseCode() const override; | 47 int GetResponseCode() const override; |
| 48 bool GetCharset(std::string* charset) override; | 48 bool GetCharset(std::string* charset) override; |
| 49 void GetResponseInfo(HttpResponseInfo* info) override; | 49 void GetResponseInfo(HttpResponseInfo* info) override; |
| 50 bool IsRedirectResponse(GURL* location, int* http_status_code) override; | 50 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
| 51 | 51 |
| 52 // Adds the testing URLs to the URLRequestFilter, both under HTTP and HTTPS. | 52 // Adds the testing URLs to the URLRequestFilter, both under HTTP and HTTPS. |
| 53 static void AddUrlHandlers( | 53 static void AddUrlHandlers( |
| 54 const base::FilePath& base_path, | 54 const base::FilePath& base_path, |
| 55 const scoped_refptr<base::SequencedWorkerPool>& worker_pool); | 55 const scoped_refptr<base::SequencedWorkerPool>& worker_pool); |
| 56 | 56 |
| 57 // Respond to all HTTP requests of |hostname| with contents of the file | |
| 58 // located at |file_path|. | |
| 59 static void AddHostnameToFileHandler( | |
| 60 const std::string& hostname, | |
| 61 const base::FilePath& file, | |
| 62 const scoped_refptr<base::SequencedWorkerPool>& worker_pool); | |
| 63 | |
| 64 // Given the path to a file relative to the path passed to AddUrlHandler(), | 57 // Given the path to a file relative to the path passed to AddUrlHandler(), |
| 65 // construct a mock URL. | 58 // construct a mock URL. |
| 66 static GURL GetMockUrl(const base::FilePath& path); | 59 static GURL GetMockUrl(const base::FilePath& path); |
| 67 static GURL GetMockHttpsUrl(const base::FilePath& path); | 60 static GURL GetMockHttpsUrl(const base::FilePath& path); |
| 68 | 61 |
| 69 // Given the path to a file relative to the path passed to AddUrlHandler(), | 62 // Given the path to a file relative to the path passed to AddUrlHandler(), |
| 70 // construct a mock URL that reports |net_error| at given |phase| of the | 63 // construct a mock URL that reports |net_error| at given |phase| of the |
| 71 // request. Reporting |net_error| ERR_IO_PENDING results in a hung request. | 64 // request. Reporting |net_error| ERR_IO_PENDING results in a hung request. |
| 72 static GURL GetMockUrlWithFailure(const base::FilePath& path, | 65 static GURL GetMockUrlWithFailure(const base::FilePath& path, |
| 73 FailurePhase phase, | 66 FailurePhase phase, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 104 const scoped_refptr<base::TaskRunner> task_runner_; | 97 const scoped_refptr<base::TaskRunner> task_runner_; |
| 105 | 98 |
| 106 base::WeakPtrFactory<URLRequestMockHTTPJob> weak_ptr_factory_; | 99 base::WeakPtrFactory<URLRequestMockHTTPJob> weak_ptr_factory_; |
| 107 | 100 |
| 108 DISALLOW_COPY_AND_ASSIGN(URLRequestMockHTTPJob); | 101 DISALLOW_COPY_AND_ASSIGN(URLRequestMockHTTPJob); |
| 109 }; | 102 }; |
| 110 | 103 |
| 111 } // namespace net | 104 } // namespace net |
| 112 | 105 |
| 113 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ | 106 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_MOCK_HTTP_JOB_H_ |
| OLD | NEW |