| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ | 5 #ifndef CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ |
| 6 #define CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ | 6 #define CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlcom.h> | 9 #include <atlcom.h> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Switch from [DONE] to [WORKING]. | 157 // Switch from [DONE] to [WORKING]. |
| 158 void Start() { | 158 void Start() { |
| 159 DCHECK_EQ(state_, DONE); | 159 DCHECK_EQ(state_, DONE); |
| 160 state_ = WORKING; | 160 state_ = WORKING; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Save redirection information and switch to [ABORTING] state. | 163 // Save redirection information and switch to [ABORTING] state. |
| 164 // Assumes binding_->Abort() will be called! | 164 // Assumes binding_->Abort() will be called! |
| 165 void SetRedirected(int http_code, const std::string& utf8_url) { | 165 void SetRedirected(int http_code, const std::string& utf8_url) { |
| 166 DCHECK_EQ(state_, WORKING); | 166 DCHECK_EQ(state_, WORKING); |
| 167 DCHECK_EQ(result_.status(), URLRequestStatus::SUCCESS); | 167 DCHECK_EQ(result_.status(), net::URLRequestStatus::SUCCESS); |
| 168 redirect_.utf8_url = utf8_url; | 168 redirect_.utf8_url = utf8_url; |
| 169 | 169 |
| 170 // At times we receive invalid redirect codes like 0, 200, etc. We | 170 // At times we receive invalid redirect codes like 0, 200, etc. We |
| 171 // default to 302 in this case. | 171 // default to 302 in this case. |
| 172 redirect_.http_code = http_code; | 172 redirect_.http_code = http_code; |
| 173 if (!net::HttpResponseHeaders::IsRedirectResponseCode(http_code)) | 173 if (!net::HttpResponseHeaders::IsRedirectResponseCode(http_code)) |
| 174 redirect_.http_code = 302; | 174 redirect_.http_code = 302; |
| 175 | 175 |
| 176 state_ = ABORTING; | 176 state_ = ABORTING; |
| 177 } | 177 } |
| 178 | 178 |
| 179 // Set the result as URLRequestStatus::CANCELED. | 179 // Set the result as net::URLRequestStatus::CANCELED. |
| 180 // Switch to [ABORTING] state (if not already in that state). | 180 // Switch to [ABORTING] state (if not already in that state). |
| 181 void Cancel() { | 181 void Cancel() { |
| 182 if (state_ == DONE) | 182 if (state_ == DONE) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 if (state_ == WORKING) { | 185 if (state_ == WORKING) { |
| 186 state_ = ABORTING; | 186 state_ = ABORTING; |
| 187 } else { | 187 } else { |
| 188 // state_ == ABORTING | 188 // state_ == ABORTING |
| 189 redirect_.http_code = 0; | 189 redirect_.http_code = 0; |
| 190 redirect_.utf8_url.clear(); | 190 redirect_.utf8_url.clear(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 set_result(URLRequestStatus::CANCELED, 0); | 193 set_result(net::URLRequestStatus::CANCELED, 0); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void Done() { | 196 void Done() { |
| 197 state_ = DONE; | 197 state_ = DONE; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool was_redirected() const { | 200 bool was_redirected() const { |
| 201 return redirect_.http_code != 0; | 201 return redirect_.http_code != 0; |
| 202 } | 202 } |
| 203 | 203 |
| 204 const Redirection& get_redirection() const { | 204 const Redirection& get_redirection() const { |
| 205 return redirect_; | 205 return redirect_; |
| 206 } | 206 } |
| 207 | 207 |
| 208 const URLRequestStatus& get_result() const { | 208 const net::URLRequestStatus& get_result() const { |
| 209 return result_; | 209 return result_; |
| 210 } | 210 } |
| 211 | 211 |
| 212 void set_result(URLRequestStatus::Status status, int os_error) { | 212 void set_result(net::URLRequestStatus::Status status, int os_error) { |
| 213 result_.set_status(status); | 213 result_.set_status(status); |
| 214 result_.set_os_error(os_error); | 214 result_.set_os_error(os_error); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void set_result(HRESULT hr) { | 217 void set_result(HRESULT hr) { |
| 218 result_.set_status(FAILED(hr)? URLRequestStatus::FAILED: | 218 result_.set_status(FAILED(hr)? net::URLRequestStatus::FAILED: |
| 219 URLRequestStatus::SUCCESS); | 219 net::URLRequestStatus::SUCCESS); |
| 220 result_.set_os_error(HresultToNetError(hr)); | 220 result_.set_os_error(HresultToNetError(hr)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 Redirection redirect_; | 224 Redirection redirect_; |
| 225 State state_; | 225 State state_; |
| 226 URLRequestStatus result_; | 226 net::URLRequestStatus result_; |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 Status status_; | 229 Status status_; |
| 230 ScopedComPtr<IBinding> binding_; | 230 ScopedComPtr<IBinding> binding_; |
| 231 ScopedComPtr<IMoniker> moniker_; | 231 ScopedComPtr<IMoniker> moniker_; |
| 232 ScopedComPtr<IBindCtx> bind_context_; | 232 ScopedComPtr<IBindCtx> bind_context_; |
| 233 ScopedComPtr<IStream> cache_; | 233 ScopedComPtr<IStream> cache_; |
| 234 ScopedComPtr<IStream> pending_data_; | 234 ScopedComPtr<IStream> pending_data_; |
| 235 | 235 |
| 236 size_t pending_read_size_; | 236 size_t pending_read_size_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 249 bool is_expecting_download_; | 249 bool is_expecting_download_; |
| 250 // Set to true if the Urlmon transaction object needs to be cleaned up | 250 // Set to true if the Urlmon transaction object needs to be cleaned up |
| 251 // when this object is destroyed. Happens if we return | 251 // when this object is destroyed. Happens if we return |
| 252 // INET_E_TERMINATE_BIND from OnDataAvailable in the last data notification. | 252 // INET_E_TERMINATE_BIND from OnDataAvailable in the last data notification. |
| 253 bool cleanup_transaction_; | 253 bool cleanup_transaction_; |
| 254 | 254 |
| 255 DISALLOW_COPY_AND_ASSIGN(UrlmonUrlRequest); | 255 DISALLOW_COPY_AND_ASSIGN(UrlmonUrlRequest); |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 #endif // CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ | 258 #endif // CHROME_FRAME_URLMON_URL_REQUEST_PRIVATE_H_ |
| OLD | NEW |