Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: net/url_request/url_request_job.h

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_inet_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "net/base/auth.h" 13 #include "net/base/auth.h"
14 #include "net/base/filter.h" 14 #include "net/base/filter.h"
15 #include "net/base/load_states.h" 15 #include "net/base/load_states.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 17
18 namespace net { 18 namespace net {
19 class HttpResponseInfo; 19 class HttpResponseInfo;
20 class IOBuffer;
20 class UploadData; 21 class UploadData;
21 } 22 }
22 23
23 class GURL; 24 class GURL;
24 class URLRequest; 25 class URLRequest;
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.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 virtual void Kill(); 72 virtual void Kill();
72 73
73 // Called to detach the request from this Job. Results in the Job being 74 // Called to detach the request from this Job. Results in the Job being
74 // killed off eventually. The job must not use the request pointer any more. 75 // killed off eventually. The job must not use the request pointer any more.
75 void DetachRequest(); 76 void DetachRequest();
76 77
77 // Called to read post-filtered data from this Job, returning the number of 78 // Called to read post-filtered data from this Job, returning the number of
78 // bytes read, 0 when there is no more data, or -1 if there was an error. 79 // bytes read, 0 when there is no more data, or -1 if there was an error.
79 // This is just the backend for URLRequest::Read, see that function for more 80 // This is just the backend for URLRequest::Read, see that function for more
80 // info. 81 // info.
81 bool Read(char* buf, int buf_size, int *bytes_read); 82 bool Read(net::IOBuffer* buf, int buf_size, int *bytes_read);
82 83
83 // Called to fetch the current load state for the job. 84 // Called to fetch the current load state for the job.
84 virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } 85 virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; }
85 86
86 // Called to get the upload progress in bytes. 87 // Called to get the upload progress in bytes.
87 virtual uint64 GetUploadProgress() const { return 0; } 88 virtual uint64 GetUploadProgress() const { return 0; }
88 89
89 // Called to fetch the mime_type for this request. Only makes sense for some 90 // 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 // types of requests. Returns true on success. Calling this on a type that
91 // doesn't have a mime type will return false. 92 // doesn't have a mime type will return false.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 225
225 // Called to read raw (pre-filtered) data from this Job. 226 // Called to read raw (pre-filtered) data from this Job.
226 // If returning true, data was read from the job. buf will contain 227 // If returning true, data was read from the job. buf will contain
227 // the data, and bytes_read will receive the number of bytes read. 228 // the data, and bytes_read will receive the number of bytes read.
228 // If returning true, and bytes_read is returned as 0, there is no 229 // If returning true, and bytes_read is returned as 0, there is no
229 // additional data to be read. 230 // additional data to be read.
230 // If returning false, an error occurred or an async IO is now pending. 231 // If returning false, an error occurred or an async IO is now pending.
231 // If async IO is pending, the status of the request will be 232 // If async IO is pending, the status of the request will be
232 // URLRequestStatus::IO_PENDING, and buf must remain available until the 233 // URLRequestStatus::IO_PENDING, and buf must remain available until the
233 // operation is completed. See comments on URLRequest::Read for more info. 234 // operation is completed. See comments on URLRequest::Read for more info.
234 virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); 235 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
235 236
236 // Informs the filter that data has been read into its buffer 237 // Informs the filter that data has been read into its buffer
237 void FilteredDataRead(int bytes_read); 238 void FilteredDataRead(int bytes_read);
238 239
239 // Reads filtered data from the request. Returns true if successful, 240 // Reads filtered data from the request. Returns true if successful,
240 // false otherwise. Note, if there is not enough data received to 241 // false otherwise. Note, if there is not enough data received to
241 // return data, this call can issue a new async IO request under 242 // return data, this call can issue a new async IO request under
242 // the hood. 243 // the hood.
243 bool ReadFilteredData(int *bytes_read); 244 bool ReadFilteredData(int *bytes_read);
244 245
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // all the data or an error has been encountered. Set exclusively by 283 // all the data or an error has been encountered. Set exclusively by
283 // NotifyDone so that it is kept in sync with the request. 284 // NotifyDone so that it is kept in sync with the request.
284 bool done_; 285 bool done_;
285 286
286 // The data stream filter which is enabled on demand. 287 // The data stream filter which is enabled on demand.
287 scoped_ptr<Filter> filter_; 288 scoped_ptr<Filter> filter_;
288 // When we filter data, we receive data into the filter buffers. After 289 // When we filter data, we receive data into the filter buffers. After
289 // processing the filtered data, we return the data in the caller's buffer. 290 // processing the filtered data, we return the data in the caller's buffer.
290 // While the async IO is in progress, we save the user buffer here, and 291 // While the async IO is in progress, we save the user buffer here, and
291 // when the IO completes, we fill this in. 292 // when the IO completes, we fill this in.
292 char *read_buffer_; 293 net::IOBuffer *read_buffer_;
293 int read_buffer_len_; 294 int read_buffer_len_;
294 295
295 // Used by HandleResponseIfNecessary to track whether we've sent the 296 // Used by HandleResponseIfNecessary to track whether we've sent the
296 // OnResponseStarted callback and potentially redirect callbacks as well. 297 // OnResponseStarted callback and potentially redirect callbacks as well.
297 bool has_handled_response_; 298 bool has_handled_response_;
298 299
299 // Expected content size 300 // Expected content size
300 int64 expected_content_size_; 301 int64 expected_content_size_;
301 302
302 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); 303 DISALLOW_COPY_AND_ASSIGN(URLRequestJob);
303 }; 304 };
304 305
305 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ 306 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_
306 307
OLDNEW
« no previous file with comments | « net/url_request/url_request_inet_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698