| OLD | NEW |
| 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
| 6 | 6 |
| 7 #include "webkit/glue/weburlloader_impl.h" | 7 #include "webkit/glue/weburlloader_impl.h" |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 *status = URLRequestStatus(URLRequestStatus::FAILED, net::ERR_INVALID_URL); | 157 *status = URLRequestStatus(URLRequestStatus::FAILED, net::ERR_INVALID_URL); |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void PopulateURLResponse( | 161 void PopulateURLResponse( |
| 162 const GURL& url, | 162 const GURL& url, |
| 163 const ResourceLoaderBridge::ResponseInfo& info, | 163 const ResourceLoaderBridge::ResponseInfo& info, |
| 164 WebURLResponse* response) { | 164 WebURLResponse* response) { |
| 165 response->setURL(url); | 165 response->setURL(url); |
| 166 response->setResponseTime(info.response_time.ToDoubleT()); |
| 166 response->setMIMEType(WebString::fromUTF8(info.mime_type)); | 167 response->setMIMEType(WebString::fromUTF8(info.mime_type)); |
| 167 response->setTextEncodingName(WebString::fromUTF8(info.charset)); | 168 response->setTextEncodingName(WebString::fromUTF8(info.charset)); |
| 168 response->setExpectedContentLength(info.content_length); | 169 response->setExpectedContentLength(info.content_length); |
| 169 response->setSecurityInfo(info.security_info); | 170 response->setSecurityInfo(info.security_info); |
| 170 response->setAppCacheID(info.appcache_id); | 171 response->setAppCacheID(info.appcache_id); |
| 171 response->setAppCacheManifestURL(info.appcache_manifest_url); | 172 response->setAppCacheManifestURL(info.appcache_manifest_url); |
| 172 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); | 173 response->setWasFetchedViaSPDY(info.was_fetched_via_spdy); |
| 173 | 174 |
| 174 const net::HttpResponseHeaders* headers = info.headers; | 175 const net::HttpResponseHeaders* headers = info.headers; |
| 175 if (!headers) | 176 if (!headers) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // ResourceLoaderBridge::Peer methods: | 226 // ResourceLoaderBridge::Peer methods: |
| 226 virtual void OnUploadProgress(uint64 position, uint64 size); | 227 virtual void OnUploadProgress(uint64 position, uint64 size); |
| 227 virtual bool OnReceivedRedirect( | 228 virtual bool OnReceivedRedirect( |
| 228 const GURL& new_url, | 229 const GURL& new_url, |
| 229 const ResourceLoaderBridge::ResponseInfo& info, | 230 const ResourceLoaderBridge::ResponseInfo& info, |
| 230 bool* has_new_first_party_for_cookies, | 231 bool* has_new_first_party_for_cookies, |
| 231 GURL* new_first_party_for_cookies); | 232 GURL* new_first_party_for_cookies); |
| 232 virtual void OnReceivedResponse( | 233 virtual void OnReceivedResponse( |
| 233 const ResourceLoaderBridge::ResponseInfo& info, bool content_filtered); | 234 const ResourceLoaderBridge::ResponseInfo& info, bool content_filtered); |
| 234 virtual void OnReceivedData(const char* data, int len); | 235 virtual void OnReceivedData(const char* data, int len); |
| 236 virtual void OnReceivedCachedMetadata(const char* data, int len); |
| 235 virtual void OnCompletedRequest( | 237 virtual void OnCompletedRequest( |
| 236 const URLRequestStatus& status, const std::string& security_info); | 238 const URLRequestStatus& status, const std::string& security_info); |
| 237 virtual GURL GetURLForDebugging() const; | 239 virtual GURL GetURLForDebugging() const; |
| 238 | 240 |
| 239 private: | 241 private: |
| 240 friend class base::RefCounted<Context>; | 242 friend class base::RefCounted<Context>; |
| 241 ~Context() {} | 243 ~Context() {} |
| 242 | 244 |
| 243 void HandleDataURL(); | 245 void HandleDataURL(); |
| 244 | 246 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 ftp_listing_delegate_->OnReceivedData(data, len); | 527 ftp_listing_delegate_->OnReceivedData(data, len); |
| 526 } else if (multipart_delegate_.get()) { | 528 } else if (multipart_delegate_.get()) { |
| 527 // The multipart delegate will make the appropriate calls to | 529 // The multipart delegate will make the appropriate calls to |
| 528 // client_->didReceiveData and client_->didReceiveResponse. | 530 // client_->didReceiveData and client_->didReceiveResponse. |
| 529 multipart_delegate_->OnReceivedData(data, len); | 531 multipart_delegate_->OnReceivedData(data, len); |
| 530 } else { | 532 } else { |
| 531 client_->didReceiveData(loader_, data, len); | 533 client_->didReceiveData(loader_, data, len); |
| 532 } | 534 } |
| 533 } | 535 } |
| 534 | 536 |
| 537 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( |
| 538 const char* data, int len) { |
| 539 if (client_) |
| 540 client_->didReceiveCachedMetadata(loader_, data, len); |
| 541 } |
| 542 |
| 535 void WebURLLoaderImpl::Context::OnCompletedRequest( | 543 void WebURLLoaderImpl::Context::OnCompletedRequest( |
| 536 const URLRequestStatus& status, | 544 const URLRequestStatus& status, |
| 537 const std::string& security_info) { | 545 const std::string& security_info) { |
| 538 if (ftp_listing_delegate_.get()) { | 546 if (ftp_listing_delegate_.get()) { |
| 539 ftp_listing_delegate_->OnCompletedRequest(); | 547 ftp_listing_delegate_->OnCompletedRequest(); |
| 540 ftp_listing_delegate_.reset(NULL); | 548 ftp_listing_delegate_.reset(NULL); |
| 541 } else if (multipart_delegate_.get()) { | 549 } else if (multipart_delegate_.get()) { |
| 542 multipart_delegate_->OnCompletedRequest(); | 550 multipart_delegate_->OnCompletedRequest(); |
| 543 multipart_delegate_.reset(NULL); | 551 multipart_delegate_.reset(NULL); |
| 544 } | 552 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 | 648 |
| 641 void WebURLLoaderImpl::cancel() { | 649 void WebURLLoaderImpl::cancel() { |
| 642 context_->Cancel(); | 650 context_->Cancel(); |
| 643 } | 651 } |
| 644 | 652 |
| 645 void WebURLLoaderImpl::setDefersLoading(bool value) { | 653 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 646 context_->SetDefersLoading(value); | 654 context_->SetDefersLoading(value); |
| 647 } | 655 } |
| 648 | 656 |
| 649 } // namespace webkit_glue | 657 } // namespace webkit_glue |
| OLD | NEW |