| OLD | NEW |
| 1 // Copyright (c) 2011 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 // 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 // ResourceLoaderBridge::Peer methods: | 288 // ResourceLoaderBridge::Peer methods: |
| 289 virtual void OnUploadProgress(uint64 position, uint64 size); | 289 virtual void OnUploadProgress(uint64 position, uint64 size); |
| 290 virtual bool OnReceivedRedirect( | 290 virtual bool OnReceivedRedirect( |
| 291 const GURL& new_url, | 291 const GURL& new_url, |
| 292 const ResourceResponseInfo& info, | 292 const ResourceResponseInfo& info, |
| 293 bool* has_new_first_party_for_cookies, | 293 bool* has_new_first_party_for_cookies, |
| 294 GURL* new_first_party_for_cookies); | 294 GURL* new_first_party_for_cookies); |
| 295 virtual void OnReceivedResponse(const ResourceResponseInfo& info); | 295 virtual void OnReceivedResponse(const ResourceResponseInfo& info); |
| 296 virtual void OnDownloadedData(int len); | 296 virtual void OnDownloadedData(int len); |
| 297 virtual void OnReceivedData(const char* data, int len); | 297 virtual void OnReceivedData(const char* data, |
| 298 int data_length, |
| 299 int length_received); |
| 298 virtual void OnReceivedCachedMetadata(const char* data, int len); | 300 virtual void OnReceivedCachedMetadata(const char* data, int len); |
| 299 virtual void OnCompletedRequest(const net::URLRequestStatus& status, | 301 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
| 300 const std::string& security_info, | 302 const std::string& security_info, |
| 301 const base::Time& completion_time); | 303 const base::Time& completion_time); |
| 302 | 304 |
| 303 private: | 305 private: |
| 304 friend class base::RefCounted<Context>; | 306 friend class base::RefCounted<Context>; |
| 305 ~Context() {} | 307 ~Context() {} |
| 306 | 308 |
| 307 // We can optimize the handling of data URLs in most cases. | 309 // We can optimize the handling of data URLs in most cases. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 } | 585 } |
| 584 | 586 |
| 585 response_url_ = response.url(); | 587 response_url_ = response.url(); |
| 586 } | 588 } |
| 587 | 589 |
| 588 void WebURLLoaderImpl::Context::OnDownloadedData(int len) { | 590 void WebURLLoaderImpl::Context::OnDownloadedData(int len) { |
| 589 if (client_) | 591 if (client_) |
| 590 client_->didDownloadData(loader_, len); | 592 client_->didDownloadData(loader_, len); |
| 591 } | 593 } |
| 592 | 594 |
| 593 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, int len) { | 595 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, |
| 596 int data_length, |
| 597 int length_received) { |
| 594 if (!client_) | 598 if (!client_) |
| 595 return; | 599 return; |
| 596 | 600 |
| 597 // Temporary logging, see site_isolation_metrics.h/cc. | 601 // Temporary logging, see site_isolation_metrics.h/cc. |
| 598 SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, len); | 602 SiteIsolationMetrics::SniffCrossOriginHTML(response_url_, data, data_length); |
| 599 | 603 |
| 600 if (ftp_listing_delegate_.get()) { | 604 if (ftp_listing_delegate_.get()) { |
| 601 // The FTP listing delegate will make the appropriate calls to | 605 // The FTP listing delegate will make the appropriate calls to |
| 602 // client_->didReceiveData and client_->didReceiveResponse. | 606 // client_->didReceiveData and client_->didReceiveResponse. |
| 603 ftp_listing_delegate_->OnReceivedData(data, len); | 607 ftp_listing_delegate_->OnReceivedData(data, data_length); |
| 604 } else if (multipart_delegate_.get()) { | 608 } else if (multipart_delegate_.get()) { |
| 605 // The multipart delegate will make the appropriate calls to | 609 // The multipart delegate will make the appropriate calls to |
| 606 // client_->didReceiveData and client_->didReceiveResponse. | 610 // client_->didReceiveData and client_->didReceiveResponse. |
| 607 multipart_delegate_->OnReceivedData(data, len); | 611 multipart_delegate_->OnReceivedData(data, data_length, length_received); |
| 608 } else { | 612 } else { |
| 609 // FIXME(vsevik): rename once renamed in webkit | 613 // FIXME(vsevik): rename once renamed in webkit |
| 610 client_->didReceiveData2(loader_, data, len, -1); | 614 client_->didReceiveData2(loader_, data, data_length, length_received); |
| 611 } | 615 } |
| 612 } | 616 } |
| 613 | 617 |
| 614 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( | 618 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( |
| 615 const char* data, int len) { | 619 const char* data, int len) { |
| 616 if (client_) | 620 if (client_) |
| 617 client_->didReceiveCachedMetadata(loader_, data, len); | 621 client_->didReceiveCachedMetadata(loader_, data, len); |
| 618 } | 622 } |
| 619 | 623 |
| 620 void WebURLLoaderImpl::Context::OnCompletedRequest( | 624 void WebURLLoaderImpl::Context::OnCompletedRequest( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 691 } |
| 688 | 692 |
| 689 void WebURLLoaderImpl::Context::HandleDataURL() { | 693 void WebURLLoaderImpl::Context::HandleDataURL() { |
| 690 ResourceResponseInfo info; | 694 ResourceResponseInfo info; |
| 691 net::URLRequestStatus status; | 695 net::URLRequestStatus status; |
| 692 std::string data; | 696 std::string data; |
| 693 | 697 |
| 694 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { | 698 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { |
| 695 OnReceivedResponse(info); | 699 OnReceivedResponse(info); |
| 696 if (!data.empty()) | 700 if (!data.empty()) |
| 697 OnReceivedData(data.data(), data.size()); | 701 OnReceivedData(data.data(), data.size(), 0); |
| 698 } | 702 } |
| 699 | 703 |
| 700 OnCompletedRequest(status, info.security_info, base::Time::Now()); | 704 OnCompletedRequest(status, info.security_info, base::Time::Now()); |
| 701 } | 705 } |
| 702 | 706 |
| 703 // WebURLLoaderImpl ----------------------------------------------------------- | 707 // WebURLLoaderImpl ----------------------------------------------------------- |
| 704 | 708 |
| 705 WebURLLoaderImpl::WebURLLoaderImpl() | 709 WebURLLoaderImpl::WebURLLoaderImpl() |
| 706 : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { | 710 : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))) { |
| 707 } | 711 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 752 |
| 749 void WebURLLoaderImpl::cancel() { | 753 void WebURLLoaderImpl::cancel() { |
| 750 context_->Cancel(); | 754 context_->Cancel(); |
| 751 } | 755 } |
| 752 | 756 |
| 753 void WebURLLoaderImpl::setDefersLoading(bool value) { | 757 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 754 context_->SetDefersLoading(value); | 758 context_->SetDefersLoading(value); |
| 755 } | 759 } |
| 756 | 760 |
| 757 } // namespace webkit_glue | 761 } // namespace webkit_glue |
| OLD | NEW |