15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NET_URL_REQUEST_URL_REQUEST_JOB_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h" 149ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch#include "base/message_loop/message_loop.h" 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/power_monitor/power_observer.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/host_port_pair.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/load_states.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/net_export.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/base/request_priority.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/upload_progress.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/cookies/canonical_cookie.h" 226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "net/url_request/redirect_info.h" 237dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net { 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AuthChallengeInfo; 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AuthCredentials; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CookieOptions; 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class CookieStore; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Filter; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HttpRequestHeaders; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HttpResponseInfo; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class IOBuffer; 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct LoadTimingInfo; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class NetworkDelegate; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SSLCertRequestInfo; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SSLInfo; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class URLRequest; 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class UploadDataStream; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class URLRequestStatus; 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class X509Certificate; 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class NET_EXPORT URLRequestJob 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) : public base::RefCounted<URLRequestJob>, 46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public base::PowerObserver { 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit URLRequestJob(URLRequest* request, 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NetworkDelegate* network_delegate); 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the request that owns this job. THIS POINTER MAY BE NULL if the 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // request was destroyed. 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) URLRequest* request() const { 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return request_; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the upload data, most requests have no upload data, so this is a NOP. 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Job types supporting upload data will override this. 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetUpload(UploadDataStream* upload_data_stream); 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Sets extra request headers for Job types that support request 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // headers. Called once before Start() is called. 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetExtraRequestHeaders(const HttpRequestHeaders& headers); 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Sets the priority of the job. Called once before Start() is 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // called, but also when the priority of the parent request changes. 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetPriority(RequestPriority priority); 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If any error occurs while starting the Job, NotifyStartError should be 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // called. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This helps ensure that all errors follow more similar notification code 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // paths, which should simplify testing. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Start() = 0; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This function MUST somehow call NotifyDone/NotifyCanceled or some requests 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // will get leaked. Certain callers use that message to know when they can 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // delete their URLRequest object, even when doing a cancel. The default 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Kill implementation calls NotifyCanceled, so it is recommended that 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // subclasses call URLRequestJob::Kill() after doing any additional work. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The job should endeavor to stop working as soon as is convenient, but must 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not send and complete notifications from inside this function. Instead, 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // complete notifications (including "canceled") should be sent from a 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // callback run from the message loop. 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The job is not obliged to immediately stop sending data in response to 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // this call, nor is it obliged to fail with "canceled" unless not all data 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was sent as a result. A typical case would be where the job is almost 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // complete and can succeed before the canceled notification can be 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // dispatched (from the message loop). 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The job should be prepared to receive multiple calls to kill it, but only 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // one notification must be issued. 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Kill(); 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to detach the request from this Job. Results in the Job being 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // killed off eventually. The job must not use the request pointer any more. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DetachRequest(); 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to read post-filtered data from this Job, returning the number of 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bytes read, 0 when there is no more data, or -1 if there was an error. 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is just the backend for URLRequest::Read, see that function for 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // more info. 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool Read(IOBuffer* buf, int buf_size, int* bytes_read); 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stops further caching of this request, if any. For more info, see 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // URLRequest::StopCaching(). 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void StopCaching(); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 110eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch virtual bool GetFullRequestHeaders(HttpRequestHeaders* headers) const; 111eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Get the number of bytes received from network. 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual int64 GetTotalReceivedBytes() const; 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to fetch the current load state for the job. 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual LoadState GetLoadState() const; 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to get the upload progress in bytes. 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual UploadProgress GetUploadProgress() const; 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to fetch the charset for this request. Only makes sense for some 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // types of requests. Returns true on success. Calling this on a type that 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // doesn't have a charset will return false. 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetCharset(std::string* charset); 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to get response info. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetResponseInfo(HttpResponseInfo* info); 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 129c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // This returns the times when events actually occurred, rather than the time 130c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // each event blocked the request. See FixupLoadTimingInfo in url_request.h 131c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // for more information on the difference. 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const; 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the cookie values included in the response, if applicable. 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if applicable. 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: This removes the cookies from the job, so it will only return 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // useful results once per job. 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetResponseCookies(std::vector<std::string>* cookies); 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to setup a stream filter for this request. An example of filter is 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // content encoding/decoding. 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Subclasses should return the appropriate Filter, or NULL for no Filter. 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This class takes ownership of the returned Filter. 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The default implementation returns NULL. 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual Filter* SetupFilter() const; 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to determine if this response is a redirect. Only makes sense 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for some types of requests. This method returns true if the response 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is a redirect, and fills in the location param with the URL of the 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // redirect. The HTTP status code (e.g., 302) is filled into 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |*http_status_code| to signify the type of redirect. 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The caller is responsible for following the redirect by setting up an 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // appropriate replacement Job. Note that the redirected location may be 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // invalid, the caller should be sure it can handle this. 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The default implementation inspects the response_info_. 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsRedirectResponse(GURL* location, int* http_status_code); 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 161c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Called to determine if it is okay to copy the reference fragment from the 162c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // original URL (if existent) to the redirection target when the redirection 163c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // target has no reference fragment. 164c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // 165c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The default implementation returns true. 166c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual bool CopyFragmentOnRedirect(const GURL& location) const; 167c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to determine if it is okay to redirect this job to the specified 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // location. This may be used to implement protocol-specific restrictions. 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this function returns false, then the URLRequest will fail 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // reporting ERR_UNSAFE_REDIRECT. 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool IsSafeRedirect(const GURL& location); 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to determine if this response is asking for authentication. Only 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // makes sense for some types of requests. The caller is responsible for 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // obtaining the credentials passing them to SetAuth. 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool NeedsAuth(); 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Fills the authentication info with the server's response. 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetAuthChallengeInfo( 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<AuthChallengeInfo>* auth_info); 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Resend the request with authentication credentials. 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetAuth(const AuthCredentials& credentials); 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Display the error page without asking for credentials again. 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void CancelAuth(); 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ContinueWithCertificate(X509Certificate* client_cert); 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Continue processing the request ignoring the last error. 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ContinueDespiteLastError(); 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Continue with the network request. 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void ResumeNetworkStart(); 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void FollowDeferredRedirect(); 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the Job is done producing response data and has called 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyDone on the request. 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_done() const { return done_; } 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Get/Set expected content size 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 expected_content_size() const { return expected_content_size_; } 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_expected_content_size(const int64& size) { 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) expected_content_size_ = size; 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether we have processed the response for that request yet. 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_response_started() const { return has_handled_response_; } 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These methods are not applicable to all connections. 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetMimeType(std::string* mime_type) const; 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetResponseCode() const; 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the socket address for the connection. 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See url_request.h for details. 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual HostPortPair GetSocketAddress() const; 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 220c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // base::PowerObserver methods: 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We invoke URLRequestJob::Kill on suspend (crbug.com/4606). 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnSuspend() OVERRIDE; 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called after a NetworkDelegate has been informed that the URLRequest 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // will be destroyed. This is used to track that no pending callbacks 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // exist at destruction time of the URLRequestJob, unless they have been 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // canceled by an explicit NetworkDelegate::NotifyURLRequestDestroyed() call. 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void NotifyURLRequestDestroyed(); 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class base::RefCounted<URLRequestJob>; 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~URLRequestJob(); 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the job that a certificate is requested. 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyCertificateRequested(SSLCertRequestInfo* cert_request_info); 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the job about an SSL certificate error. 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifySSLCertificateError(const SSLInfo& ssl_info, bool fatal); 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Delegates to URLRequest::Delegate. 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool CanGetCookies(const CookieList& cookie_list) const; 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Delegates to URLRequest::Delegate. 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool CanSetCookie(const std::string& cookie_line, 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CookieOptions* options) const; 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 24790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Delegates to URLRequest::Delegate. 24890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool CanEnablePrivacyMode() const; 24990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the cookie store to be used for the request. 251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CookieStore* GetCookieStore() const; 252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Notifies the job that the network is about to be used. 2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void NotifyBeforeNetworkStart(bool* defer); 2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the job that headers have been received. 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyHeadersComplete(); 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the request that the job has completed a Read operation. 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyReadComplete(int bytes_read); 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the request that a start error has occurred. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyStartError(const URLRequestStatus& status); 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyDone marks when we are done with a request. It is really 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a glorified set_status, but also does internal state checking and 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // job tracking. It should be called once per request, when the job is 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // finished doing all IO. 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyDone(const URLRequestStatus& status); 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Some work performed by NotifyDone must be completed on a separate task 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // so as to avoid re-entering the delegate. This method exists to perform 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that work. 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CompleteNotifyDone(); 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used as an asynchronous callback for Kill to notify the URLRequest 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // that we were canceled. 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyCanceled(); 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the job the request should be restarted. 2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Should only be called if the job has not started a response. 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NotifyRestartRequired(); 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // See corresponding functions in url_request.h. 2851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void OnCallToDelegate(); 2861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void OnCallToDelegateComplete(); 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to read raw (pre-filtered) data from this Job. 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If returning true, data was read from the job. buf will contain 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the data, and bytes_read will receive the number of bytes read. 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If returning true, and bytes_read is returned as 0, there is no 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // additional data to be read. 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If returning false, an error occurred or an async IO is now pending. 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If async IO is pending, the status of the request will be 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // URLRequestStatus::IO_PENDING, and buf must remain available until the 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // operation is completed. See comments on URLRequest::Read for more 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // info. 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to tell the job that a filter has successfully reached the end of 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the stream. 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void DoneReading(); 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 304effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Called to tell the job that the body won't be read because it's a redirect. 305effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // This is needed so that redirect headers can be cached even though their 306effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // bodies are never read. 307effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void DoneReadingRedirectResponse(); 308effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Informs the filter that data has been read into its buffer 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void FilteredDataRead(int bytes_read); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Reads filtered data from the request. Returns true if successful, 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // false otherwise. Note, if there is not enough data received to 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // return data, this call can issue a new async IO request under 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the hood. 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ReadFilteredData(int *bytes_read); 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the response is being filtered in this job. 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Only valid after NotifyHeadersComplete() has been called. 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool HasFilter() { return filter_ != NULL; } 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // At or near destruction time, a derived class may request that the filters 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be destroyed so that statistics can be gathered while the derived class is 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // still present to assist in calculations. This is used by URLRequestHttpJob 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to get SDCH to emit stats. 3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void DestroyFilters(); 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Provides derived classes with access to the request's network delegate. 3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NetworkDelegate* network_delegate() { return network_delegate_; } 3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The status of the job. 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const URLRequestStatus GetStatus(); 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set the status of the job. 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetStatus(const URLRequestStatus& status); 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 337f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) // Set the proxy server that was used, if any. 338f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) void SetProxyServer(const HostPortPair& proxy_server); 339f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The number of bytes read before passing to the filter. 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int prefilter_bytes_read() const { return prefilter_bytes_read_; } 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The number of bytes read after passing through the filter. 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int postfilter_bytes_read() const { return postfilter_bytes_read_; } 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Total number of bytes read from network (or cache) and typically handed 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to filter to process. Used to histogram compression ratios, and error 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // recovery scenarios in filters. 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 filter_input_byte_count() const { return filter_input_byte_count_; } 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The request that initiated this job. This value MAY BE NULL if the 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // request was released by DetachRequest(). 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) URLRequest* request_; 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // When data filtering is enabled, this function is used to read data 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // for the filter. Returns true if raw data was read. Returns false if 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // an error occurred (or we are waiting for IO to complete). 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ReadRawDataForFilter(int *bytes_read); 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Invokes ReadRawData and records bytes read if the read completes 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // synchronously. 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called in response to a redirect that was not canceled to follow the 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // redirect. The current job will be replaced with a new job loading the 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // given redirect destination. 3686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) void FollowRedirect(const RedirectInfo& redirect_info); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called after every raw read. If |bytes_read| is > 0, this indicates 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // is 0, this indicates that there is no additional data to read. If 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |bytes_read| is < 0, an error occurred and no bytes were read. 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnRawReadComplete(int bytes_read); 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Updates the profiling info and notifies observers that an additional 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |bytes_read| unfiltered bytes have been read for this job. 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RecordBytesRead(int bytes_read); 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called to query whether there is data available in the filter to be read 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // out. 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool FilterHasData(); 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Subclasses may implement this method to record packet arrival times. 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The default implementation does nothing. 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdatePacketReadTimes(); 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Computes a new RedirectInfo based on receiving a redirect response of 3896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // |location| and |http_status_code|. 3906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); 3916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Indicates that the job is done producing data, either it has completed 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // all the data or an error has been encountered. Set exclusively by 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NotifyDone so that it is kept in sync with the request. 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool done_; 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int prefilter_bytes_read_; 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int postfilter_bytes_read_; 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 filter_input_byte_count_; 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The data stream filter which is enabled on demand. 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_ptr<Filter> filter_; 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the filter filled its output buffer, then there is a change that it 4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // still has internal data to emit, and this flag is set. 4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool filter_needs_more_output_space_; 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // When we filter data, we receive data into the filter buffers. After 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // processing the filtered data, we return the data in the caller's buffer. 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // While the async IO is in progress, we save the user buffer here, and 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // when the IO completes, we fill this in. 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<IOBuffer> filtered_read_buffer_; 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int filtered_read_buffer_len_; 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We keep a pointer to the read buffer while asynchronous reads are 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in progress, so we are able to pass those bytes to job observers. 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<IOBuffer> raw_read_buffer_; 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used by HandleResponseIfNecessary to track whether we've sent the 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // OnResponseStarted callback and potentially redirect callbacks as well. 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool has_handled_response_; 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Expected content size 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 expected_content_size_; 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set when a redirect is deferred. 4276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) RedirectInfo deferred_redirect_info_; 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The network delegate to use with this request, if any. 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NetworkDelegate* network_delegate_; 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::WeakPtrFactory<URLRequestJob> weak_factory_; 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(URLRequestJob); 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace net 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ 440