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

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

Issue 22254005: UMA data collector for cross-site documents(XSD) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Revise comments and use lowercaseequls for "nosniff" value Created 7 years, 4 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/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 13 matching lines...) Expand all
24 #include "third_party/WebKit/public/platform/WebURL.h" 24 #include "third_party/WebKit/public/platform/WebURL.h"
25 #include "third_party/WebKit/public/platform/WebURLError.h" 25 #include "third_party/WebKit/public/platform/WebURLError.h"
26 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h" 26 #include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
27 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 27 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
28 #include "third_party/WebKit/public/platform/WebURLRequest.h" 28 #include "third_party/WebKit/public/platform/WebURLRequest.h"
29 #include "third_party/WebKit/public/platform/WebURLResponse.h" 29 #include "third_party/WebKit/public/platform/WebURLResponse.h"
30 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 30 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
31 #include "webkit/child/ftp_directory_listing_response_delegate.h" 31 #include "webkit/child/ftp_directory_listing_response_delegate.h"
32 #include "webkit/child/multipart_response_delegate.h" 32 #include "webkit/child/multipart_response_delegate.h"
33 #include "webkit/child/resource_loader_bridge.h" 33 #include "webkit/child/resource_loader_bridge.h"
34 #include "webkit/child/site_isolation_policy.h"
darin (slow to review) 2013/08/14 05:23:27 We are trying not to add more code to src/webkit/
dsjang 2013/08/14 20:47:03 Done.
34 #include "webkit/child/webkitplatformsupport_impl.h" 35 #include "webkit/child/webkitplatformsupport_impl.h"
35 #include "webkit/child/weburlrequest_extradata_impl.h" 36 #include "webkit/child/weburlrequest_extradata_impl.h"
36 #include "webkit/child/weburlresponse_extradata_impl.h" 37 #include "webkit/child/weburlresponse_extradata_impl.h"
37 #include "webkit/common/resource_request_body.h" 38 #include "webkit/common/resource_request_body.h"
38 39
39 using base::Time; 40 using base::Time;
40 using base::TimeTicks; 41 using base::TimeTicks;
41 using WebKit::WebData; 42 using WebKit::WebData;
42 using WebKit::WebHTTPBody; 43 using WebKit::WebHTTPBody;
43 using WebKit::WebHTTPHeaderVisitor; 44 using WebKit::WebHTTPHeaderVisitor;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void HandleDataURL(); 367 void HandleDataURL();
367 368
368 WebURLLoaderImpl* loader_; 369 WebURLLoaderImpl* loader_;
369 WebURLRequest request_; 370 WebURLRequest request_;
370 WebURLLoaderClient* client_; 371 WebURLLoaderClient* client_;
371 WebReferrerPolicy referrer_policy_; 372 WebReferrerPolicy referrer_policy_;
372 scoped_ptr<ResourceLoaderBridge> bridge_; 373 scoped_ptr<ResourceLoaderBridge> bridge_;
373 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; 374 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
374 scoped_ptr<MultipartResponseDelegate> multipart_delegate_; 375 scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
375 scoped_ptr<ResourceLoaderBridge> completed_bridge_; 376 scoped_ptr<ResourceLoaderBridge> completed_bridge_;
377
378 // TODO(dsjang): A temporary hack to connect the lastest response observed by
darin (slow to review) 2013/08/14 05:23:27 nit: lastest -> latest
dsjang 2013/08/14 20:47:03 Done.
379 // OnReceiveResponse() and the data stream received by OnReceivedData(). We
380 // can use this information for actual blocking. We can move this to somewhere
381 // better than here for actual blocking in the renderer. Ultimately, the
382 // blocking code will be moved to the browser process.
383 WebURL response_url_;
376 }; 384 };
377 385
378 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader) 386 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader)
379 : loader_(loader), 387 : loader_(loader),
380 client_(NULL), 388 client_(NULL),
381 referrer_policy_(WebKit::WebReferrerPolicyDefault) { 389 referrer_policy_(WebKit::WebReferrerPolicyDefault) {
382 } 390 }
383 391
384 void WebURLLoaderImpl::Context::Cancel() { 392 void WebURLLoaderImpl::Context::Cancel() {
385 // The bridge will still send OnCompletedRequest, which will Release() us, so 393 // The bridge will still send OnCompletedRequest, which will Release() us, so
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // code, nsMultiMixedConv::OnStartRequest throws an exception. 669 // code, nsMultiMixedConv::OnStartRequest throws an exception.
662 if (!boundary.empty()) { 670 if (!boundary.empty()) {
663 multipart_delegate_.reset( 671 multipart_delegate_.reset(
664 new MultipartResponseDelegate(client_, loader_, response, boundary)); 672 new MultipartResponseDelegate(client_, loader_, response, boundary));
665 } 673 }
666 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" && 674 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
667 !show_raw_listing) { 675 !show_raw_listing) {
668 ftp_listing_delegate_.reset( 676 ftp_listing_delegate_.reset(
669 new FtpDirectoryListingResponseDelegate(client_, loader_, response)); 677 new FtpDirectoryListingResponseDelegate(client_, loader_, response));
670 } 678 }
679
680 response_url_ = response.url();
671 } 681 }
672 682
673 void WebURLLoaderImpl::Context::OnDownloadedData(int len) { 683 void WebURLLoaderImpl::Context::OnDownloadedData(int len) {
674 if (client_) 684 if (client_)
675 client_->didDownloadData(loader_, len); 685 client_->didDownloadData(loader_, len);
676 } 686 }
677 687
678 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, 688 void WebURLLoaderImpl::Context::OnReceivedData(const char* data,
679 int data_length, 689 int data_length,
680 int encoded_data_length) { 690 int encoded_data_length) {
681 if (!client_) 691 if (!client_)
682 return; 692 return;
683 693
684 if (ftp_listing_delegate_) { 694 if (ftp_listing_delegate_) {
685 // The FTP listing delegate will make the appropriate calls to 695 // The FTP listing delegate will make the appropriate calls to
686 // client_->didReceiveData and client_->didReceiveResponse. 696 // client_->didReceiveData and client_->didReceiveResponse.
687 ftp_listing_delegate_->OnReceivedData(data, data_length); 697 ftp_listing_delegate_->OnReceivedData(data, data_length);
688 } else if (multipart_delegate_) { 698 } else if (multipart_delegate_) {
689 // The multipart delegate will make the appropriate calls to 699 // The multipart delegate will make the appropriate calls to
690 // client_->didReceiveData and client_->didReceiveResponse. 700 // client_->didReceiveData and client_->didReceiveResponse.
691 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); 701 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length);
692 } else { 702 } else {
693 client_->didReceiveData(loader_, data, data_length, encoded_data_length); 703 client_->didReceiveData(loader_, data, data_length, encoded_data_length);
694 } 704 }
705
706 // TODO(dsjang): This logging code is just temporary. There has to
707 // be a better way to connect the received data to the response_url
708 // than this.
709 SiteIsolationPolicy::DidReceiveData(data, data_length, response_url_);
695 } 710 }
696 711
697 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 712 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
698 const char* data, int len) { 713 const char* data, int len) {
699 if (client_) 714 if (client_)
700 client_->didReceiveCachedMetadata(loader_, data, len); 715 client_->didReceiveCachedMetadata(loader_, data, len);
701 } 716 }
702 717
703 void WebURLLoaderImpl::Context::OnCompletedRequest( 718 void WebURLLoaderImpl::Context::OnCompletedRequest(
704 int error_code, 719 int error_code,
(...skipping 15 matching lines...) Expand all
720 735
721 if (client_) { 736 if (client_) {
722 if (error_code != net::OK) { 737 if (error_code != net::OK) {
723 client_->didFail(loader_, CreateError(request_.url(), error_code)); 738 client_->didFail(loader_, CreateError(request_.url(), error_code));
724 } else { 739 } else {
725 client_->didFinishLoading( 740 client_->didFinishLoading(
726 loader_, (completion_time - TimeTicks()).InSecondsF()); 741 loader_, (completion_time - TimeTicks()).InSecondsF());
727 } 742 }
728 } 743 }
729 744
745 // TODO(dsjang): This logging code is just temporary. There has to
746 // be a better way to connect the received data to the response_url
747 // than this.
748 SiteIsolationPolicy::DidFinishResourceLoadForUrl(response_url_);
749
730 // We are done with the bridge now, and so we need to release the reference 750 // We are done with the bridge now, and so we need to release the reference
731 // to ourselves that we took on behalf of the bridge. This may cause our 751 // to ourselves that we took on behalf of the bridge. This may cause our
732 // destruction. 752 // destruction.
733 Release(); 753 Release();
734 } 754 }
735 755
736 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const { 756 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const {
737 DCHECK(url.SchemeIs("data")); 757 DCHECK(url.SchemeIs("data"));
738 758
739 // Optimize for the case where we can handle a data URL locally. We must 759 // Optimize for the case where we can handle a data URL locally. We must
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 864
845 void WebURLLoaderImpl::setDefersLoading(bool value) { 865 void WebURLLoaderImpl::setDefersLoading(bool value) {
846 context_->SetDefersLoading(value); 866 context_->SetDefersLoading(value);
847 } 867 }
848 868
849 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { 869 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
850 context_->DidChangePriority(new_priority); 870 context_->DidChangePriority(new_priority);
851 } 871 }
852 872
853 } // namespace webkit_glue 873 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698