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_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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // still present to assist in calculations. This is used by URLRequestHttpJob | 330 // still present to assist in calculations. This is used by URLRequestHttpJob |
331 // to get SDCH to emit stats. | 331 // to get SDCH to emit stats. |
332 void DestroyFilters(); | 332 void DestroyFilters(); |
333 | 333 |
334 // Provides derived classes with access to the request's network delegate. | 334 // Provides derived classes with access to the request's network delegate. |
335 NetworkDelegate* network_delegate() { return network_delegate_; } | 335 NetworkDelegate* network_delegate() { return network_delegate_; } |
336 | 336 |
337 // The status of the job. | 337 // The status of the job. |
338 const URLRequestStatus GetStatus(); | 338 const URLRequestStatus GetStatus(); |
339 | 339 |
340 // Set the status of the job. | |
341 void SetStatus(const URLRequestStatus& status); | |
342 | |
343 // Set the proxy server that was used, if any. | 340 // Set the proxy server that was used, if any. |
344 void SetProxyServer(const HostPortPair& proxy_server); | 341 void SetProxyServer(const HostPortPair& proxy_server); |
345 | 342 |
346 // The number of bytes read before passing to the filter. This value reflects | 343 // The number of bytes read before passing to the filter. This value reflects |
347 // bytes read even when there is no filter. | 344 // bytes read even when there is no filter. |
348 int64_t prefilter_bytes_read() const { return prefilter_bytes_read_; } | 345 int64_t prefilter_bytes_read() const { return prefilter_bytes_read_; } |
349 | 346 |
350 // The number of bytes read after passing through the filter. This value | 347 // The number of bytes read after passing through the filter. This value |
351 // reflects bytes read even when there is no filter. | 348 // reflects bytes read even when there is no filter. |
352 int64_t postfilter_bytes_read() const { return postfilter_bytes_read_; } | 349 int64_t postfilter_bytes_read() const { return postfilter_bytes_read_; } |
353 | 350 |
354 // Turns an integer result code into an Error and a count of bytes read. | 351 // Turns an integer result code into an Error and a count of bytes read. |
355 // The semantics are: | 352 // The semantics are: |
356 // |result| >= 0: |*error| == OK, |*count| == |result| | 353 // |result| >= 0: |*error| == OK, |*count| == |result| |
357 // |result| < 0: |*error| = |result|, |*count| == 0 | 354 // |result| < 0: |*error| = |result|, |*count| == 0 |
358 static void ConvertResultToError(int result, Error* error, int* count); | 355 static void ConvertResultToError(int result, Error* error, int* count); |
359 | 356 |
360 // Completion callback for raw reads. See |ReadRawData| for details. | 357 // Completion callback for raw reads. See |ReadRawData| for details. |
361 // |bytes_read| is either >= 0 to indicate a successful read and count of | 358 // |bytes_read| is either >= 0 to indicate a successful read and count of |
362 // bytes read, or < 0 to indicate an error. | 359 // bytes read, or < 0 to indicate an error. |
363 void ReadRawDataComplete(int bytes_read); | 360 void ReadRawDataComplete(int bytes_read); |
364 | 361 |
365 // The request that initiated this job. This value will never be nullptr. | 362 // The request that initiated this job. This value will never be nullptr. |
366 URLRequest* request_; | 363 URLRequest* request_; |
367 | 364 |
368 private: | 365 private: |
| 366 // Set the status of the associated URLRequest. |
| 367 // TODO(mmenke): Make the URLRequest manage its own status. |
| 368 void SetStatus(const URLRequestStatus& status); |
| 369 |
369 // When data filtering is enabled, this function is used to read data | 370 // When data filtering is enabled, this function is used to read data |
370 // for the filter. Returns a net error code to indicate if raw data was | 371 // for the filter. Returns a net error code to indicate if raw data was |
371 // successfully read, an error happened, or the IO is pending. | 372 // successfully read, an error happened, or the IO is pending. |
372 Error ReadRawDataForFilter(int* bytes_read); | 373 Error ReadRawDataForFilter(int* bytes_read); |
373 | 374 |
374 // Informs the filter chain that data has been read into its buffer. | 375 // Informs the filter chain that data has been read into its buffer. |
375 void PushInputToFilter(int bytes_read); | 376 void PushInputToFilter(int bytes_read); |
376 | 377 |
377 // Invokes ReadRawData and records bytes read if the read completes | 378 // Invokes ReadRawData and records bytes read if the read completes |
378 // synchronously. | 379 // synchronously. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 int64_t last_notified_total_sent_bytes_; | 472 int64_t last_notified_total_sent_bytes_; |
472 | 473 |
473 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 474 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
474 | 475 |
475 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 476 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
476 }; | 477 }; |
477 | 478 |
478 } // namespace net | 479 } // namespace net |
479 | 480 |
480 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 481 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
OLD | NEW |