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

Side by Side Diff: webkit/glue/weburlloader_impl.cc

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: hack, hack, hack Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 297 virtual void OnReceivedData(const char* data,
298 int data_length, 298 int data_length,
299 int encoded_data_length); 299 int encoded_data_length);
300 virtual void OnReceivedCachedMetadata(const char* data, int len); 300 virtual void OnReceivedCachedMetadata(const char* data, int len);
301 virtual void OnCompletedRequest(const net::URLRequestStatus& status, 301 virtual void OnCompletedRequest(const net::URLRequestStatus& status,
302 bool handled_externally,
302 const std::string& security_info, 303 const std::string& security_info,
303 const base::TimeTicks& completion_time); 304 const base::TimeTicks& completion_time);
304 305
305 private: 306 private:
306 friend class base::RefCounted<Context>; 307 friend class base::RefCounted<Context>;
307 ~Context() {} 308 ~Context() {}
308 309
309 // We can optimize the handling of data URLs in most cases. 310 // We can optimize the handling of data URLs in most cases.
310 bool CanHandleDataURL(const GURL& url) const; 311 bool CanHandleDataURL(const GURL& url) const;
311 void HandleDataURL(); 312 void HandleDataURL();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 618 }
618 619
619 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 620 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
620 const char* data, int len) { 621 const char* data, int len) {
621 if (client_) 622 if (client_)
622 client_->didReceiveCachedMetadata(loader_, data, len); 623 client_->didReceiveCachedMetadata(loader_, data, len);
623 } 624 }
624 625
625 void WebURLLoaderImpl::Context::OnCompletedRequest( 626 void WebURLLoaderImpl::Context::OnCompletedRequest(
626 const net::URLRequestStatus& status, 627 const net::URLRequestStatus& status,
628 bool handled_externally,
627 const std::string& security_info, 629 const std::string& security_info,
628 const base::TimeTicks& completion_time) { 630 const base::TimeTicks& completion_time) {
629 if (ftp_listing_delegate_.get()) { 631 if (ftp_listing_delegate_.get()) {
630 ftp_listing_delegate_->OnCompletedRequest(); 632 ftp_listing_delegate_->OnCompletedRequest();
631 ftp_listing_delegate_.reset(NULL); 633 ftp_listing_delegate_.reset(NULL);
632 } else if (multipart_delegate_.get()) { 634 } else if (multipart_delegate_.get()) {
633 multipart_delegate_->OnCompletedRequest(); 635 multipart_delegate_->OnCompletedRequest();
634 multipart_delegate_.reset(NULL); 636 multipart_delegate_.reset(NULL);
635 } 637 }
636 638
637 // Prevent any further IPC to the browser now that we're complete, but 639 // Prevent any further IPC to the browser now that we're complete, but
638 // don't delete it to keep any downloaded temp files alive. 640 // don't delete it to keep any downloaded temp files alive.
639 DCHECK(!completed_bridge_.get()); 641 DCHECK(!completed_bridge_.get());
640 completed_bridge_.swap(bridge_); 642 completed_bridge_.swap(bridge_);
641 643
642 if (client_) { 644 if (client_) {
643 if (status.status() != net::URLRequestStatus::SUCCESS) { 645 if (status.status() != net::URLRequestStatus::SUCCESS) {
644 int error_code;
645 if (status.status() == net::URLRequestStatus::HANDLED_EXTERNALLY) {
646 // By marking this request as aborted we insure that we don't navigate
647 // to an error page.
648 error_code = net::ERR_ABORTED;
649 } else {
650 error_code = status.error();
651 }
652 WebURLError error; 646 WebURLError error;
653 if (error_code == net::ERR_ABORTED) { 647 if (status.error() == net::ERR_ABORTED) {
654 error.isCancellation = true; 648 error.isCancellation = true;
655 } else if (error_code == net::ERR_TEMPORARILY_THROTTLED) { 649 } else if (status.error() == net::ERR_TEMPORARILY_THROTTLED) {
656 error.localizedDescription = WebString::fromUTF8( 650 error.localizedDescription = WebString::fromUTF8(
657 kThrottledErrorDescription); 651 kThrottledErrorDescription);
658 } 652 }
659 error.domain = WebString::fromUTF8(net::kErrorDomain); 653 error.domain = WebString::fromUTF8(
660 error.reason = error_code; 654 handled_externally ? "ext" : net::kErrorDomain);
655 error.reason = status.error();
661 error.unreachableURL = request_.url(); 656 error.unreachableURL = request_.url();
662 client_->didFail(loader_, error); 657 client_->didFail(loader_, error);
663 } else { 658 } else {
664 client_->didFinishLoading( 659 client_->didFinishLoading(
665 loader_, (completion_time - TimeTicks()).InSecondsF()); 660 loader_, (completion_time - TimeTicks()).InSecondsF());
666 } 661 }
667 } 662 }
668 663
669 // We are done with the bridge now, and so we need to release the reference 664 // We are done with the bridge now, and so we need to release the reference
670 // to ourselves that we took on behalf of the bridge. This may cause our 665 // to ourselves that we took on behalf of the bridge. This may cause our
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 ResourceResponseInfo info; 701 ResourceResponseInfo info;
707 net::URLRequestStatus status; 702 net::URLRequestStatus status;
708 std::string data; 703 std::string data;
709 704
710 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { 705 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) {
711 OnReceivedResponse(info); 706 OnReceivedResponse(info);
712 if (!data.empty()) 707 if (!data.empty())
713 OnReceivedData(data.data(), data.size(), 0); 708 OnReceivedData(data.data(), data.size(), 0);
714 } 709 }
715 710
716 OnCompletedRequest(status, info.security_info, base::TimeTicks::Now()); 711 OnCompletedRequest(status, false, info.security_info,
712 base::TimeTicks::Now());
717 } 713 }
718 714
719 // WebURLLoaderImpl ----------------------------------------------------------- 715 // WebURLLoaderImpl -----------------------------------------------------------
720 716
721 WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform) 717 WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform)
722 : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))), 718 : ALLOW_THIS_IN_INITIALIZER_LIST(context_(new Context(this))),
723 platform_(platform) { 719 platform_(platform) {
724 } 720 }
725 721
726 WebURLLoaderImpl::~WebURLLoaderImpl() { 722 WebURLLoaderImpl::~WebURLLoaderImpl() {
727 cancel(); 723 cancel();
728 } 724 }
729 725
730 void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request, 726 void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request,
731 WebURLResponse& response, 727 WebURLResponse& response,
732 WebURLError& error, 728 WebURLError& error,
733 WebData& data) { 729 WebData& data) {
734 ResourceLoaderBridge::SyncLoadResponse sync_load_response; 730 ResourceLoaderBridge::SyncLoadResponse sync_load_response;
735 context_->Start(request, &sync_load_response, platform_); 731 context_->Start(request, &sync_load_response, platform_);
736 732
737 const GURL& final_url = sync_load_response.url; 733 const GURL& final_url = sync_load_response.url;
738 734
739 // TODO(tc): For file loads, we may want to include a more descriptive 735 // TODO(tc): For file loads, we may want to include a more descriptive
740 // status code or status text. 736 // status code or status text.
741 const net::URLRequestStatus::Status& status = 737 const net::URLRequestStatus::Status& status =
742 sync_load_response.status.status(); 738 sync_load_response.status.status();
743 if (status != net::URLRequestStatus::SUCCESS && 739 if (status != net::URLRequestStatus::SUCCESS) {
744 status != net::URLRequestStatus::HANDLED_EXTERNALLY) {
745 response.setURL(final_url); 740 response.setURL(final_url);
746 error.domain = WebString::fromUTF8(net::kErrorDomain); 741 error.domain = WebString::fromUTF8(
742 sync_load_response.handled_externally ? "ext" : net::kErrorDomain);
747 error.reason = sync_load_response.status.error(); 743 error.reason = sync_load_response.status.error();
748 error.unreachableURL = final_url; 744 error.unreachableURL = final_url;
749 return; 745 return;
750 } 746 }
751 747
752 PopulateURLResponse(final_url, sync_load_response, &response); 748 PopulateURLResponse(final_url, sync_load_response, &response);
753 749
754 data.assign(sync_load_response.data.data(), 750 data.assign(sync_load_response.data.data(),
755 sync_load_response.data.size()); 751 sync_load_response.data.size());
756 } 752 }
757 753
758 void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request, 754 void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request,
759 WebURLLoaderClient* client) { 755 WebURLLoaderClient* client) {
760 DCHECK(!context_->client()); 756 DCHECK(!context_->client());
761 757
762 context_->set_client(client); 758 context_->set_client(client);
763 context_->Start(request, NULL, platform_); 759 context_->Start(request, NULL, platform_);
764 } 760 }
765 761
766 void WebURLLoaderImpl::cancel() { 762 void WebURLLoaderImpl::cancel() {
767 context_->Cancel(); 763 context_->Cancel();
768 } 764 }
769 765
770 void WebURLLoaderImpl::setDefersLoading(bool value) { 766 void WebURLLoaderImpl::setDefersLoading(bool value) {
771 context_->SetDefersLoading(value); 767 context_->SetDefersLoading(value);
772 } 768 }
773 769
774 } // namespace webkit_glue 770 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698