Commit b763d7f0 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Replace use of std containers with WTF's equivalents in previews_resource_loading_hints.h

This CL replaces the use of std::vector of std container with
WTF::Vector in previews_resource_loading_hints.h.

Bug: 952716
Change-Id: Ide7b17540d17c4ff48d594ad3b4646c714232c56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1678036Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#672448}
parent 4ad26a41
...@@ -34,7 +34,7 @@ String GetConsoleLogStringForBlockedLoad(const KURL& url) { ...@@ -34,7 +34,7 @@ String GetConsoleLogStringForBlockedLoad(const KURL& url) {
PreviewsResourceLoadingHints* PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* PreviewsResourceLoadingHints::Create(
ExecutionContext& execution_context, ExecutionContext& execution_context,
int64_t ukm_source_id, int64_t ukm_source_id,
const std::vector<WTF::String>& subresource_patterns_to_block) { const Vector<WTF::String>& subresource_patterns_to_block) {
return MakeGarbageCollected<PreviewsResourceLoadingHints>( return MakeGarbageCollected<PreviewsResourceLoadingHints>(
&execution_context, ukm_source_id, subresource_patterns_to_block); &execution_context, ukm_source_id, subresource_patterns_to_block);
} }
...@@ -42,14 +42,14 @@ PreviewsResourceLoadingHints* PreviewsResourceLoadingHints::Create( ...@@ -42,14 +42,14 @@ PreviewsResourceLoadingHints* PreviewsResourceLoadingHints::Create(
PreviewsResourceLoadingHints::PreviewsResourceLoadingHints( PreviewsResourceLoadingHints::PreviewsResourceLoadingHints(
ExecutionContext* execution_context, ExecutionContext* execution_context,
int64_t ukm_source_id, int64_t ukm_source_id,
const std::vector<WTF::String>& subresource_patterns_to_block) const Vector<WTF::String>& subresource_patterns_to_block)
: execution_context_(execution_context), : execution_context_(execution_context),
ukm_source_id_(ukm_source_id), ukm_source_id_(ukm_source_id),
subresource_patterns_to_block_(subresource_patterns_to_block) { subresource_patterns_to_block_(subresource_patterns_to_block) {
DCHECK_NE(ukm::kInvalidSourceId, ukm_source_id_); DCHECK_NE(ukm::kInvalidSourceId, ukm_source_id_);
subresource_patterns_to_block_usage_.assign( subresource_patterns_to_block_usage_.Fill(
subresource_patterns_to_block.size(), false); false, subresource_patterns_to_block.size());
blocked_resource_load_priority_counts_.fill(0); blocked_resource_load_priority_counts_.fill(0);
// Populate which specific resource types are eligible for blocking. // Populate which specific resource types are eligible for blocking.
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/platform/loader/fetch/resource.h" #include "third_party/blink/renderer/platform/loader/fetch/resource.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h" #include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace ukm { namespace ukm {
class UkmRecorder; class UkmRecorder;
...@@ -32,12 +33,12 @@ class CORE_EXPORT PreviewsResourceLoadingHints final ...@@ -32,12 +33,12 @@ class CORE_EXPORT PreviewsResourceLoadingHints final
static PreviewsResourceLoadingHints* Create( static PreviewsResourceLoadingHints* Create(
ExecutionContext& execution_context, ExecutionContext& execution_context,
int64_t ukm_source_id, int64_t ukm_source_id,
const std::vector<WTF::String>& subresource_patterns_to_block); const Vector<WTF::String>& subresource_patterns_to_block);
PreviewsResourceLoadingHints( PreviewsResourceLoadingHints(
ExecutionContext* execution_context, ExecutionContext* execution_context,
int64_t ukm_source_id, int64_t ukm_source_id,
const std::vector<WTF::String>& subresource_patterns_to_block); const Vector<WTF::String>& subresource_patterns_to_block);
~PreviewsResourceLoadingHints(); ~PreviewsResourceLoadingHints();
// Returns true if load of resource with type |type|, URL |resource_url| // Returns true if load of resource with type |type|, URL |resource_url|
...@@ -66,7 +67,7 @@ class CORE_EXPORT PreviewsResourceLoadingHints final ...@@ -66,7 +67,7 @@ class CORE_EXPORT PreviewsResourceLoadingHints final
// WTF::String. If a subresource URL contains any of the strings specified in // WTF::String. If a subresource URL contains any of the strings specified in
// |subresource_patterns_to_block_|, then that subresource's loading could // |subresource_patterns_to_block_|, then that subresource's loading could
// be blocked. // be blocked.
const std::vector<WTF::String> subresource_patterns_to_block_; const Vector<WTF::String> subresource_patterns_to_block_;
// True if resource blocking hints should apply to resource of a given type. // True if resource blocking hints should apply to resource of a given type.
bool block_resource_type_[static_cast<int>(ResourceType::kMaxValue) + 1] = { bool block_resource_type_[static_cast<int>(ResourceType::kMaxValue) + 1] = {
...@@ -74,7 +75,7 @@ class CORE_EXPORT PreviewsResourceLoadingHints final ...@@ -74,7 +75,7 @@ class CORE_EXPORT PreviewsResourceLoadingHints final
// |subresource_patterns_to_block_usage_| records whether the pattern located // |subresource_patterns_to_block_usage_| records whether the pattern located
// at the same index in |subresource_patterns_to_block_| was ever blocked. // at the same index in |subresource_patterns_to_block_| was ever blocked.
mutable std::vector<bool> subresource_patterns_to_block_usage_; mutable Vector<bool> subresource_patterns_to_block_usage_;
// |blocked_resource_load_priority_counts_| records the total number of // |blocked_resource_load_priority_counts_| records the total number of
// resources blocked at each ResourceLoadPriority. // resources blocked at each ResourceLoadPriority.
......
...@@ -30,7 +30,7 @@ void PreviewsResourceLoadingHintsReceiverImpl::SetResourceLoadingHints( ...@@ -30,7 +30,7 @@ void PreviewsResourceLoadingHintsReceiverImpl::SetResourceLoadingHints(
"ResourceLoadingHints.CountBlockedSubresourcePatterns", "ResourceLoadingHints.CountBlockedSubresourcePatterns",
resource_loading_hints->subresources_to_block.size()); resource_loading_hints->subresources_to_block.size());
std::vector<WTF::String> subresource_patterns_to_block; Vector<WTF::String> subresource_patterns_to_block;
for (const auto& subresource : for (const auto& subresource :
resource_loading_hints->subresources_to_block) { resource_loading_hints->subresources_to_block) {
subresource_patterns_to_block.push_back(subresource); subresource_patterns_to_block.push_back(subresource);
......
...@@ -40,7 +40,7 @@ class PreviewsResourceLoadingHintsTest : public PageTestBase { ...@@ -40,7 +40,7 @@ class PreviewsResourceLoadingHintsTest : public PageTestBase {
}; };
TEST_F(PreviewsResourceLoadingHintsTest, NoPatterns) { TEST_F(PreviewsResourceLoadingHintsTest, NoPatterns) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create(
dummy_page_holder_->GetDocument(), ukm::UkmRecorder::GetNewSourceID(), dummy_page_holder_->GetDocument(), ukm::UkmRecorder::GetNewSourceID(),
...@@ -51,7 +51,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, NoPatterns) { ...@@ -51,7 +51,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, NoPatterns) {
} }
TEST_F(PreviewsResourceLoadingHintsTest, OnePattern) { TEST_F(PreviewsResourceLoadingHintsTest, OnePattern) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back("foo.jpg"); subresources_to_block.push_back("foo.jpg");
PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create(
...@@ -112,7 +112,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, OnePattern) { ...@@ -112,7 +112,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, OnePattern) {
} }
TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatterns) { TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatterns) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back(".example1.com/foo.jpg"); subresources_to_block.push_back(".example1.com/foo.jpg");
subresources_to_block.push_back(".example1.com/bar.jpg"); subresources_to_block.push_back(".example1.com/bar.jpg");
subresources_to_block.push_back(".example2.com/baz.jpg"); subresources_to_block.push_back(".example2.com/baz.jpg");
...@@ -146,7 +146,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatterns) { ...@@ -146,7 +146,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatterns) {
} }
TEST_F(PreviewsResourceLoadingHintsTest, OnePatternHistogramChecker) { TEST_F(PreviewsResourceLoadingHintsTest, OnePatternHistogramChecker) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back("foo.jpg"); subresources_to_block.push_back("foo.jpg");
PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create(
...@@ -199,7 +199,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, OnePatternHistogramChecker) { ...@@ -199,7 +199,7 @@ TEST_F(PreviewsResourceLoadingHintsTest, OnePatternHistogramChecker) {
} }
TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatternUKMChecker) { TEST_F(PreviewsResourceLoadingHintsTest, MultiplePatternUKMChecker) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back(".example1.com/low_1.jpg"); subresources_to_block.push_back(".example1.com/low_1.jpg");
subresources_to_block.push_back(".example1.com/very_low_1.jpg"); subresources_to_block.push_back(".example1.com/very_low_1.jpg");
subresources_to_block.push_back(".example1.com/very_high_1.jpg"); subresources_to_block.push_back(".example1.com/very_high_1.jpg");
...@@ -298,7 +298,7 @@ class PreviewsResourceLoadingHintsTestBlockImages ...@@ -298,7 +298,7 @@ class PreviewsResourceLoadingHintsTestBlockImages
TEST_F(PreviewsResourceLoadingHintsTestBlockImages, TEST_F(PreviewsResourceLoadingHintsTestBlockImages,
OnePatternWithResourceSubtype) { OnePatternWithResourceSubtype) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back("foo.jpg"); subresources_to_block.push_back("foo.jpg");
PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create(
...@@ -354,7 +354,7 @@ class PreviewsResourceLoadingHintsTestAllowCSS ...@@ -354,7 +354,7 @@ class PreviewsResourceLoadingHintsTestAllowCSS
TEST_F(PreviewsResourceLoadingHintsTestAllowCSS, TEST_F(PreviewsResourceLoadingHintsTestAllowCSS,
OnePatternWithResourceSubtype) { OnePatternWithResourceSubtype) {
std::vector<WTF::String> subresources_to_block; Vector<WTF::String> subresources_to_block;
subresources_to_block.push_back("foo.jpg"); subresources_to_block.push_back("foo.jpg");
PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create( PreviewsResourceLoadingHints* hints = PreviewsResourceLoadingHints::Create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment