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

Side by Side Diff: ios/web/net/request_tracker_impl.mm

Issue 2617243002: Remove ScopedVector from ios/. (Closed)
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « ios/web/net/request_tracker_impl.h ('k') | ios/web/net/request_tracker_impl_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/web/net/request_tracker_impl.h" 5 #import "ios/web/net/request_tracker_impl.h"
6 6
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #import "base/mac/bind_objc_block.h" 15 #import "base/mac/bind_objc_block.h"
16 #import "base/mac/scoped_nsobject.h" 16 #import "base/mac/scoped_nsobject.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "base/strings/sys_string_conversions.h" 20 #include "base/strings/sys_string_conversions.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 #import "ios/net/clients/crn_forwarding_network_client.h" 22 #import "ios/net/clients/crn_forwarding_network_client.h"
22 #import "ios/net/clients/crn_forwarding_network_client_factory.h" 23 #import "ios/net/clients/crn_forwarding_network_client_factory.h"
23 #include "ios/web/history_state_util.h" 24 #include "ios/web/history_state_util.h"
24 #import "ios/web/net/crw_request_tracker_delegate.h" 25 #import "ios/web/net/crw_request_tracker_delegate.h"
25 #include "ios/web/public/browser_state.h" 26 #include "ios/web/public/browser_state.h"
26 #include "ios/web/public/certificate_policy_cache.h" 27 #include "ios/web/public/certificate_policy_cache.h"
27 #include "ios/web/public/ssl_status.h" 28 #include "ios/web/public/ssl_status.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 DCHECK_EQ(is_for_static_file_requests_, request->url().SchemeIsFile()); 481 DCHECK_EQ(is_for_static_file_requests_, request->url().SchemeIsFile());
481 482
482 if (new_estimate_round_) { 483 if (new_estimate_round_) {
483 // Starting a new estimate round. Ignore the previous requests for the 484 // Starting a new estimate round. Ignore the previous requests for the
484 // calculation. 485 // calculation.
485 counts_by_request_.clear(); 486 counts_by_request_.clear();
486 estimate_start_index_ = counts_.size(); 487 estimate_start_index_ = counts_.size();
487 new_estimate_round_ = false; 488 new_estimate_round_ = false;
488 } 489 }
489 const GURL& url = request->original_url(); 490 const GURL& url = request->original_url();
490 TrackerCounts* counts = new TrackerCounts( 491 auto counts =
491 GURLByRemovingRefFromGURL(url), request); 492 base::MakeUnique<TrackerCounts>(GURLByRemovingRefFromGURL(url), request);
492 counts_.push_back(counts); 493 counts_by_request_[request] = counts.get();
493 counts_by_request_[request] = counts; 494 counts_.push_back(std::move(counts));
494 if (page_url_.SchemeIsCryptographic() && !url.SchemeIsCryptographic()) 495 if (page_url_.SchemeIsCryptographic() && !url.SchemeIsCryptographic())
495 has_mixed_content_ = true; 496 has_mixed_content_ = true;
496 Notify(); 497 Notify();
497 } 498 }
498 499
499 void RequestTrackerImpl::CaptureHeaders(net::URLRequest* request) { 500 void RequestTrackerImpl::CaptureHeaders(net::URLRequest* request) {
500 DCHECK_CURRENTLY_ON(web::WebThread::IO); 501 DCHECK_CURRENTLY_ON(web::WebThread::IO);
501 if (is_closing_) 502 if (is_closing_)
502 return; 503 return;
503 504
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 if (is_closing_) 781 if (is_closing_)
781 return; 782 return;
782 783
783 if (counts_.empty()) 784 if (counts_.empty())
784 return; // Nothing yet to notify. 785 return; // Nothing yet to notify.
785 786
786 if (!page_url_.SchemeIsCryptographic()) 787 if (!page_url_.SchemeIsCryptographic())
787 return; 788 return;
788 789
789 const GURL page_origin = page_url_.GetOrigin(); 790 const GURL page_origin = page_url_.GetOrigin();
790 ScopedVector<TrackerCounts>::iterator it; 791 for (const auto& tracker_count : counts_) {
791 for (it = counts_.begin(); it != counts_.end(); ++it) { 792 if (!tracker_count->ssl_info.is_valid())
792 if (!(*it)->ssl_info.is_valid())
793 continue; // No SSL info at this point in time on this tracker. 793 continue; // No SSL info at this point in time on this tracker.
794 794
795 GURL request_origin = (*it)->url.GetOrigin(); 795 GURL request_origin = tracker_count->url.GetOrigin();
796 if (request_origin != page_origin) 796 if (request_origin != page_origin)
797 continue; // Not interesting in the context of the page. 797 continue; // Not interesting in the context of the page.
798 798
799 base::scoped_nsobject<CRWSSLCarrier> carrier( 799 base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc]
800 [[CRWSSLCarrier alloc] initWithTracker:this counts:*it]); 800 initWithTracker:this
801 counts:tracker_count.get()]);
801 web::WebThread::PostTask( 802 web::WebThread::PostTask(
802 web::WebThread::UI, FROM_HERE, 803 web::WebThread::UI, FROM_HERE,
803 base::Bind(&RequestTrackerImpl::NotifyUpdatedSSLStatus, this, carrier)); 804 base::Bind(&RequestTrackerImpl::NotifyUpdatedSSLStatus, this, carrier));
804 break; 805 break;
805 } 806 }
806 } 807 }
807 808
808 void RequestTrackerImpl::NotifyResponseHeaders( 809 void RequestTrackerImpl::NotifyResponseHeaders(
809 net::HttpResponseHeaders* headers, 810 net::HttpResponseHeaders* headers,
810 const GURL& request_url) { 811 const GURL& request_url) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 CancelRequestForCounts(counts); 921 CancelRequestForCounts(counts);
921 break; 922 break;
922 } 923 }
923 } 924 }
924 925
925 void RequestTrackerImpl::ReevaluateCallbacksForAllCounts() { 926 void RequestTrackerImpl::ReevaluateCallbacksForAllCounts() {
926 DCHECK_CURRENTLY_ON(web::WebThread::IO); 927 DCHECK_CURRENTLY_ON(web::WebThread::IO);
927 if (is_closing_) 928 if (is_closing_)
928 return; 929 return;
929 930
930 ScopedVector<TrackerCounts>::iterator it; 931 for (const auto& tracker_count : counts_) {
931 for (it = counts_.begin(); it != counts_.end(); ++it) {
932 // Check if the value hasn't changed via a user action. 932 // Check if the value hasn't changed via a user action.
933 if ((*it)->ssl_judgment == CertPolicy::UNKNOWN) 933 if (tracker_count->ssl_judgment == CertPolicy::UNKNOWN)
934 EvaluateSSLCallbackForCounts(*it); 934 EvaluateSSLCallbackForCounts(tracker_count.get());
935 935
936 CertPolicy::Judgment judgment = (*it)->ssl_judgment; 936 CertPolicy::Judgment judgment = tracker_count->ssl_judgment;
937 if (judgment == CertPolicy::ALLOWED) 937 if (judgment == CertPolicy::ALLOWED)
938 continue; 938 continue;
939 939
940 // SSL errors on subrequests are simply ignored. The call to 940 // SSL errors on subrequests are simply ignored. The call to
941 // EvaluateSSLCallbackForCounts() cancelled the request and nothing will 941 // EvaluateSSLCallbackForCounts() cancelled the request and nothing will
942 // restart it. 942 // restart it.
943 if ((*it)->is_subrequest) 943 if (tracker_count->is_subrequest)
944 continue; 944 continue;
945 945
946 if (!current_ssl_error_) { 946 if (!current_ssl_error_) {
947 // For the UNKNOWN and DENIED state the information should be pushed to 947 // For the UNKNOWN and DENIED state the information should be pushed to
948 // the delegate. But only one at a time. 948 // the delegate. But only one at a time.
949 current_ssl_error_ = (*it); 949 current_ssl_error_ = tracker_count.get();
950 base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc] 950 base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc]
951 initWithTracker:this counts:current_ssl_error_]); 951 initWithTracker:this counts:current_ssl_error_]);
952 web::WebThread::PostTask( 952 web::WebThread::PostTask(
953 web::WebThread::UI, FROM_HERE, 953 web::WebThread::UI, FROM_HERE,
954 base::Bind(&RequestTrackerImpl::NotifyPresentSSLError, this, carrier, 954 base::Bind(&RequestTrackerImpl::NotifyPresentSSLError, this, carrier,
955 judgment == CertPolicy::UNKNOWN)); 955 judgment == CertPolicy::UNKNOWN));
956 } 956 }
957 } 957 }
958 } 958 }
959 959
960 void RequestTrackerImpl::CancelRequestForCounts(TrackerCounts* counts) { 960 void RequestTrackerImpl::CancelRequestForCounts(TrackerCounts* counts) {
961 DCHECK_CURRENTLY_ON(web::WebThread::IO); 961 DCHECK_CURRENTLY_ON(web::WebThread::IO);
962 // Cancel the request. 962 // Cancel the request.
963 counts->done = true; 963 counts->done = true;
964 counts_by_request_.erase(counts->request); 964 counts_by_request_.erase(counts->request);
965 counts->ssl_callback.Run(NO); 965 counts->ssl_callback.Run(NO);
966 counts->ssl_callback = base::Bind(&DoNothing); 966 counts->ssl_callback = base::Bind(&DoNothing);
967 Notify(); 967 Notify();
968 } 968 }
969 969
970 PageCounts RequestTrackerImpl::pageCounts() { 970 PageCounts RequestTrackerImpl::pageCounts() {
971 DCHECK_GE(counts_.size(), estimate_start_index_); 971 DCHECK_GE(counts_.size(), estimate_start_index_);
972 972
973 PageCounts page_counts; 973 PageCounts page_counts;
974 974
975 ScopedVector<TrackerCounts>::iterator it; 975 for (const auto& tracker_count : counts_) {
976 for (it = counts_.begin() + estimate_start_index_; 976 if (tracker_count->done) {
977 it != counts_.end(); ++it) { 977 uint64_t size = tracker_count->processed;
978 if ((*it)->done) {
979 uint64_t size = (*it)->processed;
980 page_counts.finished += 1; 978 page_counts.finished += 1;
981 page_counts.finished_bytes += size; 979 page_counts.finished_bytes += size;
982 if (page_counts.largest_byte_size_known < size) { 980 if (page_counts.largest_byte_size_known < size) {
983 page_counts.largest_byte_size_known = size; 981 page_counts.largest_byte_size_known = size;
984 } 982 }
985 } else { 983 } else {
986 page_counts.unfinished += 1; 984 page_counts.unfinished += 1;
987 if ((*it)->expected_length) { 985 if (tracker_count->expected_length) {
988 uint64_t size = (*it)->expected_length; 986 uint64_t size = tracker_count->expected_length;
989 page_counts.unfinished_estimate_bytes_done += (*it)->processed; 987 page_counts.unfinished_estimate_bytes_done += tracker_count->processed;
990 page_counts.unfinished_estimated_bytes_left += size; 988 page_counts.unfinished_estimated_bytes_left += size;
991 if (page_counts.largest_byte_size_known < size) { 989 if (page_counts.largest_byte_size_known < size) {
992 page_counts.largest_byte_size_known = size; 990 page_counts.largest_byte_size_known = size;
993 } 991 }
994 } else { 992 } else {
995 page_counts.unfinished_no_estimate += 1; 993 page_counts.unfinished_no_estimate += 1;
996 page_counts.unfinished_no_estimate_bytes_done += (*it)->processed; 994 page_counts.unfinished_no_estimate_bytes_done +=
995 tracker_count->processed;
997 } 996 }
998 } 997 }
999 } 998 }
1000 999
1001 return page_counts; 1000 return page_counts;
1002 } 1001 }
1003 1002
1004 float RequestTrackerImpl::EstimatedProgress() { 1003 float RequestTrackerImpl::EstimatedProgress() {
1005 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1004 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1006 1005
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 return previous_estimate_; 1073 return previous_estimate_;
1075 } 1074 }
1076 1075
1077 void RequestTrackerImpl::RecomputeMixedContent( 1076 void RequestTrackerImpl::RecomputeMixedContent(
1078 const TrackerCounts* split_position) { 1077 const TrackerCounts* split_position) {
1079 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1078 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1080 // Check if the mixed content before trimming was correct. 1079 // Check if the mixed content before trimming was correct.
1081 if (page_url_.SchemeIsCryptographic() && has_mixed_content_) { 1080 if (page_url_.SchemeIsCryptographic() && has_mixed_content_) {
1082 bool old_url_has_mixed_content = false; 1081 bool old_url_has_mixed_content = false;
1083 const GURL origin = page_url_.GetOrigin(); 1082 const GURL origin = page_url_.GetOrigin();
1084 ScopedVector<TrackerCounts>::iterator it = counts_.begin(); 1083 auto it = counts_.begin();
1085 while (it != counts_.end() && *it != split_position) { 1084 while (it != counts_.end() && it->get() != split_position) {
1086 if (!(*it)->url.SchemeIsCryptographic() && 1085 if (!(*it)->url.SchemeIsCryptographic() &&
1087 origin == (*it)->first_party_for_cookies_origin) { 1086 origin == (*it)->first_party_for_cookies_origin) {
1088 old_url_has_mixed_content = true; 1087 old_url_has_mixed_content = true;
1089 break; 1088 break;
1090 } 1089 }
1091 ++it; 1090 ++it;
1092 } 1091 }
1093 if (!old_url_has_mixed_content) { 1092 if (!old_url_has_mixed_content) {
1094 // We marked the previous page with incorrect data about its mixed 1093 // We marked the previous page with incorrect data about its mixed
1095 // content. Turns out that the elements that triggered that condition 1094 // content. Turns out that the elements that triggered that condition
1096 // where in fact in a subsequent page. Duh. 1095 // where in fact in a subsequent page. Duh.
1097 // Resend a notification for the |page_url_| informing the upper layer 1096 // Resend a notification for the |page_url_| informing the upper layer
1098 // that the mixed content was a red herring. 1097 // that the mixed content was a red herring.
1099 has_mixed_content_ = false; 1098 has_mixed_content_ = false;
1100 SSLNotify(); 1099 SSLNotify();
1101 } 1100 }
1102 } 1101 }
1103 } 1102 }
1104 1103
1105 void RequestTrackerImpl::RecomputeCertificatePolicy( 1104 void RequestTrackerImpl::RecomputeCertificatePolicy(
1106 const TrackerCounts* splitPosition) { 1105 const TrackerCounts* splitPosition) {
1107 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1106 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1108 // Clear the judgments for the old URL. 1107 // Clear the judgments for the old URL.
1109 web::WebThread::PostTask( 1108 web::WebThread::PostTask(
1110 web::WebThread::UI, FROM_HERE, 1109 web::WebThread::UI, FROM_HERE,
1111 base::Bind(&RequestTrackerImpl::NotifyClearCertificates, this)); 1110 base::Bind(&RequestTrackerImpl::NotifyClearCertificates, this));
1112 // Report judgements for the new URL. 1111 // Report judgements for the new URL.
1113 ScopedVector<TrackerCounts>::const_reverse_iterator it; 1112 for (auto it = counts_.rbegin(); it != counts_.rend(); ++it) {
1114 for (it = counts_.rbegin(); it != counts_.rend(); ++it) { 1113 TrackerCounts* counts = it->get();
1115 TrackerCounts* counts = *it;
1116 if (counts->allowed_by_user) { 1114 if (counts->allowed_by_user) {
1117 std::string host = counts->url.host(); 1115 std::string host = counts->url.host();
1118 web::WebThread::PostTask( 1116 web::WebThread::PostTask(
1119 web::WebThread::UI, FROM_HERE, 1117 web::WebThread::UI, FROM_HERE,
1120 base::Bind(&RequestTrackerImpl::NotifyCertificateUsed, this, 1118 base::Bind(&RequestTrackerImpl::NotifyCertificateUsed, this,
1121 base::RetainedRef(counts->ssl_info.cert), host, 1119 base::RetainedRef(counts->ssl_info.cert), host,
1122 counts->ssl_info.cert_status)); 1120 counts->ssl_info.cert_status));
1123 } 1121 }
1124 if (counts == splitPosition) 1122 if (counts == splitPosition)
1125 break; 1123 break;
(...skipping 11 matching lines...) Expand all
1137 } 1135 }
1138 1136
1139 void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) { 1137 void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
1140 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1138 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1141 1139
1142 GURL url = GURLByRemovingRefFromGURL(full_url); 1140 GURL url = GURLByRemovingRefFromGURL(full_url);
1143 1141
1144 // Locate the request with this url, if present. 1142 // Locate the request with this url, if present.
1145 bool new_url_has_mixed_content = false; 1143 bool new_url_has_mixed_content = false;
1146 bool url_scheme_is_secure = url.SchemeIsCryptographic(); 1144 bool url_scheme_is_secure = url.SchemeIsCryptographic();
1147 ScopedVector<TrackerCounts>::const_reverse_iterator rit = counts_.rbegin(); 1145 auto rit = counts_.rbegin();
1148 while (rit != counts_.rend() && (*rit)->url != url) { 1146 while (rit != counts_.rend() && (*rit)->url != url) {
1149 if (url_scheme_is_secure && !(*rit)->url.SchemeIsCryptographic() && 1147 if (url_scheme_is_secure && !(*rit)->url.SchemeIsCryptographic() &&
1150 (*rit)->first_party_for_cookies_origin == url.GetOrigin()) { 1148 (*rit)->first_party_for_cookies_origin == url.GetOrigin()) {
1151 new_url_has_mixed_content = true; 1149 new_url_has_mixed_content = true;
1152 } 1150 }
1153 ++rit; 1151 ++rit;
1154 } 1152 }
1155 1153
1156 // |split_position| will be set to the count for the passed url if it exists. 1154 // |split_position| will be set to the count for the passed url if it exists.
1157 TrackerCounts* split_position = NULL; 1155 TrackerCounts* split_position = NULL;
1158 if (rit != counts_.rend()) { 1156 if (rit != counts_.rend()) {
1159 split_position = (*rit); 1157 split_position = rit->get();
1160 } else { 1158 } else {
1161 // The URL was not found, everything will be trimmed. The mixed content 1159 // The URL was not found, everything will be trimmed. The mixed content
1162 // calculation is invalid. 1160 // calculation is invalid.
1163 new_url_has_mixed_content = false; 1161 new_url_has_mixed_content = false;
1164 1162
1165 // In the case of a page loaded via a HTML5 manifest there is no page 1163 // In the case of a page loaded via a HTML5 manifest there is no page
1166 // boundary to be found. However the latest count is a request for a 1164 // boundary to be found. However the latest count is a request for a
1167 // manifest. This tries to detect this peculiar case. 1165 // manifest. This tries to detect this peculiar case.
1168 // This is important as if this request for the manifest is on the same 1166 // This is important as if this request for the manifest is on the same
1169 // domain as the page itself this will allow retrieval of the SSL 1167 // domain as the page itself this will allow retrieval of the SSL
1170 // information. 1168 // information.
1171 if (url_scheme_is_secure && counts_.size()) { 1169 if (url_scheme_is_secure && counts_.size()) {
1172 TrackerCounts* back = counts_.back(); 1170 TrackerCounts* back = counts_.back().get();
1173 const GURL& back_url = back->url; 1171 const GURL& back_url = back->url;
1174 if (back_url.SchemeIsCryptographic() && 1172 if (back_url.SchemeIsCryptographic() &&
1175 back_url.GetOrigin() == url.GetOrigin() && !back->is_subrequest) { 1173 back_url.GetOrigin() == url.GetOrigin() && !back->is_subrequest) {
1176 split_position = back; 1174 split_position = back;
1177 } 1175 }
1178 } 1176 }
1179 } 1177 }
1180 RecomputeMixedContent(split_position); 1178 RecomputeMixedContent(split_position);
1181 RecomputeCertificatePolicy(split_position); 1179 RecomputeCertificatePolicy(split_position);
1182 1180
1183 // Trim up to that element. 1181 // Trim up to that element.
1184 ScopedVector<TrackerCounts>::iterator it = counts_.begin(); 1182 auto it = counts_.begin();
1185 while (it != counts_.end() && *it != split_position) { 1183 while (it != counts_.end() && it->get() != split_position) {
1186 if (!(*it)->done) { 1184 if (!(*it)->done) {
1187 // This is for an unfinished request on a previous page. We do not care 1185 // This is for an unfinished request on a previous page. We do not care
1188 // about those anymore. Cancel the request. 1186 // about those anymore. Cancel the request.
1189 if ((*it)->ssl_judgment == CertPolicy::UNKNOWN) 1187 if ((*it)->ssl_judgment == CertPolicy::UNKNOWN)
1190 CancelRequestForCounts(*it); 1188 CancelRequestForCounts(it->get());
1191 counts_by_request_.erase((*it)->request); 1189 counts_by_request_.erase((*it)->request);
1192 } 1190 }
1193 it = counts_.erase(it); 1191 it = counts_.erase(it);
1194 } 1192 }
1195 1193
1196 has_mixed_content_ = new_url_has_mixed_content; 1194 has_mixed_content_ = new_url_has_mixed_content;
1197 page_url_ = url; 1195 page_url_ = url;
1198 user_info_.reset(user_info); 1196 user_info_.reset(user_info);
1199 estimate_start_index_ = 0; 1197 estimate_start_index_ = 0;
1200 is_loading_ = true; 1198 is_loading_ = true;
(...skipping 25 matching lines...) Expand all
1226 return; 1224 return;
1227 web::WebThread::PostTask(thread, FROM_HERE, task); 1225 web::WebThread::PostTask(thread, FROM_HERE, task);
1228 } 1226 }
1229 1227
1230 #pragma mark Other internal methods. 1228 #pragma mark Other internal methods.
1231 1229
1232 NSString* RequestTrackerImpl::UnsafeDescription() { 1230 NSString* RequestTrackerImpl::UnsafeDescription() {
1233 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1231 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1234 1232
1235 NSMutableArray* urls = [NSMutableArray array]; 1233 NSMutableArray* urls = [NSMutableArray array];
1236 ScopedVector<TrackerCounts>::iterator it; 1234 for (const auto& tracker_count : counts_)
1237 for (it = counts_.begin(); it != counts_.end(); ++it) 1235 [urls addObject:tracker_count->Description()];
1238 [urls addObject:(*it)->Description()];
1239 1236
1240 return [NSString stringWithFormat:@"RequestGroupID %@\n%@\n%@", 1237 return [NSString stringWithFormat:@"RequestGroupID %@\n%@\n%@",
1241 request_group_id_.get(), 1238 request_group_id_.get(),
1242 net::NSURLWithGURL(page_url_), 1239 net::NSURLWithGURL(page_url_),
1243 [urls componentsJoinedByString:@"\n"]]; 1240 [urls componentsJoinedByString:@"\n"]];
1244 } 1241 }
1245 1242
1246 void RequestTrackerImpl::CancelRequests() { 1243 void RequestTrackerImpl::CancelRequests() {
1247 DCHECK_CURRENTLY_ON(web::WebThread::IO); 1244 DCHECK_CURRENTLY_ON(web::WebThread::IO);
1248 std::set<net::URLRequest*>::iterator it; 1245 std::set<net::URLRequest*>::iterator it;
1249 // TODO(droger): When canceling the request, we should in theory make sure 1246 // TODO(droger): When canceling the request, we should in theory make sure
1250 // that the NSURLProtocol client method |didFailWithError| is called, 1247 // that the NSURLProtocol client method |didFailWithError| is called,
1251 // otherwise the iOS system may wait indefinitely for the request to complete. 1248 // otherwise the iOS system may wait indefinitely for the request to complete.
1252 // However, as we currently only cancel the requests when closing a tab, the 1249 // However, as we currently only cancel the requests when closing a tab, the
1253 // requests are all canceled by the system shortly after and nothing bad 1250 // requests are all canceled by the system shortly after and nothing bad
1254 // happens. 1251 // happens.
1255 for (it = live_requests_.begin(); it != live_requests_.end(); ++it) 1252 for (it = live_requests_.begin(); it != live_requests_.end(); ++it)
1256 (*it)->Cancel(); 1253 (*it)->Cancel();
1257 1254
1258 live_requests_.clear(); 1255 live_requests_.clear();
1259 } 1256 }
1260 1257
1261 void RequestTrackerImpl::SetCertificatePolicyCacheForTest( 1258 void RequestTrackerImpl::SetCertificatePolicyCacheForTest(
1262 web::CertificatePolicyCache* cache) { 1259 web::CertificatePolicyCache* cache) {
1263 policy_cache_ = cache; 1260 policy_cache_ = cache;
1264 } 1261 }
1265 1262
1266 } // namespace web 1263 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/net/request_tracker_impl.h ('k') | ios/web/net/request_tracker_impl_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698