OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 explicit URLRequestTestJob(URLRequest* request, bool auto_advance); | 43 explicit URLRequestTestJob(URLRequest* request, bool auto_advance); |
44 | 44 |
45 // Constructs a job to return the given response regardless of the request | 45 // Constructs a job to return the given response regardless of the request |
46 // url. The headers should include the HTTP status line and be formatted as | 46 // url. The headers should include the HTTP status line and be formatted as |
47 // expected by net::HttpResponseHeaders. | 47 // expected by net::HttpResponseHeaders. |
48 explicit URLRequestTestJob(URLRequest* request, | 48 explicit URLRequestTestJob(URLRequest* request, |
49 const std::string& response_headers, | 49 const std::string& response_headers, |
50 const std::string& response_data, | 50 const std::string& response_data, |
51 bool auto_advance); | 51 bool auto_advance); |
52 | 52 |
53 virtual ~URLRequestTestJob(); | |
54 | |
55 // The three canned URLs this handler will respond to without having been | 53 // The three canned URLs this handler will respond to without having been |
56 // explicitly initialized with response headers and data. | 54 // explicitly initialized with response headers and data. |
57 // FIXME(brettw): we should probably also have a redirect one | 55 // FIXME(brettw): we should probably also have a redirect one |
58 static GURL test_url_1(); | 56 static GURL test_url_1(); |
59 static GURL test_url_2(); | 57 static GURL test_url_2(); |
60 static GURL test_url_3(); | 58 static GURL test_url_3(); |
61 static GURL test_url_error(); | 59 static GURL test_url_error(); |
62 | 60 |
63 // The data that corresponds to each of the URLs above | 61 // The data that corresponds to each of the URLs above |
64 static std::string test_data_1(); | 62 static std::string test_data_1(); |
(...skipping 30 matching lines...) Expand all Loading... |
95 virtual void Kill(); | 93 virtual void Kill(); |
96 virtual bool GetMimeType(std::string* mime_type) const; | 94 virtual bool GetMimeType(std::string* mime_type) const; |
97 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 95 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
98 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 96 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
99 | 97 |
100 protected: | 98 protected: |
101 // This is what operation we are going to do next when this job is handled. | 99 // This is what operation we are going to do next when this job is handled. |
102 // When the stage is DONE, this job will not be put on the queue. | 100 // When the stage is DONE, this job will not be put on the queue. |
103 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; | 101 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; |
104 | 102 |
| 103 virtual ~URLRequestTestJob(); |
| 104 |
105 // Call to process the next opeation, usually sending a notification, and | 105 // Call to process the next opeation, usually sending a notification, and |
106 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. | 106 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. |
107 void ProcessNextOperation(); | 107 void ProcessNextOperation(); |
108 | 108 |
109 // Call to move the job along to the next operation. | 109 // Call to move the job along to the next operation. |
110 void AdvanceJob(); | 110 void AdvanceJob(); |
111 | 111 |
112 // Called via InvokeLater to cause callbacks to occur after Start() returns. | 112 // Called via InvokeLater to cause callbacks to occur after Start() returns. |
113 virtual void StartAsync(); | 113 virtual void StartAsync(); |
114 | 114 |
(...skipping 11 matching lines...) Expand all Loading... |
126 | 126 |
127 // current offset within response_data_ | 127 // current offset within response_data_ |
128 int offset_; | 128 int offset_; |
129 | 129 |
130 // Holds the buffer for an asynchronous ReadRawData call | 130 // Holds the buffer for an asynchronous ReadRawData call |
131 net::IOBuffer* async_buf_; | 131 net::IOBuffer* async_buf_; |
132 int async_buf_size_; | 132 int async_buf_size_; |
133 }; | 133 }; |
134 | 134 |
135 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 135 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
OLD | NEW |