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

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

Issue 3010037: Add the actual data being read to the OnBytesRead callback, take two.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 4 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/net.gyp ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 private: 307 private:
308 // Size of filter input buffers used by this class. 308 // Size of filter input buffers used by this class.
309 static const int kFilterBufSize; 309 static const int kFilterBufSize;
310 310
311 // When data filtering is enabled, this function is used to read data 311 // When data filtering is enabled, this function is used to read data
312 // for the filter. Returns true if raw data was read. Returns false if 312 // for the filter. Returns true if raw data was read. Returns false if
313 // an error occurred (or we are waiting for IO to complete). 313 // an error occurred (or we are waiting for IO to complete).
314 bool ReadRawDataForFilter(int *bytes_read); 314 bool ReadRawDataForFilter(int *bytes_read);
315 315
316 // Invokes ReadRawData and records bytes read if the read completes
317 // synchronously.
318 bool ReadRawDataHelper(net::IOBuffer* buf, int buf_size, int* bytes_read);
319
316 // Called in response to a redirect that was not canceled to follow the 320 // Called in response to a redirect that was not canceled to follow the
317 // redirect. The current job will be replaced with a new job loading the 321 // redirect. The current job will be replaced with a new job loading the
318 // given redirect destination. 322 // given redirect destination.
319 void FollowRedirect(const GURL& location, int http_status_code); 323 void FollowRedirect(const GURL& location, int http_status_code);
320 324
321 // Updates the profiling info and notifies observers that bytes_read bytes 325 // Called after every raw read. If |bytes_read| is > 0, this indicates
322 // have been read. 326 // a successful read of |bytes_read| unfiltered bytes. If |bytes_read|
327 // is 0, this indicates that there is no additional data to read. If
328 // |bytes_read| is < 0, an error occurred and no bytes were read.
329 void OnRawReadComplete(int bytes_read);
330
331 // Updates the profiling info and notifies observers that an additional
332 // |bytes_read| unfiltered bytes have been read for this job.
323 void RecordBytesRead(int bytes_read); 333 void RecordBytesRead(int bytes_read);
324 334
325 // Called to query whether there is data available in the filter to be read 335 // Called to query whether there is data available in the filter to be read
326 // out. 336 // out.
327 bool FilterHasData(); 337 bool FilterHasData();
328 338
329 // Record packet arrival times for possible use in histograms. 339 // Record packet arrival times for possible use in histograms.
330 void UpdatePacketReadTimes(); 340 void UpdatePacketReadTimes();
331 341
332 void RecordCompressionHistograms(); 342 void RecordCompressionHistograms();
(...skipping 10 matching lines...) Expand all
343 scoped_ptr<Filter> filter_; 353 scoped_ptr<Filter> filter_;
344 354
345 // If the filter filled its output buffer, then there is a change that it 355 // If the filter filled its output buffer, then there is a change that it
346 // still has internal data to emit, and this flag is set. 356 // still has internal data to emit, and this flag is set.
347 bool filter_needs_more_output_space_; 357 bool filter_needs_more_output_space_;
348 358
349 // When we filter data, we receive data into the filter buffers. After 359 // When we filter data, we receive data into the filter buffers. After
350 // processing the filtered data, we return the data in the caller's buffer. 360 // processing the filtered data, we return the data in the caller's buffer.
351 // While the async IO is in progress, we save the user buffer here, and 361 // While the async IO is in progress, we save the user buffer here, and
352 // when the IO completes, we fill this in. 362 // when the IO completes, we fill this in.
353 scoped_refptr<net::IOBuffer> read_buffer_; 363 scoped_refptr<net::IOBuffer> filtered_read_buffer_;
354 int read_buffer_len_; 364 int filtered_read_buffer_len_;
365
366 // We keep a pointer to the read buffer while asynchronous reads are
367 // in progress, so we are able to pass those bytes to job observers.
368 scoped_refptr<net::IOBuffer> raw_read_buffer_;
355 369
356 // Used by HandleResponseIfNecessary to track whether we've sent the 370 // Used by HandleResponseIfNecessary to track whether we've sent the
357 // OnResponseStarted callback and potentially redirect callbacks as well. 371 // OnResponseStarted callback and potentially redirect callbacks as well.
358 bool has_handled_response_; 372 bool has_handled_response_;
359 373
360 // Expected content size 374 // Expected content size
361 int64 expected_content_size_; 375 int64 expected_content_size_;
362 376
363 // Set when a redirect is deferred. 377 // Set when a redirect is deferred.
364 GURL deferred_redirect_url_; 378 GURL deferred_redirect_url_;
365 int deferred_redirect_status_code_; 379 int deferred_redirect_status_code_;
366 380
367 //---------------------------------------------------------------------------- 381 //----------------------------------------------------------------------------
368 // Data used for statistics gathering in some instances. This data is only 382 // Data used for statistics gathering in some instances. This data is only
369 // used for histograms etc., and is not required. It is optionally gathered 383 // used for histograms etc., and is not required. It is optionally gathered
370 // based on the settings of several control variables. 384 // based on the settings of several control variables.
371 385
372 // Enable recording of packet arrival times for histogramming. 386 // Enable recording of packet arrival times for histogramming.
373 bool packet_timing_enabled_; 387 bool packet_timing_enabled_;
374 388
375 // TODO(jar): improve the quality of the gathered info by gathering most times 389 // TODO(jar): improve the quality of the gathered info by gathering most times
376 // at a lower point in the network stack, assuring we have actual packet 390 // at a lower point in the network stack, assuring we have actual packet
377 // boundaries, rather than approximations. Also note that input byte count 391 // boundaries, rather than approximations. Also note that input byte count
378 // as gathered here is post-SSL, and post-cache-fetch, and does not reflect 392 // as gathered here is post-SSL, and post-cache-fetch, and does not reflect
379 // true packet arrival times in such cases. 393 // true packet arrival times in such cases.
380 394
381 // Total number of bytes read from network (or cache) and and typically handed 395 // Total number of bytes read from network (or cache) and typically handed
382 // to filter to process. Used to histogram compression ratios, and error 396 // to filter to process. Used to histogram compression ratios, and error
383 // recovery scenarios in filters. 397 // recovery scenarios in filters.
384 int64 filter_input_byte_count_; 398 int64 filter_input_byte_count_;
385 399
386 // The number of bytes that have been accounted for in packets (where some of 400 // The number of bytes that have been accounted for in packets (where some of
387 // those packets may possibly have had their time of arrival recorded). 401 // those packets may possibly have had their time of arrival recorded).
388 int64 bytes_observed_in_packets_; 402 int64 bytes_observed_in_packets_;
389 403
390 // Limit on the size of the array packet_times_. This can be set to 404 // Limit on the size of the array packet_times_. This can be set to
391 // zero, and then no packet times will be gathered. 405 // zero, and then no packet times will be gathered.
(...skipping 11 matching lines...) Expand all
403 base::Time final_packet_time_; 417 base::Time final_packet_time_;
404 418
405 // The count of the number of packets, some of which may not have been timed. 419 // The count of the number of packets, some of which may not have been timed.
406 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes. 420 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes.
407 int observed_packet_count_; 421 int observed_packet_count_;
408 422
409 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); 423 DISALLOW_COPY_AND_ASSIGN(URLRequestJob);
410 }; 424 };
411 425
412 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ 426 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698