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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // notifications to send. This is not applicable when using auto_advance. | 83 // notifications to send. This is not applicable when using auto_advance. |
84 static bool ProcessOnePendingMessage(); | 84 static bool ProcessOnePendingMessage(); |
85 | 85 |
86 // With auto advance enabled, the job will advance thru the stages without | 86 // With auto advance enabled, the job will advance thru the stages without |
87 // the caller having to call ProcessOnePendingMessage. Auto advance depends | 87 // the caller having to call ProcessOnePendingMessage. Auto advance depends |
88 // on having a message loop running. The default is to not auto advance. | 88 // on having a message loop running. The default is to not auto advance. |
89 // Should not be altered after the job has started. | 89 // Should not be altered after the job has started. |
90 bool auto_advance() { return auto_advance_; } | 90 bool auto_advance() { return auto_advance_; } |
91 void set_auto_advance(bool auto_advance) { auto_advance_ = auto_advance; } | 91 void set_auto_advance(bool auto_advance) { auto_advance_ = auto_advance; } |
92 | 92 |
| 93 RequestPriority priority() const { return priority_; } |
| 94 |
93 // Factory method for protocol factory registration if callers don't subclass | 95 // Factory method for protocol factory registration if callers don't subclass |
94 static URLRequest::ProtocolFactory Factory; | 96 static URLRequest::ProtocolFactory Factory; |
95 | 97 |
96 // Job functions | 98 // Job functions |
| 99 virtual void SetPriority(RequestPriority priority) OVERRIDE; |
97 virtual void Start() OVERRIDE; | 100 virtual void Start() OVERRIDE; |
98 virtual bool ReadRawData(IOBuffer* buf, | 101 virtual bool ReadRawData(IOBuffer* buf, |
99 int buf_size, | 102 int buf_size, |
100 int *bytes_read) OVERRIDE; | 103 int *bytes_read) OVERRIDE; |
101 virtual void Kill() OVERRIDE; | 104 virtual void Kill() OVERRIDE; |
102 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 105 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
103 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; | 106 virtual void GetResponseInfo(HttpResponseInfo* info) OVERRIDE; |
104 virtual int GetResponseCode() const OVERRIDE; | 107 virtual int GetResponseCode() const OVERRIDE; |
105 virtual bool IsRedirectResponse(GURL* location, | 108 virtual bool IsRedirectResponse(GURL* location, |
106 int* http_status_code) OVERRIDE; | 109 int* http_status_code) OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
125 // Call to move the job along to the next operation. | 128 // Call to move the job along to the next operation. |
126 void AdvanceJob(); | 129 void AdvanceJob(); |
127 | 130 |
128 // Called via InvokeLater to cause callbacks to occur after Start() returns. | 131 // Called via InvokeLater to cause callbacks to occur after Start() returns. |
129 virtual void StartAsync(); | 132 virtual void StartAsync(); |
130 | 133 |
131 bool auto_advance_; | 134 bool auto_advance_; |
132 | 135 |
133 Stage stage_; | 136 Stage stage_; |
134 | 137 |
| 138 RequestPriority priority_; |
| 139 |
135 // The headers the job should return, will be set in Start() if not provided | 140 // The headers the job should return, will be set in Start() if not provided |
136 // in the explicit ctor. | 141 // in the explicit ctor. |
137 scoped_refptr<HttpResponseHeaders> response_headers_; | 142 scoped_refptr<HttpResponseHeaders> response_headers_; |
138 | 143 |
139 // The data to send, will be set in Start() if not provided in the explicit | 144 // The data to send, will be set in Start() if not provided in the explicit |
140 // ctor. | 145 // ctor. |
141 std::string response_data_; | 146 std::string response_data_; |
142 | 147 |
143 // current offset within response_data_ | 148 // current offset within response_data_ |
144 int offset_; | 149 int offset_; |
145 | 150 |
146 // Holds the buffer for an asynchronous ReadRawData call | 151 // Holds the buffer for an asynchronous ReadRawData call |
147 IOBuffer* async_buf_; | 152 IOBuffer* async_buf_; |
148 int async_buf_size_; | 153 int async_buf_size_; |
149 | 154 |
150 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; | 155 base::WeakPtrFactory<URLRequestTestJob> weak_factory_; |
151 }; | 156 }; |
152 | 157 |
153 } // namespace net | 158 } // namespace net |
154 | 159 |
155 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ | 160 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_JOB_H_ |
OLD | NEW |