| 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 #include "net/url_request/test_url_request_interceptor.h" |    5 #include "net/url_request/test_url_request_interceptor.h" | 
|    6  |    6  | 
|    7 #include "base/files/file_util.h" |    7 #include "base/files/file_util.h" | 
|    8 #include "base/macros.h" |    8 #include "base/macros.h" | 
|    9 #include "base/threading/sequenced_worker_pool.h" |    9 #include "base/threading/sequenced_worker_pool.h" | 
|   10 #include "base/threading/thread_restrictions.h" |   10 #include "base/threading/thread_restrictions.h" | 
 |   11 #include "net/http/http_response_headers.h" | 
 |   12 #include "net/http/http_response_info.h" | 
|   11 #include "net/url_request/url_request.h" |   13 #include "net/url_request/url_request.h" | 
|   12 #include "net/url_request/url_request_file_job.h" |   14 #include "net/url_request/url_request_file_job.h" | 
|   13 #include "net/url_request/url_request_filter.h" |   15 #include "net/url_request/url_request_filter.h" | 
|   14 #include "net/url_request/url_request_interceptor.h" |   16 #include "net/url_request/url_request_interceptor.h" | 
|   15 #include "testing/gtest/include/gtest/gtest.h" |   17 #include "testing/gtest/include/gtest/gtest.h" | 
|   16  |   18  | 
|   17 namespace net { |   19 namespace net { | 
|   18  |   20  | 
|   19 namespace { |   21 namespace { | 
|   20  |   22  | 
|   21 // This class is needed because URLRequestFileJob always returns a -1 |   23 // This class is needed because URLRequestFileJob always returns a -1 | 
|   22 // HTTP response status code. |   24 // HTTP response status code. | 
|   23 class TestURLRequestJob : public URLRequestFileJob { |   25 class TestURLRequestJob : public URLRequestFileJob { | 
|   24  public: |   26  public: | 
|   25   TestURLRequestJob(URLRequest* request, |   27   TestURLRequestJob(URLRequest* request, | 
|   26                     NetworkDelegate* network_delegate, |   28                     NetworkDelegate* network_delegate, | 
|   27                     const base::FilePath& file_path, |   29                     const base::FilePath& file_path, | 
|   28                     const scoped_refptr<base::TaskRunner>& worker_task_runner) |   30                     const scoped_refptr<base::TaskRunner>& worker_task_runner) | 
|   29       : URLRequestFileJob(request, |   31       : URLRequestFileJob(request, | 
|   30                           network_delegate, |   32                           network_delegate, | 
|   31                           file_path, |   33                           file_path, | 
|   32                           worker_task_runner) {} |   34                           worker_task_runner) {} | 
|   33  |   35  | 
|   34   int GetResponseCode() const override { return 200; } |   36   void GetResponseInfo(HttpResponseInfo* info) override { | 
 |   37     info->headers = new net::HttpResponseHeaders("HTTP/1.1 200 OK"); | 
 |   38   } | 
|   35  |   39  | 
|   36  private: |   40  private: | 
|   37   ~TestURLRequestJob() override {} |   41   ~TestURLRequestJob() override {} | 
|   38  |   42  | 
|   39   DISALLOW_COPY_AND_ASSIGN(TestURLRequestJob); |   43   DISALLOW_COPY_AND_ASSIGN(TestURLRequestJob); | 
|   40 }; |   44 }; | 
|   41  |   45  | 
|   42 }  // namespace |   46 }  // namespace | 
|   43  |   47  | 
|   44 // This class handles the actual URL request interception. It may be constructed |   48 // This class handles the actual URL request interception. It may be constructed | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  190 LocalHostTestURLRequestInterceptor::LocalHostTestURLRequestInterceptor( |  194 LocalHostTestURLRequestInterceptor::LocalHostTestURLRequestInterceptor( | 
|  191     const scoped_refptr<base::TaskRunner>& network_task_runner, |  195     const scoped_refptr<base::TaskRunner>& network_task_runner, | 
|  192     const scoped_refptr<base::TaskRunner>& worker_task_runner) |  196     const scoped_refptr<base::TaskRunner>& worker_task_runner) | 
|  193     : TestURLRequestInterceptor("http", |  197     : TestURLRequestInterceptor("http", | 
|  194                                 "localhost", |  198                                 "localhost", | 
|  195                                 network_task_runner, |  199                                 network_task_runner, | 
|  196                                 worker_task_runner) { |  200                                 worker_task_runner) { | 
|  197 } |  201 } | 
|  198  |  202  | 
|  199 }  // namespace net |  203 }  // namespace net | 
| OLD | NEW |