| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 virtual void Start() OVERRIDE; | 97 virtual void Start() OVERRIDE; |
| 98 virtual bool ReadRawData(IOBuffer* buf, | 98 virtual bool ReadRawData(IOBuffer* buf, |
| 99 int buf_size, | 99 int buf_size, |
| 100 int *bytes_read) OVERRIDE; | 100 int *bytes_read) OVERRIDE; |
| 101 virtual void Kill() OVERRIDE; | 101 virtual void Kill() OVERRIDE; |
| 102 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 102 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 103 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; | 103 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; |
| 104 virtual int GetResponseCode() const OVERRIDE; | 104 virtual int GetResponseCode() const OVERRIDE; |
| 105 virtual bool IsRedirectResponse(GURL* location, | 105 virtual bool IsRedirectResponse(GURL* location, |
| 106 int* http_status_code) OVERRIDE; | 106 int* http_status_code) OVERRIDE; |
| 107 virtual void SetPriority(RequestPriority priority) OVERRIDE; |
| 108 |
| 109 RequestPriority priority() const { |
| 110 return priority_; |
| 111 } |
| 107 | 112 |
| 108 protected: | 113 protected: |
| 109 // Override to specify whether the next read done from this job will | 114 // Override to specify whether the next read done from this job will |
| 110 // return IO pending. This controls whether or not the WAITING state will | 115 // return IO pending. This controls whether or not the WAITING state will |
| 111 // transition back to WAITING or to DATA_AVAILABLE after an asynchronous | 116 // transition back to WAITING or to DATA_AVAILABLE after an asynchronous |
| 112 // read is processed. | 117 // read is processed. |
| 113 virtual bool NextReadAsync(); | 118 virtual bool NextReadAsync(); |
| 114 | 119 |
| 115 // This is what operation we are going to do next when this job is handled. | 120 // This is what operation we are going to do next when this job is handled. |
| 116 // When the stage is DONE, this job will not be put on the queue. | 121 // When the stage is DONE, this job will not be put on the queue. |
| 117 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; | 122 enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; |
| 118 | 123 |
| 119 virtual ~URLRequestTestJob(); | 124 virtual ~URLRequestTestJob(); |
| 120 | 125 |
| 121 // Call to process the next opeation, usually sending a notification, and | 126 // Call to process the next opeation, usually sending a notification, and |
| 122 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. | 127 // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. |
| 123 void ProcessNextOperation(); | 128 void ProcessNextOperation(); |
| 124 | 129 |
| 125 // Call to move the job along to the next operation. | 130 // Call to move the job along to the next operation. |
| 126 void AdvanceJob(); | 131 void AdvanceJob(); |
| 127 | 132 |
| 128 // Called via InvokeLater to cause callbacks to occur after Start() returns. | 133 // Called via InvokeLater to cause callbacks to occur after Start() returns. |
| 129 virtual void StartAsync(); | 134 virtual void StartAsync(); |
| 130 | 135 |
| 131 bool auto_advance_; | 136 bool auto_advance_; |
| 132 | 137 |
| 133 Stage stage_; | 138 Stage stage_; |
| 134 | 139 |
| 140 RequestPriority priority_; |
| 141 |
| 135 // The headers the job should return, will be set in Start() if not provided | 142 // The headers the job should return, will be set in Start() if not provided |
| 136 // in the explicit ctor. | 143 // in the explicit ctor. |
| 137 scoped_refptr<HttpResponseHeaders> response_headers_; | 144 scoped_refptr<HttpResponseHeaders> response_headers_; |
| 138 | 145 |
| 139 // The data to send, will be set in Start() if not provided in the explicit | 146 // The data to send, will be set in Start() if not provided in the explicit |
| 140 // ctor. | 147 // ctor. |
| 141 std::string response_data_; | 148 std::string response_data_; |
| 142 | 149 |
| 143 // current offset within response_data_ | 150 // current offset within response_data_ |
| 144 int offset_; | 151 int offset_; |
| 145 | 152 |
| 146 // Holds the buffer for an asynchronous ReadRawData call | 153 // Holds the buffer for an asynchronous ReadRawData call |
| 147 IOBuffer* async_buf_; | 154 IOBuffer* async_buf_; |
| 148 int async_buf_size_; | 155 int async_buf_size_; |
| 149 | 156 |
| 150 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; | 157 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; |
| 151 }; | 158 }; |
| 152 | 159 |
| 153 } // namespace net | 160 } // namespace net |
| 154 | 161 |
| 155 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 162 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
| OLD | NEW |