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

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

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 explicit URLRequestJob(URLRequest* request); 44 explicit URLRequestJob(URLRequest* request);
45 45
46 // Returns the request that owns this job. THIS POINTER MAY BE NULL if the 46 // Returns the request that owns this job. THIS POINTER MAY BE NULL if the
47 // request was destroyed. 47 // request was destroyed.
48 URLRequest* request() const { 48 URLRequest* request() const {
49 return request_; 49 return request_;
50 } 50 }
51 51
52 // Sets the upload data, most requests have no upload data, so this is a NOP. 52 // Sets the upload data, most requests have no upload data, so this is a NOP.
53 // Job types supporting upload data will override this. 53 // Job types supporting upload data will override this.
54 virtual void SetUpload(net::UploadData* upload) { } 54 virtual void SetUpload(net::UploadData* upload);
55 55
56 // Sets extra request headers for Job types that support request headers. 56 // Sets extra request headers for Job types that support request headers.
57 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) {} 57 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers);
58 58
59 // If any error occurs while starting the Job, NotifyStartError should be 59 // If any error occurs while starting the Job, NotifyStartError should be
60 // called. 60 // called.
61 // This helps ensure that all errors follow more similar notification code 61 // This helps ensure that all errors follow more similar notification code
62 // paths, which should simplify testing. 62 // paths, which should simplify testing.
63 virtual void Start() = 0; 63 virtual void Start() = 0;
64 64
65 // This function MUST somehow call NotifyDone/NotifyCanceled or some requests 65 // This function MUST somehow call NotifyDone/NotifyCanceled or some requests
66 // will get leaked. Certain callers use that message to know when they can 66 // will get leaked. Certain callers use that message to know when they can
67 // delete their URLRequest object, even when doing a cancel. The default Kill 67 // delete their URLRequest object, even when doing a cancel. The default Kill
(...skipping 23 matching lines...) Expand all
91 // bytes read, 0 when there is no more data, or -1 if there was an error. 91 // bytes read, 0 when there is no more data, or -1 if there was an error.
92 // This is just the backend for URLRequest::Read, see that function for more 92 // This is just the backend for URLRequest::Read, see that function for more
93 // info. 93 // info.
94 bool Read(net::IOBuffer* buf, int buf_size, int* bytes_read); 94 bool Read(net::IOBuffer* buf, int buf_size, int* bytes_read);
95 95
96 // Stops further caching of this request, if any. For more info, see 96 // Stops further caching of this request, if any. For more info, see
97 // URLRequest::StopCaching(). 97 // URLRequest::StopCaching().
98 virtual void StopCaching(); 98 virtual void StopCaching();
99 99
100 // Called to fetch the current load state for the job. 100 // Called to fetch the current load state for the job.
101 virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } 101 virtual net::LoadState GetLoadState() const;
102 102
103 // Called to get the upload progress in bytes. 103 // Called to get the upload progress in bytes.
104 virtual uint64 GetUploadProgress() const { return 0; } 104 virtual uint64 GetUploadProgress() const;
105 105
106 // Called to fetch the charset for this request. Only makes sense for some 106 // Called to fetch the charset for this request. Only makes sense for some
107 // types of requests. Returns true on success. Calling this on a type that 107 // types of requests. Returns true on success. Calling this on a type that
108 // doesn't have a charset will return false. 108 // doesn't have a charset will return false.
109 virtual bool GetCharset(std::string* charset) { return false; } 109 virtual bool GetCharset(std::string* charset);
110 110
111 // Called to get response info. 111 // Called to get response info.
112 virtual void GetResponseInfo(net::HttpResponseInfo* info) {} 112 virtual void GetResponseInfo(net::HttpResponseInfo* info);
113 113
114 // Returns the cookie values included in the response, if applicable. 114 // Returns the cookie values included in the response, if applicable.
115 // Returns true if applicable. 115 // Returns true if applicable.
116 // NOTE: This removes the cookies from the job, so it will only return 116 // NOTE: This removes the cookies from the job, so it will only return
117 // useful results once per job. 117 // useful results once per job.
118 virtual bool GetResponseCookies(std::vector<std::string>* cookies) { 118 virtual bool GetResponseCookies(std::vector<std::string>* cookies);
119 return false;
120 }
121 119
122 // Called to fetch the encoding types for this request. Only makes sense for 120 // Called to fetch the encoding types for this request. Only makes sense for
123 // some types of requests. Returns true on success. Calling this on a request 121 // some types of requests. Returns true on success. Calling this on a request
124 // that doesn't have or specify an encoding type will return false. 122 // that doesn't have or specify an encoding type will return false.
125 // Returns a array of strings showing the sequential encodings used on the 123 // Returns a array of strings showing the sequential encodings used on the
126 // content. 124 // content.
127 // For example, encoding_types[0] = FILTER_TYPE_SDCH and encoding_types[1] = 125 // For example, encoding_types[0] = FILTER_TYPE_SDCH and encoding_types[1] =
128 // FILTER_TYPE_GZIP, means the content was first encoded by sdch, and then 126 // FILTER_TYPE_GZIP, means the content was first encoded by sdch, and then
129 // result was encoded by gzip. To decode, a series of filters must be applied 127 // result was encoded by gzip. To decode, a series of filters must be applied
130 // in the reverse order (in the above example, ungzip first, and then sdch 128 // in the reverse order (in the above example, ungzip first, and then sdch
131 // expand). 129 // expand).
132 virtual bool GetContentEncodings( 130 virtual bool GetContentEncodings(
133 std::vector<Filter::FilterType>* encoding_types) { 131 std::vector<Filter::FilterType>* encoding_types);
134 return false;
135 }
136 132
137 // Find out if this is a download. 133 // Find out if this is a download.
138 virtual bool IsDownload() const; 134 virtual bool IsDownload() const;
139 135
140 // Find out if this is a response to a request that advertised an SDCH 136 // Find out if this is a response to a request that advertised an SDCH
141 // dictionary. Only makes sense for some types of requests. 137 // dictionary. Only makes sense for some types of requests.
142 virtual bool IsSdchResponse() const { return false; } 138 virtual bool IsSdchResponse() const;
143 139
144 // Called to setup stream filter for this request. An example of filter is 140 // Called to setup stream filter for this request. An example of filter is
145 // content encoding/decoding. 141 // content encoding/decoding.
146 void SetupFilter(); 142 void SetupFilter();
147 143
148 // Called to determine if this response is a redirect. Only makes sense 144 // Called to determine if this response is a redirect. Only makes sense
149 // for some types of requests. This method returns true if the response 145 // for some types of requests. This method returns true if the response
150 // is a redirect, and fills in the location param with the URL of the 146 // is a redirect, and fills in the location param with the URL of the
151 // redirect. The HTTP status code (e.g., 302) is filled into 147 // redirect. The HTTP status code (e.g., 302) is filled into
152 // |*http_status_code| to signify the type of redirect. 148 // |*http_status_code| to signify the type of redirect.
153 // 149 //
154 // The caller is responsible for following the redirect by setting up an 150 // The caller is responsible for following the redirect by setting up an
155 // appropriate replacement Job. Note that the redirected location may be 151 // appropriate replacement Job. Note that the redirected location may be
156 // invalid, the caller should be sure it can handle this. 152 // invalid, the caller should be sure it can handle this.
157 // 153 //
158 // The default implementation inspects the response_info_. 154 // The default implementation inspects the response_info_.
159 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); 155 virtual bool IsRedirectResponse(GURL* location, int* http_status_code);
160 156
161 // Called to determine if it is okay to redirect this job to the specified 157 // Called to determine if it is okay to redirect this job to the specified
162 // location. This may be used to implement protocol-specific restrictions. 158 // location. This may be used to implement protocol-specific restrictions.
163 // If this function returns false, then the URLRequest will fail reporting 159 // If this function returns false, then the URLRequest will fail reporting
164 // net::ERR_UNSAFE_REDIRECT. 160 // net::ERR_UNSAFE_REDIRECT.
165 virtual bool IsSafeRedirect(const GURL& location) { 161 virtual bool IsSafeRedirect(const GURL& location);
166 return true;
167 }
168 162
169 // Called to determine if this response is asking for authentication. Only 163 // Called to determine if this response is asking for authentication. Only
170 // makes sense for some types of requests. The caller is responsible for 164 // makes sense for some types of requests. The caller is responsible for
171 // obtaining the credentials passing them to SetAuth. 165 // obtaining the credentials passing them to SetAuth.
172 virtual bool NeedsAuth() { return false; } 166 virtual bool NeedsAuth();
173 167
174 // Fills the authentication info with the server's response. 168 // Fills the authentication info with the server's response.
175 virtual void GetAuthChallengeInfo( 169 virtual void GetAuthChallengeInfo(
176 scoped_refptr<net::AuthChallengeInfo>* auth_info); 170 scoped_refptr<net::AuthChallengeInfo>* auth_info);
177 171
178 // Resend the request with authentication credentials. 172 // Resend the request with authentication credentials.
179 virtual void SetAuth(const std::wstring& username, 173 virtual void SetAuth(const std::wstring& username,
180 const std::wstring& password); 174 const std::wstring& password);
181 175
182 // Display the error page without asking for credentials again. 176 // Display the error page without asking for credentials again.
(...skipping 22 matching lines...) Expand all
205 int64 expected_content_size() const { return expected_content_size_; } 199 int64 expected_content_size() const { return expected_content_size_; }
206 void set_expected_content_size(const int64& size) { 200 void set_expected_content_size(const int64& size) {
207 expected_content_size_ = size; 201 expected_content_size_ = size;
208 } 202 }
209 203
210 // Whether we have processed the response for that request yet. 204 // Whether we have processed the response for that request yet.
211 bool has_response_started() const { return has_handled_response_; } 205 bool has_response_started() const { return has_handled_response_; }
212 206
213 // FilterContext methods: 207 // FilterContext methods:
214 // These methods are not applicable to all connections. 208 // These methods are not applicable to all connections.
215 virtual bool GetMimeType(std::string* mime_type) const { return false; } 209 virtual bool GetMimeType(std::string* mime_type) const;
216 virtual bool GetURL(GURL* gurl) const; 210 virtual bool GetURL(GURL* gurl) const;
217 virtual base::Time GetRequestTime() const; 211 virtual base::Time GetRequestTime() const;
218 virtual bool IsCachedContent() const { return false; } 212 virtual bool IsCachedContent() const;
219 virtual int64 GetByteReadCount() const; 213 virtual int64 GetByteReadCount() const;
220 virtual int GetResponseCode() const { return -1; } 214 virtual int GetResponseCode() const;
221 virtual int GetInputStreamBufferSize() const { return kFilterBufSize; } 215 virtual int GetInputStreamBufferSize() const;
222 virtual void RecordPacketStats(StatisticSelector statistic) const; 216 virtual void RecordPacketStats(StatisticSelector statistic) const;
223 217
224 protected: 218 protected:
225 friend class base::RefCountedThreadSafe<URLRequestJob>; 219 friend class base::RefCountedThreadSafe<URLRequestJob>;
226 virtual ~URLRequestJob(); 220 virtual ~URLRequestJob();
227 221
228 // Notifies the job that headers have been received. 222 // Notifies the job that headers have been received.
229 void NotifyHeadersComplete(); 223 void NotifyHeadersComplete();
230 224
231 // Notifies the request that the job has completed a Read operation. 225 // Notifies the request that the job has completed a Read operation.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 base::Time final_packet_time_; 401 base::Time final_packet_time_;
408 402
409 // The count of the number of packets, some of which may not have been timed. 403 // The count of the number of packets, some of which may not have been timed.
410 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes. 404 // We're ignoring overflow, as 1430 x 2^31 is a LOT of bytes.
411 int observed_packet_count_; 405 int observed_packet_count_;
412 406
413 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); 407 DISALLOW_COPY_AND_ASSIGN(URLRequestJob);
414 }; 408 };
415 409
416 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ 410 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_
OLDNEW
« base/tracked.h ('K') | « net/base/filter.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698