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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/net/request_tracker_impl.mm
diff --git a/ios/web/net/request_tracker_impl.mm b/ios/web/net/request_tracker_impl.mm
index 5a6014fd0d59af7103b7329f8d1ba11080f9dfff..bc0986f98fe25f69cf509e57b8b4e29dc35b757e 100644
--- a/ios/web/net/request_tracker_impl.mm
+++ b/ios/web/net/request_tracker_impl.mm
@@ -15,6 +15,7 @@
#import "base/mac/bind_objc_block.h"
#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/synchronization/lock.h"
@@ -487,10 +488,10 @@ void RequestTrackerImpl::StartRequest(net::URLRequest* request) {
new_estimate_round_ = false;
}
const GURL& url = request->original_url();
- TrackerCounts* counts = new TrackerCounts(
- GURLByRemovingRefFromGURL(url), request);
- counts_.push_back(counts);
- counts_by_request_[request] = counts;
+ auto counts =
+ base::MakeUnique<TrackerCounts>(GURLByRemovingRefFromGURL(url), request);
+ counts_by_request_[request] = counts.get();
+ counts_.push_back(std::move(counts));
if (page_url_.SchemeIsCryptographic() && !url.SchemeIsCryptographic())
has_mixed_content_ = true;
Notify();
@@ -787,17 +788,17 @@ void RequestTrackerImpl::SSLNotify() {
return;
const GURL page_origin = page_url_.GetOrigin();
- ScopedVector<TrackerCounts>::iterator it;
- for (it = counts_.begin(); it != counts_.end(); ++it) {
- if (!(*it)->ssl_info.is_valid())
+ for (const auto& tracker_count : counts_) {
+ if (!tracker_count->ssl_info.is_valid())
continue; // No SSL info at this point in time on this tracker.
- GURL request_origin = (*it)->url.GetOrigin();
+ GURL request_origin = tracker_count->url.GetOrigin();
if (request_origin != page_origin)
continue; // Not interesting in the context of the page.
- base::scoped_nsobject<CRWSSLCarrier> carrier(
- [[CRWSSLCarrier alloc] initWithTracker:this counts:*it]);
+ base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc]
+ initWithTracker:this
+ counts:tracker_count.get()]);
web::WebThread::PostTask(
web::WebThread::UI, FROM_HERE,
base::Bind(&RequestTrackerImpl::NotifyUpdatedSSLStatus, this, carrier));
@@ -927,26 +928,25 @@ void RequestTrackerImpl::ReevaluateCallbacksForAllCounts() {
if (is_closing_)
return;
- ScopedVector<TrackerCounts>::iterator it;
- for (it = counts_.begin(); it != counts_.end(); ++it) {
+ for (const auto& tracker_count : counts_) {
// Check if the value hasn't changed via a user action.
- if ((*it)->ssl_judgment == CertPolicy::UNKNOWN)
- EvaluateSSLCallbackForCounts(*it);
+ if (tracker_count->ssl_judgment == CertPolicy::UNKNOWN)
+ EvaluateSSLCallbackForCounts(tracker_count.get());
- CertPolicy::Judgment judgment = (*it)->ssl_judgment;
+ CertPolicy::Judgment judgment = tracker_count->ssl_judgment;
if (judgment == CertPolicy::ALLOWED)
continue;
// SSL errors on subrequests are simply ignored. The call to
// EvaluateSSLCallbackForCounts() cancelled the request and nothing will
// restart it.
- if ((*it)->is_subrequest)
+ if (tracker_count->is_subrequest)
continue;
if (!current_ssl_error_) {
// For the UNKNOWN and DENIED state the information should be pushed to
// the delegate. But only one at a time.
- current_ssl_error_ = (*it);
+ current_ssl_error_ = tracker_count.get();
base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc]
initWithTracker:this counts:current_ssl_error_]);
web::WebThread::PostTask(
@@ -972,11 +972,9 @@ PageCounts RequestTrackerImpl::pageCounts() {
PageCounts page_counts;
- ScopedVector<TrackerCounts>::iterator it;
- for (it = counts_.begin() + estimate_start_index_;
- it != counts_.end(); ++it) {
- if ((*it)->done) {
- uint64_t size = (*it)->processed;
+ for (const auto& tracker_count : counts_) {
+ if (tracker_count->done) {
+ uint64_t size = tracker_count->processed;
page_counts.finished += 1;
page_counts.finished_bytes += size;
if (page_counts.largest_byte_size_known < size) {
@@ -984,16 +982,17 @@ PageCounts RequestTrackerImpl::pageCounts() {
}
} else {
page_counts.unfinished += 1;
- if ((*it)->expected_length) {
- uint64_t size = (*it)->expected_length;
- page_counts.unfinished_estimate_bytes_done += (*it)->processed;
+ if (tracker_count->expected_length) {
+ uint64_t size = tracker_count->expected_length;
+ page_counts.unfinished_estimate_bytes_done += tracker_count->processed;
page_counts.unfinished_estimated_bytes_left += size;
if (page_counts.largest_byte_size_known < size) {
page_counts.largest_byte_size_known = size;
}
} else {
page_counts.unfinished_no_estimate += 1;
- page_counts.unfinished_no_estimate_bytes_done += (*it)->processed;
+ page_counts.unfinished_no_estimate_bytes_done +=
+ tracker_count->processed;
}
}
}
@@ -1081,8 +1080,8 @@ void RequestTrackerImpl::RecomputeMixedContent(
if (page_url_.SchemeIsCryptographic() && has_mixed_content_) {
bool old_url_has_mixed_content = false;
const GURL origin = page_url_.GetOrigin();
- ScopedVector<TrackerCounts>::iterator it = counts_.begin();
- while (it != counts_.end() && *it != split_position) {
+ auto it = counts_.begin();
+ while (it != counts_.end() && it->get() != split_position) {
if (!(*it)->url.SchemeIsCryptographic() &&
origin == (*it)->first_party_for_cookies_origin) {
old_url_has_mixed_content = true;
@@ -1110,9 +1109,8 @@ void RequestTrackerImpl::RecomputeCertificatePolicy(
web::WebThread::UI, FROM_HERE,
base::Bind(&RequestTrackerImpl::NotifyClearCertificates, this));
// Report judgements for the new URL.
- ScopedVector<TrackerCounts>::const_reverse_iterator it;
- for (it = counts_.rbegin(); it != counts_.rend(); ++it) {
- TrackerCounts* counts = *it;
+ for (auto it = counts_.rbegin(); it != counts_.rend(); ++it) {
+ TrackerCounts* counts = it->get();
if (counts->allowed_by_user) {
std::string host = counts->url.host();
web::WebThread::PostTask(
@@ -1144,7 +1142,7 @@ void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
// Locate the request with this url, if present.
bool new_url_has_mixed_content = false;
bool url_scheme_is_secure = url.SchemeIsCryptographic();
- ScopedVector<TrackerCounts>::const_reverse_iterator rit = counts_.rbegin();
+ auto rit = counts_.rbegin();
while (rit != counts_.rend() && (*rit)->url != url) {
if (url_scheme_is_secure && !(*rit)->url.SchemeIsCryptographic() &&
(*rit)->first_party_for_cookies_origin == url.GetOrigin()) {
@@ -1156,7 +1154,7 @@ void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
// |split_position| will be set to the count for the passed url if it exists.
TrackerCounts* split_position = NULL;
if (rit != counts_.rend()) {
- split_position = (*rit);
+ split_position = rit->get();
} else {
// The URL was not found, everything will be trimmed. The mixed content
// calculation is invalid.
@@ -1169,7 +1167,7 @@ void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
// domain as the page itself this will allow retrieval of the SSL
// information.
if (url_scheme_is_secure && counts_.size()) {
- TrackerCounts* back = counts_.back();
+ TrackerCounts* back = counts_.back().get();
const GURL& back_url = back->url;
if (back_url.SchemeIsCryptographic() &&
back_url.GetOrigin() == url.GetOrigin() && !back->is_subrequest) {
@@ -1181,13 +1179,13 @@ void RequestTrackerImpl::TrimToURL(const GURL& full_url, id user_info) {
RecomputeCertificatePolicy(split_position);
// Trim up to that element.
- ScopedVector<TrackerCounts>::iterator it = counts_.begin();
- while (it != counts_.end() && *it != split_position) {
+ auto it = counts_.begin();
+ while (it != counts_.end() && it->get() != split_position) {
if (!(*it)->done) {
// This is for an unfinished request on a previous page. We do not care
// about those anymore. Cancel the request.
if ((*it)->ssl_judgment == CertPolicy::UNKNOWN)
- CancelRequestForCounts(*it);
+ CancelRequestForCounts(it->get());
counts_by_request_.erase((*it)->request);
}
it = counts_.erase(it);
@@ -1233,9 +1231,8 @@ NSString* RequestTrackerImpl::UnsafeDescription() {
DCHECK_CURRENTLY_ON(web::WebThread::IO);
NSMutableArray* urls = [NSMutableArray array];
- ScopedVector<TrackerCounts>::iterator it;
- for (it = counts_.begin(); it != counts_.end(); ++it)
- [urls addObject:(*it)->Description()];
+ for (const auto& tracker_count : counts_)
+ [urls addObject:tracker_count->Description()];
return [NSString stringWithFormat:@"RequestGroupID %@\n%@\n%@",
request_group_id_.get(),
« 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