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_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | |
12 #include "net/base/filter.h" | 13 #include "net/base/filter.h" |
13 #include "net/base/load_states.h" | 14 #include "net/base/load_states.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 class AuthChallengeInfo; | 17 class AuthChallengeInfo; |
17 class HttpResponseInfo; | 18 class HttpResponseInfo; |
18 class IOBuffer; | 19 class IOBuffer; |
19 class UploadData; | 20 class UploadData; |
20 } | 21 } |
21 | 22 |
22 class GURL; | 23 class GURL; |
23 class URLRequest; | 24 class URLRequest; |
24 class URLRequestStatus; | 25 class URLRequestStatus; |
25 class URLRequestJobMetrics; | 26 class URLRequestJobMetrics; |
26 | 27 |
27 // The URLRequestJob is using RefCounterThreadSafe because some sub classes | 28 // The URLRequestJob is using RefCounterThreadSafe because some sub classes |
28 // can be destroyed on multiple threads. This is the case of the | 29 // can be destroyed on multiple threads. This is the case of the |
29 // UrlRequestFileJob. | 30 // UrlRequestFileJob. |
30 class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob> { | 31 class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, |
32 public FilterContext { | |
31 public: | 33 public: |
32 explicit URLRequestJob(URLRequest* request); | 34 explicit URLRequestJob(URLRequest* request); |
33 virtual ~URLRequestJob(); | 35 virtual ~URLRequestJob(); |
34 | 36 |
35 // Returns the request that owns this job. THIS POINTER MAY BE NULL if the | 37 // Returns the request that owns this job. THIS POINTER MAY BE NULL if the |
36 // request was destroyed. | 38 // request was destroyed. |
37 URLRequest* request() const { | 39 URLRequest* request() const { |
38 return request_; | 40 return request_; |
39 } | 41 } |
40 | 42 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 // This is just the backend for URLRequest::Read, see that function for more | 81 // This is just the backend for URLRequest::Read, see that function for more |
80 // info. | 82 // info. |
81 bool Read(net::IOBuffer* buf, int buf_size, int *bytes_read); | 83 bool Read(net::IOBuffer* buf, int buf_size, int *bytes_read); |
82 | 84 |
83 // Called to fetch the current load state for the job. | 85 // Called to fetch the current load state for the job. |
84 virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } | 86 virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } |
85 | 87 |
86 // Called to get the upload progress in bytes. | 88 // Called to get the upload progress in bytes. |
87 virtual uint64 GetUploadProgress() const { return 0; } | 89 virtual uint64 GetUploadProgress() const { return 0; } |
88 | 90 |
89 // Called to fetch the mime_type for this request. Only makes sense for some | |
90 // types of requests. Returns true on success. Calling this on a type that | |
91 // doesn't have a mime type will return false. | |
92 virtual bool GetMimeType(std::string* mime_type) { return false; } | |
93 | |
94 // Called to fetch the charset for this request. Only makes sense for some | 91 // Called to fetch the charset for this request. Only makes sense for some |
95 // types of requests. Returns true on success. Calling this on a type that | 92 // types of requests. Returns true on success. Calling this on a type that |
96 // doesn't have a charset will return false. | 93 // doesn't have a charset will return false. |
97 virtual bool GetCharset(std::string* charset) { return false; } | 94 virtual bool GetCharset(std::string* charset) { return false; } |
98 | 95 |
99 // Called to get response info. | 96 // Called to get response info. |
100 virtual void GetResponseInfo(net::HttpResponseInfo* info) {} | 97 virtual void GetResponseInfo(net::HttpResponseInfo* info) {} |
101 | 98 |
102 // Returns the cookie values included in the response, if applicable. | 99 // Returns the cookie values included in the response, if applicable. |
103 // Returns true if applicable. | 100 // Returns true if applicable. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 // with a URLRequestJobMetrics object. The caller owns this object from now | 182 // with a URLRequestJobMetrics object. The caller owns this object from now |
186 // on. | 183 // on. |
187 URLRequestJobMetrics* RetrieveMetrics(); | 184 URLRequestJobMetrics* RetrieveMetrics(); |
188 | 185 |
189 // Get/Set expected content size | 186 // Get/Set expected content size |
190 int64 expected_content_size() const { return expected_content_size_; } | 187 int64 expected_content_size() const { return expected_content_size_; } |
191 void set_expected_content_size(const int64& size) { | 188 void set_expected_content_size(const int64& size) { |
192 expected_content_size_ = size; | 189 expected_content_size_ = size; |
193 } | 190 } |
194 | 191 |
192 // FilterContext methods: | |
193 // These methods are not applicable to all connections. | |
194 virtual bool GetMimeType(std::string* mime_type) const { return false; } | |
195 virtual bool GetURL(GURL* gurl) const; | |
196 virtual base::Time GetRequestTime() const; | |
197 virtual bool IsCachedContent() const; | |
198 virtual int GetInputStreambufferSize() const { return kFilterBufSize; } | |
wtc
2009/03/09 17:24:09
Should we capitalize "buffer"?
| |
199 | |
195 protected: | 200 protected: |
196 // Notifies the job that headers have been received. | 201 // Notifies the job that headers have been received. |
197 void NotifyHeadersComplete(); | 202 void NotifyHeadersComplete(); |
198 | 203 |
199 // Notifies the request that the job has completed a Read operation. | 204 // Notifies the request that the job has completed a Read operation. |
200 void NotifyReadComplete(int bytes_read); | 205 void NotifyReadComplete(int bytes_read); |
201 | 206 |
202 // Notifies the request that a start error has occurred. | 207 // Notifies the request that a start error has occurred. |
203 void NotifyStartError(const URLRequestStatus& status); | 208 void NotifyStartError(const URLRequestStatus& status); |
204 | 209 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 // Set the status of the job. | 257 // Set the status of the job. |
253 void SetStatus(const URLRequestStatus& status); | 258 void SetStatus(const URLRequestStatus& status); |
254 | 259 |
255 // Whether the job is doing performance profiling | 260 // Whether the job is doing performance profiling |
256 bool is_profiling_; | 261 bool is_profiling_; |
257 | 262 |
258 // Contains IO performance measurement when profiling is enabled. | 263 // Contains IO performance measurement when profiling is enabled. |
259 scoped_ptr<URLRequestJobMetrics> metrics_; | 264 scoped_ptr<URLRequestJobMetrics> metrics_; |
260 | 265 |
261 private: | 266 private: |
267 // Size of filter input buffers used by this class. | |
268 static const int kFilterBufSize; | |
269 | |
262 // When data filtering is enabled, this function is used to read data | 270 // When data filtering is enabled, this function is used to read data |
263 // for the filter. Returns true if raw data was read. Returns false if | 271 // for the filter. Returns true if raw data was read. Returns false if |
264 // an error occurred (or we are waiting for IO to complete). | 272 // an error occurred (or we are waiting for IO to complete). |
265 bool ReadRawDataForFilter(int *bytes_read); | 273 bool ReadRawDataForFilter(int *bytes_read); |
266 | 274 |
267 // Called in response to a redirect that was not canceled to follow the | 275 // Called in response to a redirect that was not canceled to follow the |
268 // redirect. The current job will be replaced with a new job loading the | 276 // redirect. The current job will be replaced with a new job loading the |
269 // given redirect destination. | 277 // given redirect destination. |
270 void FollowRedirect(const GURL& location, int http_status_code); | 278 void FollowRedirect(const GURL& location, int http_status_code); |
271 | 279 |
(...skipping 29 matching lines...) Expand all Loading... | |
301 // OnResponseStarted callback and potentially redirect callbacks as well. | 309 // OnResponseStarted callback and potentially redirect callbacks as well. |
302 bool has_handled_response_; | 310 bool has_handled_response_; |
303 | 311 |
304 // Expected content size | 312 // Expected content size |
305 int64 expected_content_size_; | 313 int64 expected_content_size_; |
306 | 314 |
307 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 315 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
308 }; | 316 }; |
309 | 317 |
310 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 318 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
OLD | NEW |