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

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: Comments & style have been updated. 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"
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
40
Charlie Reis 2013/08/09 18:48:38 nit: Remove extra blank line.
nasko 2013/08/09 19:07:28 nit: New empty line, not needed.
dsjang 2013/08/13 21:49:52 Done.
dsjang 2013/08/13 21:49:52 Done.
39 using base::Time; 41 using base::Time;
40 using base::TimeTicks; 42 using base::TimeTicks;
41 using WebKit::WebData; 43 using WebKit::WebData;
42 using WebKit::WebHTTPBody; 44 using WebKit::WebHTTPBody;
43 using WebKit::WebHTTPHeaderVisitor; 45 using WebKit::WebHTTPHeaderVisitor;
44 using WebKit::WebHTTPLoadInfo; 46 using WebKit::WebHTTPLoadInfo;
45 using WebKit::WebReferrerPolicy; 47 using WebKit::WebReferrerPolicy;
46 using WebKit::WebSecurityPolicy; 48 using WebKit::WebSecurityPolicy;
47 using WebKit::WebString; 49 using WebKit::WebString;
48 using WebKit::WebURL; 50 using WebKit::WebURL;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void HandleDataURL(); 368 void HandleDataURL();
367 369
368 WebURLLoaderImpl* loader_; 370 WebURLLoaderImpl* loader_;
369 WebURLRequest request_; 371 WebURLRequest request_;
370 WebURLLoaderClient* client_; 372 WebURLLoaderClient* client_;
371 WebReferrerPolicy referrer_policy_; 373 WebReferrerPolicy referrer_policy_;
372 scoped_ptr<ResourceLoaderBridge> bridge_; 374 scoped_ptr<ResourceLoaderBridge> bridge_;
373 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_; 375 scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
374 scoped_ptr<MultipartResponseDelegate> multipart_delegate_; 376 scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
375 scoped_ptr<ResourceLoaderBridge> completed_bridge_; 377 scoped_ptr<ResourceLoaderBridge> completed_bridge_;
378
379 // TODO(dsjang): A temporary hack to connect the lastest response
380 // observed by OnReceiveResponse() and the data stream received by
381 // OnReceivedData().
Charlie Reis 2013/08/09 18:48:38 I agree that this should only be used temporarily,
dsjang 2013/08/13 21:49:52 Done.
382 WebURL response_url_;
376 }; 383 };
377 384
378 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader) 385 WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader)
379 : loader_(loader), 386 : loader_(loader),
380 client_(NULL), 387 client_(NULL),
381 referrer_policy_(WebKit::WebReferrerPolicyDefault) { 388 referrer_policy_(WebKit::WebReferrerPolicyDefault) {
382 } 389 }
383 390
384 void WebURLLoaderImpl::Context::Cancel() { 391 void WebURLLoaderImpl::Context::Cancel() {
385 // The bridge will still send OnCompletedRequest, which will Release() us, so 392 // 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. 668 // code, nsMultiMixedConv::OnStartRequest throws an exception.
662 if (!boundary.empty()) { 669 if (!boundary.empty()) {
663 multipart_delegate_.reset( 670 multipart_delegate_.reset(
664 new MultipartResponseDelegate(client_, loader_, response, boundary)); 671 new MultipartResponseDelegate(client_, loader_, response, boundary));
665 } 672 }
666 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" && 673 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
667 !show_raw_listing) { 674 !show_raw_listing) {
668 ftp_listing_delegate_.reset( 675 ftp_listing_delegate_.reset(
669 new FtpDirectoryListingResponseDelegate(client_, loader_, response)); 676 new FtpDirectoryListingResponseDelegate(client_, loader_, response));
670 } 677 }
678
679 response_url_ = response.url();
671 } 680 }
672 681
673 void WebURLLoaderImpl::Context::OnDownloadedData(int len) { 682 void WebURLLoaderImpl::Context::OnDownloadedData(int len) {
674 if (client_) 683 if (client_)
675 client_->didDownloadData(loader_, len); 684 client_->didDownloadData(loader_, len);
676 } 685 }
677 686
678 void WebURLLoaderImpl::Context::OnReceivedData(const char* data, 687 void WebURLLoaderImpl::Context::OnReceivedData(const char* data,
679 int data_length, 688 int data_length,
680 int encoded_data_length) { 689 int encoded_data_length) {
681 if (!client_) 690 if (!client_)
682 return; 691 return;
683 692
684 if (ftp_listing_delegate_) { 693 if (ftp_listing_delegate_) {
685 // The FTP listing delegate will make the appropriate calls to 694 // The FTP listing delegate will make the appropriate calls to
686 // client_->didReceiveData and client_->didReceiveResponse. 695 // client_->didReceiveData and client_->didReceiveResponse.
687 ftp_listing_delegate_->OnReceivedData(data, data_length); 696 ftp_listing_delegate_->OnReceivedData(data, data_length);
688 } else if (multipart_delegate_) { 697 } else if (multipart_delegate_) {
689 // The multipart delegate will make the appropriate calls to 698 // The multipart delegate will make the appropriate calls to
690 // client_->didReceiveData and client_->didReceiveResponse. 699 // client_->didReceiveData and client_->didReceiveResponse.
691 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length); 700 multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length);
692 } else { 701 } else {
693 client_->didReceiveData(loader_, data, data_length, encoded_data_length); 702 client_->didReceiveData(loader_, data, data_length, encoded_data_length);
694 } 703 }
704
705 // TODO(dsjang): This logging code is just temporary. There has to
706 // be a better way to connect the received data to the response_url
707 // than this.
708 SiteIsolationPolicy::DidReceiveData(data, data_length, response_url_);
695 } 709 }
696 710
697 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata( 711 void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
698 const char* data, int len) { 712 const char* data, int len) {
699 if (client_) 713 if (client_)
700 client_->didReceiveCachedMetadata(loader_, data, len); 714 client_->didReceiveCachedMetadata(loader_, data, len);
701 } 715 }
702 716
703 void WebURLLoaderImpl::Context::OnCompletedRequest( 717 void WebURLLoaderImpl::Context::OnCompletedRequest(
704 int error_code, 718 int error_code,
(...skipping 15 matching lines...) Expand all
720 734
721 if (client_) { 735 if (client_) {
722 if (error_code != net::OK) { 736 if (error_code != net::OK) {
723 client_->didFail(loader_, CreateError(request_.url(), error_code)); 737 client_->didFail(loader_, CreateError(request_.url(), error_code));
724 } else { 738 } else {
725 client_->didFinishLoading( 739 client_->didFinishLoading(
726 loader_, (completion_time - TimeTicks()).InSecondsF()); 740 loader_, (completion_time - TimeTicks()).InSecondsF());
727 } 741 }
728 } 742 }
729 743
744 // TODO(dsjang): This logging code is just temporary. There has to
745 // be a better way to connect the received data to the response_url
746 // than this.
747 SiteIsolationPolicy::DidFinishResourceLoadForUrl(response_url_);
748
730 // We are done with the bridge now, and so we need to release the reference 749 // 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 750 // to ourselves that we took on behalf of the bridge. This may cause our
732 // destruction. 751 // destruction.
733 Release(); 752 Release();
734 } 753 }
735 754
736 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const { 755 bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const {
737 DCHECK(url.SchemeIs("data")); 756 DCHECK(url.SchemeIs("data"));
738 757
739 // Optimize for the case where we can handle a data URL locally. We must 758 // 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 863
845 void WebURLLoaderImpl::setDefersLoading(bool value) { 864 void WebURLLoaderImpl::setDefersLoading(bool value) {
846 context_->SetDefersLoading(value); 865 context_->SetDefersLoading(value);
847 } 866 }
848 867
849 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { 868 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
850 context_->DidChangePriority(new_priority); 869 context_->DidChangePriority(new_priority);
851 } 870 }
852 871
853 } // namespace webkit_glue 872 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698