| 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 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // process jobs on this queue, use ProcessOnePendingMessage, which will process | 32 // process jobs on this queue, use ProcessOnePendingMessage, which will process |
| 33 // one step of the next job. If the job is incomplete, it will be added to the | 33 // one step of the next job. If the job is incomplete, it will be added to the |
| 34 // end of the queue. | 34 // end of the queue. |
| 35 // | 35 // |
| 36 // Optionally, you can also construct test jobs that advance automatically | 36 // Optionally, you can also construct test jobs that advance automatically |
| 37 // without having to call ProcessOnePendingMessage. | 37 // without having to call ProcessOnePendingMessage. |
| 38 class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob { | 38 class NET_EXPORT_PRIVATE URLRequestTestJob : public URLRequestJob { |
| 39 public: | 39 public: |
| 40 // Constructs a job to return one of the canned responses depending on the | 40 // Constructs a job to return one of the canned responses depending on the |
| 41 // request url, with auto advance disabled. | 41 // request url, with auto advance disabled. |
| 42 explicit URLRequestTestJob(URLRequest* request); | 42 URLRequestTestJob(URLRequest* request, NetworkDelegate* network_delegate); |
| 43 | 43 |
| 44 // Constructs a job to return one of the canned responses depending on the | 44 // Constructs a job to return one of the canned responses depending on the |
| 45 // request url, optionally with auto advance enabled. | 45 // request url, optionally with auto advance enabled. |
| 46 URLRequestTestJob(URLRequest* request, bool auto_advance); | 46 URLRequestTestJob(URLRequest* request, |
| 47 NetworkDelegate* network_delegate, |
| 48 bool auto_advance); |
| 47 | 49 |
| 48 // Constructs a job to return the given response regardless of the request | 50 // Constructs a job to return the given response regardless of the request |
| 49 // url. The headers should include the HTTP status line and be formatted as | 51 // url. The headers should include the HTTP status line and be formatted as |
| 50 // expected by HttpResponseHeaders. | 52 // expected by HttpResponseHeaders. |
| 51 URLRequestTestJob(URLRequest* request, | 53 URLRequestTestJob(URLRequest* request, |
| 54 net::NetworkDelegate* network_delegate, |
| 52 const std::string& response_headers, | 55 const std::string& response_headers, |
| 53 const std::string& response_data, | 56 const std::string& response_data, |
| 54 bool auto_advance); | 57 bool auto_advance); |
| 55 | 58 |
| 56 // The three canned URLs this handler will respond to without having been | 59 // The three canned URLs this handler will respond to without having been |
| 57 // explicitly initialized with response headers and data. | 60 // explicitly initialized with response headers and data. |
| 58 // FIXME(brettw): we should probably also have a redirect one | 61 // FIXME(brettw): we should probably also have a redirect one |
| 59 static GURL test_url_1(); | 62 static GURL test_url_1(); |
| 60 static GURL test_url_2(); | 63 static GURL test_url_2(); |
| 61 static GURL test_url_3(); | 64 static GURL test_url_3(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Holds the buffer for an asynchronous ReadRawData call | 146 // Holds the buffer for an asynchronous ReadRawData call |
| 144 IOBuffer* async_buf_; | 147 IOBuffer* async_buf_; |
| 145 int async_buf_size_; | 148 int async_buf_size_; |
| 146 | 149 |
| 147 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; | 150 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; |
| 148 }; | 151 }; |
| 149 | 152 |
| 150 } // namespace net | 153 } // namespace net |
| 151 | 154 |
| 152 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 155 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| OLD | NEW |