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

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

Issue 138513002: Plumb network stack information about existence of cached copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Last comments from Matt. Created 6 years, 10 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 | Annotate | Revision Log
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/child/weburlloader_impl.h" 7 #include "webkit/child/weburlloader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 GURL* new_first_party_for_cookies) OVERRIDE; 238 GURL* new_first_party_for_cookies) OVERRIDE;
239 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE; 239 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE;
240 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE; 240 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE;
241 virtual void OnReceivedData(const char* data, 241 virtual void OnReceivedData(const char* data,
242 int data_length, 242 int data_length,
243 int encoded_data_length) OVERRIDE; 243 int encoded_data_length) OVERRIDE;
244 virtual void OnReceivedCachedMetadata(const char* data, int len) OVERRIDE; 244 virtual void OnReceivedCachedMetadata(const char* data, int len) OVERRIDE;
245 virtual void OnCompletedRequest( 245 virtual void OnCompletedRequest(
246 int error_code, 246 int error_code,
247 bool was_ignored_by_handler, 247 bool was_ignored_by_handler,
248 bool stale_copy_in_cache,
248 const std::string& security_info, 249 const std::string& security_info,
249 const base::TimeTicks& completion_time) OVERRIDE; 250 const base::TimeTicks& completion_time) OVERRIDE;
250 251
251 private: 252 private:
252 friend class base::RefCounted<Context>; 253 friend class base::RefCounted<Context>;
253 virtual ~Context() {} 254 virtual ~Context() {}
254 255
255 // We can optimize the handling of data URLs in most cases. 256 // We can optimize the handling of data URLs in most cases.
256 bool CanHandleDataURL(const GURL& url) const; 257 bool CanHandleDataURL(const GURL& url) const;
257 void HandleDataURL(); 258 void HandleDataURL();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 595
595 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 596 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
596 const char* data, int len) { 597 const char* data, int len) {
597 if (client_) 598 if (client_)
598 client_->didReceiveCachedMetadata(loader_, data, len); 599 client_->didReceiveCachedMetadata(loader_, data, len);
599 } 600 }
600 601
601 void WebURLLoaderImpl::Context::OnCompletedRequest( 602 void WebURLLoaderImpl::Context::OnCompletedRequest(
602 int error_code, 603 int error_code,
603 bool was_ignored_by_handler, 604 bool was_ignored_by_handler,
605 bool stale_copy_in_cache,
604 const std::string& security_info, 606 const std::string& security_info,
605 const base::TimeTicks& completion_time) { 607 const base::TimeTicks& completion_time) {
606 if (ftp_listing_delegate_) { 608 if (ftp_listing_delegate_) {
607 ftp_listing_delegate_->OnCompletedRequest(); 609 ftp_listing_delegate_->OnCompletedRequest();
608 ftp_listing_delegate_.reset(NULL); 610 ftp_listing_delegate_.reset(NULL);
609 } else if (multipart_delegate_) { 611 } else if (multipart_delegate_) {
610 multipart_delegate_->OnCompletedRequest(); 612 multipart_delegate_->OnCompletedRequest();
611 multipart_delegate_.reset(NULL); 613 multipart_delegate_.reset(NULL);
612 } 614 }
613 615
614 // Prevent any further IPC to the browser now that we're complete, but 616 // Prevent any further IPC to the browser now that we're complete, but
615 // don't delete it to keep any downloaded temp files alive. 617 // don't delete it to keep any downloaded temp files alive.
616 DCHECK(!completed_bridge_.get()); 618 DCHECK(!completed_bridge_.get());
617 completed_bridge_.swap(bridge_); 619 completed_bridge_.swap(bridge_);
618 620
619 if (client_) { 621 if (client_) {
620 if (error_code != net::OK) { 622 if (error_code != net::OK) {
621 client_->didFail(loader_, CreateError(request_.url(), error_code)); 623 client_->didFail(loader_, CreateError(request_.url(),
624 stale_copy_in_cache,
625 error_code));
622 } else { 626 } else {
623 client_->didFinishLoading( 627 client_->didFinishLoading(
624 loader_, (completion_time - TimeTicks()).InSecondsF()); 628 loader_, (completion_time - TimeTicks()).InSecondsF());
625 } 629 }
626 } 630 }
627 631
628 // We are done with the bridge now, and so we need to release the reference 632 // We are done with the bridge now, and so we need to release the reference
629 // to ourselves that we took on behalf of the bridge. This may cause our 633 // to ourselves that we took on behalf of the bridge. This may cause our
630 // destruction. 634 // destruction.
631 Release(); 635 Release();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 ResourceResponseInfo info; 669 ResourceResponseInfo info;
666 int error_code; 670 int error_code;
667 std::string data; 671 std::string data;
668 672
669 if (GetInfoFromDataURL(request_.url(), &info, &data, &error_code)) { 673 if (GetInfoFromDataURL(request_.url(), &info, &data, &error_code)) {
670 OnReceivedResponse(info); 674 OnReceivedResponse(info);
671 if (!data.empty()) 675 if (!data.empty())
672 OnReceivedData(data.data(), data.size(), 0); 676 OnReceivedData(data.data(), data.size(), 0);
673 } 677 }
674 678
675 OnCompletedRequest(error_code, false, info.security_info, 679 OnCompletedRequest(error_code, false, false, info.security_info,
676 base::TimeTicks::Now()); 680 base::TimeTicks::Now());
677 } 681 }
678 682
679 // WebURLLoaderImpl ----------------------------------------------------------- 683 // WebURLLoaderImpl -----------------------------------------------------------
680 684
681 WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform) 685 WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform)
682 : context_(new Context(this)), 686 : context_(new Context(this)),
683 platform_(platform) { 687 platform_(platform) {
684 } 688 }
685 689
686 WebURLLoaderImpl::~WebURLLoaderImpl() { 690 WebURLLoaderImpl::~WebURLLoaderImpl() {
687 cancel(); 691 cancel();
688 } 692 }
689 693
690 WebURLError WebURLLoaderImpl::CreateError(const WebURL& unreachable_url, 694 WebURLError WebURLLoaderImpl::CreateError(const WebURL& unreachable_url,
695 bool stale_copy_in_cache,
691 int reason) { 696 int reason) {
692 WebURLError error; 697 WebURLError error;
693 error.domain = WebString::fromUTF8(net::kErrorDomain); 698 error.domain = WebString::fromUTF8(net::kErrorDomain);
694 error.reason = reason; 699 error.reason = reason;
695 error.unreachableURL = unreachable_url; 700 error.unreachableURL = unreachable_url;
701 error.staleCopyInCache = stale_copy_in_cache;
696 if (reason == net::ERR_ABORTED) { 702 if (reason == net::ERR_ABORTED) {
697 error.isCancellation = true; 703 error.isCancellation = true;
698 } else if (reason == net::ERR_TEMPORARILY_THROTTLED) { 704 } else if (reason == net::ERR_TEMPORARILY_THROTTLED) {
699 error.localizedDescription = WebString::fromUTF8( 705 error.localizedDescription = WebString::fromUTF8(
700 kThrottledErrorDescription); 706 kThrottledErrorDescription);
701 } else { 707 } else {
702 error.localizedDescription = WebString::fromUTF8( 708 error.localizedDescription = WebString::fromUTF8(
703 net::ErrorToString(reason)); 709 net::ErrorToString(reason));
704 } 710 }
705 return error; 711 return error;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 859
854 void WebURLLoaderImpl::setDefersLoading(bool value) { 860 void WebURLLoaderImpl::setDefersLoading(bool value) {
855 context_->SetDefersLoading(value); 861 context_->SetDefersLoading(value);
856 } 862 }
857 863
858 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { 864 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
859 context_->DidChangePriority(new_priority); 865 context_->DidChangePriority(new_priority);
860 } 866 }
861 867
862 } // namespace webkit_glue 868 } // namespace webkit_glue
OLDNEW
« content/renderer/render_view_browsertest.cc ('K') | « webkit/child/weburlloader_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698