0

Fix some instances of -Wshadow.

Bug: 794619
Change-Id: I04381aa8fe38386c48581759b1b8750ad3f5c447
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3095662
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Roger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#912811}
This commit is contained in:
Peter Kasting
2021-08-18 00:04:11 +00:00
committed by Chromium LUCI CQ
parent 74555fc52c
commit 2ae7dcdb7d
44 changed files with 196 additions and 186 deletions

@ -32,17 +32,21 @@ class MyInstance : public pp::Instance {
pp::Graphics2D graphics(this, last_size_, false);
BindGraphics(graphics);
pp::BrowserFontDescription desc;
desc.set_family(PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF);
desc.set_size(100);
pp::BrowserFont_Trusted font(this, desc);
{
pp::BrowserFontDescription desc;
desc.set_family(PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF);
desc.set_size(100);
pp::BrowserFont_Trusted font(this, desc);
// Draw some large, alpha blended text, including Arabic shaping.
pp::Rect text_clip(position.size()); // Use entire bounds for clip.
font.DrawTextAt(&image,
pp::BrowserFontTextRun(
"\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7\xE2\x80\x8E", true, true),
pp::Point(20, 100), 0x80008000, clip, false);
// Draw some large, alpha blended text, including Arabic shaping.
pp::Rect text_clip(position.size()); // Use entire bounds for clip.
font.DrawTextAt(
&image,
pp::BrowserFontTextRun(
"\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7\xE2\x80\x8E", true,
true),
pp::Point(20, 100), 0x80008000, clip, false);
}
// Draw the default font names and sizes.
int y = 160;

@ -287,7 +287,7 @@ int32_t FileIOResource::Write(int64_t offset,
if (append) {
increase = bytes_to_write;
} else {
uint64_t max_offset = offset + bytes_to_write;
max_offset = offset + bytes_to_write;
if (max_offset >
static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
return PP_ERROR_FAILED; // amount calculation would overflow.

@ -23,24 +23,24 @@ namespace {
// This is an ad-hoc mock of PPP_Messaging using global variables. Eventually,
// generalize making PPAPI interface mocks by using IDL or macro/template magic.
PP_Instance received_instance;
PP_Var received_var;
PP_Instance g_received_instance;
PP_Var g_received_var;
base::WaitableEvent handle_message_called(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
void HandleMessage(PP_Instance instance, PP_Var message_data) {
received_instance = instance;
received_var = message_data;
g_received_instance = instance;
g_received_var = message_data;
handle_message_called.Signal();
}
// Clear all the 'received' values for our mock. Call this before you expect
// one of the functions to be invoked.
void ResetReceived() {
received_instance = 0;
received_var.type = PP_VARTYPE_UNDEFINED;
received_var.value.as_id = 0;
g_received_instance = 0;
g_received_var.type = PP_VARTYPE_UNDEFINED;
g_received_var.value.as_id = 0;
}
PPP_Messaging ppp_messaging_mock = {
@ -90,39 +90,39 @@ TEST_F(PPP_Messaging_ProxyTest, SendMessages) {
Dispatcher* host_dispatcher = host().GetDispatcher();
CallHandleMessage(host_dispatcher, expected_instance, expected_var);
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
expected_var = PP_MakeNull();
ResetReceived();
CallHandleMessage(host_dispatcher, expected_instance, expected_var);
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
expected_var = PP_MakeBool(PP_TRUE);
ResetReceived();
CallHandleMessage(host_dispatcher, expected_instance, expected_var);
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_var.value.as_bool, received_var.value.as_bool);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
EXPECT_EQ(expected_var.value.as_bool, g_received_var.value.as_bool);
expected_var = PP_MakeInt32(12345);
ResetReceived();
CallHandleMessage(host_dispatcher, expected_instance, expected_var);
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_var.value.as_int, received_var.value.as_int);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
EXPECT_EQ(expected_var.value.as_int, g_received_var.value.as_int);
expected_var = PP_MakeDouble(3.1415);
ResetReceived();
CallHandleMessage(host_dispatcher, expected_instance, expected_var);
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_var.value.as_double, received_var.value.as_double);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
EXPECT_EQ(expected_var.value.as_double, g_received_var.value.as_double);
const std::string kTestString("Hello world!");
expected_var = StringVar::StringToPPVar(kTestString);
@ -134,10 +134,10 @@ TEST_F(PPP_Messaging_ProxyTest, SendMessages) {
EXPECT_FALSE(StringVar::FromPPVar(expected_var));
handle_message_called.Wait();
EXPECT_EQ(expected_instance, received_instance);
EXPECT_EQ(expected_var.type, received_var.type);
EXPECT_EQ(expected_instance, g_received_instance);
EXPECT_EQ(expected_var.type, g_received_var.type);
PostTaskOnRemoteHarness(base::BindOnce(CompareAndReleaseStringVar, &plugin(),
received_var, kTestString));
g_received_var, kTestString));
}
} // namespace proxy

@ -163,7 +163,7 @@ std::string TestAudio::TestCreation() {
sample_rate == PP_AUDIOSAMPLERATE_44100 ||
sample_rate == PP_AUDIOSAMPLERATE_48000);
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSampleRates); i++) {
PP_AudioSampleRate sample_rate = kSampleRates[i];
sample_rate = kSampleRates[i];
for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kRequestFrameCounts); j++) {
// Make a config, create the audio resource, and release the config.

@ -466,8 +466,8 @@ std::string TestPostMessage::TestSendingArrayBuffer() {
// we get the _same_ buffer back when it's transferred.
if (sizes[i] > 0)
ASSERT_NE(buff, received_buff);
for (size_t i = 0; i < test_data.ByteLength(); ++i)
ASSERT_EQ(buff[i], received_buff[i]);
for (size_t byte = 0; byte < test_data.ByteLength(); ++byte)
ASSERT_EQ(buff[byte], received_buff[byte]);
message_data_.clear();
ASSERT_TRUE(ClearListeners());

@ -138,11 +138,13 @@ std::string TestTCPSocket::TestConnect() {
std::string TestTCPSocket::TestReadWrite() {
pp::TCPSocket socket(instance_);
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
{
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
cb.WaitForResult(socket.Connect(test_server_addr_, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
cb.WaitForResult(socket.Connect(test_server_addr_, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
}
ASSERT_SUBTEST_SUCCESS(WriteToSocket(&socket, "GET / HTTP/1.0\r\n\r\n"));
@ -509,10 +511,12 @@ std::string TestTCPSocket::TestConnectHangs() {
std::string TestTCPSocket::TestWriteFails() {
pp::TCPSocket socket(instance_);
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
cb.WaitForResult(socket.Connect(test_server_addr_, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
{
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
cb.WaitForResult(socket.Connect(test_server_addr_, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
}
// Write to the socket until there's an error. Some writes may succeed, since
// Mojo writes complete before the socket tries to send data. As with the read

@ -259,15 +259,17 @@ std::string TestTCPSocketPrivate::TestSSLHandshakeHangs() {
std::string TestTCPSocketPrivate::TestSSLWriteFails() {
pp::TCPSocketPrivate socket(instance_);
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
{
TestCompletionCallback cb(instance_->pp_instance(), callback_type());
cb.WaitForResult(socket.Connect("foo.test", 443, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
cb.WaitForResult(socket.Connect("foo.test", 443, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
cb.WaitForResult(socket.SSLHandshake("foo.test", 443, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
cb.WaitForResult(socket.SSLHandshake("foo.test", 443, cb.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(cb);
ASSERT_EQ(PP_OK, cb.result());
}
// Write to the socket until there's an error. Some writes may succeed, since
// Mojo writes complete before the socket tries to send data.

@ -251,7 +251,7 @@ void AudioCapturerWin::DoCapture() {
HRESULT hr = S_OK;
while (true) {
UINT32 next_packet_size;
HRESULT hr = audio_capture_client_->GetNextPacketSize(&next_packet_size);
hr = audio_capture_client_->GetNextPacketSize(&next_packet_size);
if (FAILED(hr))
break;

@ -834,8 +834,7 @@ void ClientSession::OnDesktopDisplayChanged(
protocol::VideoTrackLayout display = displays->video_track(display_id);
desktop_display_info_.AddDisplayFrom(display);
protocol::VideoTrackLayout* video_track = layout.add_video_track();
video_track->CopyFrom(display);
layout.add_video_track()->CopyFrom(display);
LOG(INFO) << " Display " << display_id << " = " << display.position_x()
<< "," << display.position_y() << " " << display.width() << "x"
<< display.height() << " [" << display.x_dpi() << ","

@ -166,9 +166,9 @@ void ResizingHostObserver::SetScreenResolution(
return;
} else {
LOG(INFO) << "Found host resolutions:";
for (const auto& resolution : resolutions) {
LOG(INFO) << " " << resolution.dimensions().width() << "x"
<< resolution.dimensions().height();
for (const auto& host_resolution : resolutions) {
LOG(INFO) << " " << host_resolution.dimensions().width() << "x"
<< host_resolution.dimensions().height();
}
}
CandidateResolution best_candidate(resolutions.front(), resolution);

@ -305,7 +305,7 @@ protocol::TokenValidator::ValidationResult TokenValidatorBase::ProcessResponse(
size_t start_pos = data_.find(kForbiddenExceptionToken);
if (start_pos != std::string::npos) {
if (data_.find(kAuthzDeniedErrorCode, start_pos) != std::string::npos) {
return RejectionReason::AUTHZ_POLICY_CHECK_FAILED;
return RejectionReason::AUTHORIZATION_POLICY_CHECK_FAILED;
}
}
}

@ -68,7 +68,7 @@ class Authenticator {
INVALID_CREDENTIALS,
// The client JID was not valid (i.e. violated a policy or was malformed).
INVALID_ACCOUNT,
INVALID_ACCOUNT_ID,
// Generic error used when something goes wrong establishing a session.
PROTOCOL_ERROR,
@ -81,7 +81,7 @@ class Authenticator {
// The client is not authorized to connect to this device due to a policy
// defined by the third party auth service.
AUTHZ_POLICY_CHECK_FAILED,
AUTHORIZATION_POLICY_CHECK_FAILED,
};
// Callback used for layered Authenticator implementations, particularly

@ -446,29 +446,29 @@ std::unique_ptr<jingle_xmpp::XmlElement> JingleMessageReply::ToXml(
new jingle_xmpp::XmlElement(QName(kJabberNamespace, "error"));
iq->AddElement(error);
std::string type;
std::string type_attr;
std::string error_text;
QName name;
switch (error_type) {
case BAD_REQUEST:
type = "modify";
type_attr = "modify";
name = QName(kJabberNamespace, "bad-request");
break;
case NOT_IMPLEMENTED:
type = "cancel";
type_attr = "cancel";
name = QName(kJabberNamespace, "feature-bad-request");
break;
case INVALID_SID:
type = "modify";
type_attr = "modify";
name = QName(kJabberNamespace, "item-not-found");
error_text = "Invalid SID";
break;
case UNEXPECTED_REQUEST:
type = "modify";
type_attr = "modify";
name = QName(kJabberNamespace, "unexpected-request");
break;
case UNSUPPORTED_INFO:
type = "modify";
type_attr = "modify";
name = QName(kJabberNamespace, "feature-not-implemented");
break;
default:
@ -479,7 +479,7 @@ std::unique_ptr<jingle_xmpp::XmlElement> JingleMessageReply::ToXml(
error_text = text;
}
error->SetAttr(QName(kEmptyNamespace, "type"), type);
error->SetAttr(QName(kEmptyNamespace, "type"), type_attr);
// If the error name is not in the standard namespace, we have
// to first add some error from that namespace.

@ -69,13 +69,13 @@ ErrorCode AuthRejectionReasonToErrorCode(
return AUTHENTICATION_FAILED;
case Authenticator::PROTOCOL_ERROR:
return INCOMPATIBLE_PROTOCOL;
case Authenticator::INVALID_ACCOUNT:
case Authenticator::INVALID_ACCOUNT_ID:
return INVALID_ACCOUNT;
case Authenticator::TOO_MANY_CONNECTIONS:
return SESSION_REJECTED;
case Authenticator::REJECTED_BY_USER:
return SESSION_REJECTED;
case Authenticator::AUTHZ_POLICY_CHECK_FAILED:
case Authenticator::AUTHORIZATION_POLICY_CHECK_FAILED:
return AUTHZ_POLICY_CHECK_FAILED;
}
NOTREACHED();
@ -524,9 +524,9 @@ void JingleSession::OnIncomingMessage(const std::string& id,
std::vector<PendingMessage> ordered = message_queue_->OnIncomingMessage(
id, PendingMessage{std::move(message), std::move(reply_callback)});
base::WeakPtr<JingleSession> self = weak_factory_.GetWeakPtr();
for (auto& message : ordered) {
ProcessIncomingMessage(std::move(message.message),
std::move(message.reply_callback));
for (auto& pending_message : ordered) {
ProcessIncomingMessage(std::move(pending_message.message),
std::move(pending_message.reply_callback));
if (!self)
return;
}

@ -70,8 +70,8 @@ bool JingleSessionManager::OnSignalStrategyIncomingStanza(
std::unique_ptr<jingle_xmpp::XmlElement> stanza_copy(new jingle_xmpp::XmlElement(*stanza));
std::unique_ptr<JingleMessage> message(new JingleMessage());
std::string error;
if (!message->ParseXml(stanza, &error)) {
std::string error_msg;
if (!message->ParseXml(stanza, &error_msg)) {
SendReply(std::move(stanza_copy), JingleMessageReply::BAD_REQUEST);
return true;
}

@ -102,7 +102,7 @@ Me2MeHostAuthenticatorFactory::CreateAuthenticator(
LOG(ERROR) << "Rejecting incoming connection from " << remote_jid
<< ": Domain not allowed.";
return std::make_unique<RejectingAuthenticator>(
Authenticator::INVALID_ACCOUNT);
Authenticator::INVALID_ACCOUNT_ID);
}
}

@ -98,7 +98,7 @@ void ValidatingAuthenticator::OnValidateComplete(base::OnceClosure callback,
break;
case Result::ERROR_INVALID_ACCOUNT:
rejection_reason_ = Authenticator::INVALID_ACCOUNT;
rejection_reason_ = Authenticator::INVALID_ACCOUNT_ID;
break;
case Result::ERROR_TOO_MANY_CONNECTIONS:

@ -299,13 +299,13 @@ TEST_F(ValidatingAuthenticatorTest, InvalidConnection_InvalidAccount) {
.WillByDefault(Return(Authenticator::REJECTED));
ON_CALL(*mock_authenticator_, rejection_reason())
.WillByDefault(Return(Authenticator::INVALID_ACCOUNT));
.WillByDefault(Return(Authenticator::INVALID_ACCOUNT_ID));
// Verify validation callback is not called for invalid connections.
SendMessageAndWaitForCallback();
ASSERT_FALSE(validate_complete_called_);
ASSERT_EQ(Authenticator::REJECTED, validating_authenticator_->state());
ASSERT_EQ(Authenticator::INVALID_ACCOUNT,
ASSERT_EQ(Authenticator::INVALID_ACCOUNT_ID,
validating_authenticator_->rejection_reason());
}

@ -552,9 +552,10 @@ bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) {
UpdateCodecParameters(&sdp_message, /*incoming=*/true);
webrtc::SdpParseError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description(
webrtc::CreateSessionDescription(type, sdp_message.ToString(), &error));
if (!session_description) {
std::unique_ptr<webrtc::SessionDescriptionInterface>
webrtc_session_description(webrtc::CreateSessionDescription(
type, sdp_message.ToString(), &error));
if (!webrtc_session_description) {
LOG(ERROR) << "Failed to parse the session description: "
<< error.description << " line: " << error.line;
return false;
@ -565,7 +566,7 @@ bool WebrtcTransport::ProcessTransportInfo(XmlElement* transport_info) {
&WebrtcTransport::OnRemoteDescriptionSet,
weak_factory_.GetWeakPtr(),
type == webrtc::SessionDescriptionInterface::kOffer)),
session_description.release());
webrtc_session_description.release());
// SetRemoteDescription() might overwrite any bitrate caps previously set,
// so (re)apply them here. This might happen if ICE state were already

@ -100,8 +100,7 @@ CyclicFrameGenerator::ChangeInfoList CyclicFrameGenerator::GetChangeList(
for (int i = last_identifier_frame_ + 1; i <= frame_id; ++i) {
ChangeType type =
(i % frames_in_cycle == 0) ? ChangeType::FULL : ChangeType::CURSOR;
base::TimeTicks timestamp = started_time_ + i * cursor_blink_period_;
result.emplace_back(type, timestamp);
result.emplace_back(type, started_time_ + i * cursor_blink_period_);
}
last_identifier_frame_ = frame_id;

@ -34,8 +34,8 @@ TEST(LibValuesUnittest, GetAccessPointFromName) {
for (int ap = rlz_lib::NO_ACCESS_POINT + 1;
ap < rlz_lib::LAST_ACCESS_POINT; ++ap) {
rlz_lib::AccessPoint point = static_cast<rlz_lib::AccessPoint>(ap);
EXPECT_TRUE(GetAccessPointName(point) != NULL);
EXPECT_TRUE(GetAccessPointName(static_cast<rlz_lib::AccessPoint>(ap)) !=
NULL);
}
}

@ -58,10 +58,10 @@ void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) {
for (; i.Valid(); ++i) {
RegistryValue& value = *data->values.insert(data->values.end(),
RegistryValue());
const uint8_t* data = reinterpret_cast<const uint8_t*>(i.Value());
const uint8_t* value_bytes = reinterpret_cast<const uint8_t*>(i.Value());
value.name.assign(i.Name());
value.type = i.Type();
value.data.assign(data, data + i.ValueSize());
value.data.assign(value_bytes, value_bytes + i.ValueSize());
}
}

@ -244,9 +244,9 @@ TEST_F(AudioServiceOutputDeviceTest, MAYBE_VerifyDataFlow) {
env.reader->Read(test_bus.get());
Mock::VerifyAndClear(&env.render_callback);
for (int i = 0; i < kFrames; ++i) {
EXPECT_EQ(kAudioData, test_bus->channel(0)[i]);
EXPECT_EQ(kAudioData, test_bus->channel(1)[i]);
for (int frame = 0; frame < kFrames; ++frame) {
EXPECT_EQ(kAudioData, test_bus->channel(0)[frame]);
EXPECT_EQ(kAudioData, test_bus->channel(1)[frame]);
}
}
}
@ -306,10 +306,11 @@ TEST_F(AudioServiceOutputDeviceTest, CreateBitStreamStream) {
EXPECT_TRUE(test_bus->is_bitstream_format());
EXPECT_EQ(kBitstreamFrames, test_bus->GetBitstreamFrames());
EXPECT_EQ(kBitstreamDataSize, test_bus->GetBitstreamDataSize());
for (size_t i = 0; i < kBitstreamDataSize / sizeof(float); ++i) {
for (size_t datum = 0; datum < kBitstreamDataSize / sizeof(float);
++datum) {
// Note: if all of these fail, the bots will behave strangely due to the
// large amount of text output. Assert is used to avoid this.
ASSERT_EQ(kAudioData, test_bus->channel(0)[i]);
ASSERT_EQ(kAudioData, test_bus->channel(0)[datum]);
}
}

@ -577,7 +577,7 @@ TEST_P(SnooperNodeTest, SuggestsRenderTimes) {
const absl::optional<base::TimeTicks> first_suggestion =
node()->SuggestLatestRenderTime(output_params().frames_per_buffer());
ASSERT_TRUE(first_suggestion);
const base::TimeTicks time_at_end_of_input =
base::TimeTicks time_at_end_of_input =
first_input_time + input_params().GetBufferDuration();
const base::TimeDelta required_duration_buffered =
output_params().GetBufferDuration() * 3 / 2;
@ -606,8 +606,7 @@ TEST_P(SnooperNodeTest, SuggestsRenderTimes) {
const absl::optional<base::TimeTicks> next_suggestion =
node()->SuggestLatestRenderTime(output_params().frames_per_buffer());
ASSERT_TRUE(next_suggestion);
const base::TimeTicks time_at_end_of_input =
next_input_time + input_params().GetBufferDuration();
time_at_end_of_input = next_input_time + input_params().GetBufferDuration();
EXPECT_GT(time_at_end_of_input - required_duration_buffered,
*next_suggestion);
EXPECT_LT(

@ -145,9 +145,9 @@ TEST_F(ImageDecoderImplTest, DecodeImageSizeLimit) {
// Check that if resize not requested and image exceeds IPC size limit,
// an empty image is returned
if (heights[i] > max_height_for_msg) {
Request request(decoder());
request.DecodeImage(jpg, false);
EXPECT_TRUE(request.bitmap().isNull());
Request request2(decoder());
request2.DecodeImage(jpg, false);
EXPECT_TRUE(request2.bitmap().isNull());
}
#endif
}

@ -112,10 +112,10 @@ void MockMediaSessionMojoObserver::MediaSessionImagesChanged(
if (expected_images_of_type_.has_value()) {
auto type = expected_images_of_type_->first;
auto images = expected_images_of_type_->second;
auto expected_images = expected_images_of_type_->second;
auto it = session_images_->find(type);
if (it != session_images_->end() && it->second == images) {
if (it != session_images_->end() && it->second == expected_images) {
run_loop_->Quit();
expected_images_of_type_.reset();
}

@ -350,7 +350,6 @@ TEST_F(ChunkedDataPipeUploadDataStreamTest, GetSizeSucceedsBeforeInit) {
std::string read_data;
while (read_data.size() < kData.size()) {
net::TestCompletionCallback callback;
int read_size = kData.size() - read_data.size();
auto io_buffer = base::MakeRefCounted<net::IOBufferWithSize>(read_size);
int result = chunked_upload_stream_->Read(
@ -399,7 +398,6 @@ TEST_F(ChunkedDataPipeUploadDataStreamTest, GetSizeSucceedsAfterReset) {
read_data.erase();
mojo::BlockingCopyFromString(kData, write_pipe_);
while (read_data.size() < kData.size()) {
net::TestCompletionCallback callback;
int read_size = kData.size() - read_data.size();
auto io_buffer = base::MakeRefCounted<net::IOBufferWithSize>(read_size);
int result = chunked_upload_stream_->Read(
@ -801,24 +799,24 @@ TEST_F(ChunkedDataPipeUploadDataStreamTest,
net::NetLogWithSource()));
}
#define EXPECT_READ(chunked_upload_stream, io_buffer, expected) \
{ \
int result = chunked_upload_stream->Read(io_buffer.get(), \
io_buffer->size(), NoCallback()); \
EXPECT_GT(result, 0); \
EXPECT_EQ(std::string(io_buffer->data(), result), expected); \
#define EXPECT_READ(chunked_upload_stream, io_buffer, expected) \
{ \
int read_result = chunked_upload_stream->Read( \
io_buffer.get(), io_buffer->size(), NoCallback()); \
EXPECT_GT(read_result, 0); \
EXPECT_EQ(std::string(io_buffer->data(), read_result), expected); \
}
#define EXPECT_EOF(chunked_upload_stream, size) \
{ \
net::TestCompletionCallback callback; \
auto io_buffer = base::MakeRefCounted<net::IOBufferWithSize>(1); \
int result = \
chunked_upload_stream->Read(io_buffer.get(), 1u, callback.callback()); \
EXPECT_EQ(net::ERR_IO_PENDING, result); \
std::move(get_size_callback_).Run(net::OK, size); \
EXPECT_EQ(net::OK, callback.GetResult(result)); \
EXPECT_TRUE(chunked_upload_stream->IsEOF()); \
#define EXPECT_EOF(chunked_upload_stream, size) \
{ \
net::TestCompletionCallback test_callback; \
auto one_byte_io_buffer = base::MakeRefCounted<net::IOBufferWithSize>(1); \
int read_result = chunked_upload_stream->Read( \
one_byte_io_buffer.get(), 1u, test_callback.callback()); \
EXPECT_EQ(net::ERR_IO_PENDING, read_result); \
std::move(get_size_callback_).Run(net::OK, size); \
EXPECT_EQ(net::OK, test_callback.GetResult(read_result)); \
EXPECT_TRUE(chunked_upload_stream->IsEOF()); \
}
#define WRITE_DATA_SYNC(write_pipe, str) \

@ -162,23 +162,25 @@ CookieSettings::GetCookieSettingWithMetadata(
block_third_party_cookies_ && is_third_party_request &&
!base::Contains(third_party_cookies_allowed_schemes_,
first_party_url.scheme());
// `content_settings_` is sorted in order of precedence, so we use the first
// matching rule we find.
const auto& entry = base::ranges::find_if(
content_settings_, [&](const ContentSettingPatternSource& entry) {
// The primary pattern is for the request URL; the secondary pattern is
// for the first-party URL (which is the top-frame origin [if available]
// or the site-for-cookies).
return entry.primary_pattern.Matches(url) &&
entry.secondary_pattern.Matches(first_party_url);
});
if (entry != content_settings_.end()) {
cookie_setting = entry->GetContentSetting();
// Site-specific settings override the global "block third-party cookies"
// setting.
// Note: global settings are implemented as a catch-all (*, *) pattern.
if (IsExplicitSetting(*entry))
blocked_by_third_party_setting = false;
{
// `content_settings_` is sorted in order of precedence, so we use the first
// matching rule we find.
const auto& entry = base::ranges::find_if(
content_settings_, [&](const ContentSettingPatternSource& entry) {
// The primary pattern is for the request URL; the secondary pattern
// is for the first-party URL (which is the top-frame origin [if
// available] or the site-for-cookies).
return entry.primary_pattern.Matches(url) &&
entry.secondary_pattern.Matches(first_party_url);
});
if (entry != content_settings_.end()) {
cookie_setting = entry->GetContentSetting();
// Site-specific settings override the global "block third-party cookies"
// setting.
// Note: global settings are implemented as a catch-all (*, *) pattern.
if (IsExplicitSetting(*entry))
blocked_by_third_party_setting = false;
}
}
if (blocked_by_third_party_setting) {

@ -1407,7 +1407,7 @@ TEST_F(NetworkContextTest, P2PHostResolution) {
host_resolver.CreateRequest(kHostPortPair, other_nik,
net::NetLogWithSource(), params);
net::TestCompletionCallback callback2;
int result = request2->Start(callback2.callback());
result = request2->Start(callback2.callback());
EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, callback2.GetResult(result));
}
}

@ -48,16 +48,16 @@ absl::optional<OriginPolicyParsedHeader> OriginPolicyParsedHeader::FromString(
const sh::Item& item = parameterized_item.item;
if (item.is_string()) {
const std::string& string = item.GetString();
if (string.empty()) {
const std::string& item_string = item.GetString();
if (item_string.empty()) {
return absl::nullopt;
}
result = OriginPolicyAllowedValue::FromString(string);
result = OriginPolicyAllowedValue::FromString(item_string);
} else if (item.is_token()) {
const std::string& string = item.GetString();
if (string == "null") {
const std::string& item_string = item.GetString();
if (item_string == "null") {
result = OriginPolicyAllowedValue::Null();
} else if (string == "latest") {
} else if (item_string == "latest") {
result = OriginPolicyAllowedValue::Latest();
}
} else {
@ -78,14 +78,14 @@ absl::optional<OriginPolicyParsedHeader> OriginPolicyParsedHeader::FromString(
const sh::Item& item = parsed_header.at("preferred").member[0].item;
if (item.is_string()) {
const std::string& string = item.GetString();
if (string.empty()) {
const std::string& item_string = item.GetString();
if (item_string.empty()) {
return absl::nullopt;
}
preferred = OriginPolicyPreferredValue::FromString(string);
preferred = OriginPolicyPreferredValue::FromString(item_string);
} else if (item.is_token()) {
const std::string& string = item.GetString();
if (string == "latest-from-network") {
const std::string& item_string = item.GetString();
if (item_string == "latest-from-network") {
preferred = OriginPolicyPreferredValue::LatestFromNetwork();
}
} else {

@ -622,7 +622,7 @@ TEST(P2PSocketTcpWithPseudoTlsTest, Hostname) {
context.host_resolver()->CreateRequest(kHostPortPair, other_nik,
net::NetLogWithSource(), params);
net::TestCompletionCallback callback2;
int result = request2->Start(callback2.callback());
result = request2->Start(callback2.callback());
EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, callback2.GetResult(result));
}
}

@ -582,9 +582,10 @@ TEST_F(P2PSocketUdpTest, PortRangeImplicitPort) {
ParseAddress(kTestIpAddress1, kTestPort1)),
net::NetworkIsolationKey());
FakeDatagramServerSocket* socket = GetSocketFromHost(socket_impl.get());
FakeDatagramServerSocket* datagram_socket =
GetSocketFromHost(socket_impl.get());
net::IPEndPoint bound_address;
socket->GetLocalAddress(&bound_address);
datagram_socket->GetLocalAddress(&bound_address);
EXPECT_EQ(port, bound_address.port());
base::RunLoop().RunUntilIdle();

@ -99,10 +99,10 @@ class ProxyConfigServiceMojoTest : public testing::Test {
// changes when the ProxyConfig changes, and is not informed of them in the case
// of "changes" that result in the same ProxyConfig as before.
TEST_F(ProxyConfigServiceMojoTest, ObserveProxyChanges) {
net::ProxyConfigWithAnnotation proxy_config;
net::ProxyConfigWithAnnotation temp;
// The service should start without a config.
EXPECT_EQ(net::ProxyConfigService::CONFIG_PENDING,
proxy_config_service_.GetLatestProxyConfig(&proxy_config));
proxy_config_service_.GetLatestProxyConfig(&temp));
net::ProxyConfig proxy_configs[3];
proxy_configs[0].proxy_rules().ParseFromString("http=foopy:80");

@ -147,7 +147,7 @@ TEST_P(ProxyResolvingClientSocketTest, NetworkIsolationKeyDirect) {
kDestinationHostPortPair, other_nik, net::NetLogWithSource(),
params);
net::TestCompletionCallback callback3;
int result = request2->Start(callback3.callback());
result = request2->Start(callback3.callback());
EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, callback3.GetResult(result));
}
}

@ -107,10 +107,10 @@ TEST(CSPSourceList, AllowStar) {
{
// With a protocol of 'file', '*' allow 'file:'
auto self = network::mojom::CSPSource::New(
auto file = network::mojom::CSPSource::New(
"file", "example.com", url::PORT_UNSPECIFIED, "", false, false);
EXPECT_TRUE(Allow(source_list, GURL("file://not-example.com"), *self));
EXPECT_FALSE(Allow(source_list, GURL("applewebdata://a.test"), *self));
EXPECT_TRUE(Allow(source_list, GURL("file://not-example.com"), *file));
EXPECT_FALSE(Allow(source_list, GURL("applewebdata://a.test"), *file));
}
}

@ -128,11 +128,11 @@ ResourceRequest::TrustedParams& ResourceRequest::TrustedParams::operator=(
}
bool ResourceRequest::TrustedParams::EqualsForTesting(
const TrustedParams& trusted_params) const {
return isolation_info.IsEqualForTesting(trusted_params.isolation_info) &&
disable_secure_dns == trusted_params.disable_secure_dns &&
has_user_activation == trusted_params.has_user_activation &&
client_security_state == trusted_params.client_security_state;
const TrustedParams& other) const {
return isolation_info.IsEqualForTesting(other.isolation_info) &&
disable_secure_dns == other.disable_secure_dns &&
has_user_activation == other.has_user_activation &&
client_security_state == other.client_security_state;
}
ResourceRequest::WebBundleTokenParams::WebBundleTokenParams() = default;

@ -55,7 +55,7 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceRequest {
TrustedParams(const TrustedParams& params);
TrustedParams& operator=(const TrustedParams& other);
bool EqualsForTesting(const TrustedParams& trusted_params) const;
bool EqualsForTesting(const TrustedParams& other) const;
net::IsolationInfo isolation_info;
bool disable_secure_dns = false;

@ -84,7 +84,7 @@ class SourceStreamToDataPipeTest
while (result == MOJO_RESULT_OK || result == MOJO_RESULT_SHOULD_WAIT) {
char buffer[16];
uint32_t read_size = sizeof(buffer);
MojoResult result =
result =
consumer_end().ReadData(buffer, &read_size, MOJO_READ_DATA_FLAG_NONE);
if (result == MOJO_RESULT_FAILED_PRECONDITION)
break;

@ -58,11 +58,11 @@ class ResourceSchedulerParamsManagerTest : public testing::Test {
while (effective_connection_type < net::EFFECTIVE_CONNECTION_TYPE_LAST) {
if (effective_connection_type <
net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G + num_ranges) {
int index = static_cast<int>(effective_connection_type) - 1;
EXPECT_EQ(index * 10u, resource_scheduler_params_manager
.GetParamsForEffectiveConnectionType(
effective_connection_type)
.max_delayable_requests);
int type = static_cast<int>(effective_connection_type) - 1;
EXPECT_EQ(type * 10u, resource_scheduler_params_manager
.GetParamsForEffectiveConnectionType(
effective_connection_type)
.max_delayable_requests);
EXPECT_EQ(0, resource_scheduler_params_manager
.GetParamsForEffectiveConnectionType(
effective_connection_type)

@ -473,8 +473,8 @@ TEST_F(TCPSocketTest, ServerReceivesMultipleAccept) {
&client_socket_send_handle));
client_sockets.push_back(std::move(client_socket));
}
for (const auto& callback : accept_callbacks) {
EXPECT_EQ(net::OK, callback->WaitForResult());
for (const auto& accept_callback : accept_callbacks) {
EXPECT_EQ(net::OK, accept_callback->WaitForResult());
}
}

@ -260,12 +260,12 @@ void CoordinatorImpl::UnregisterClientProcess(base::ProcessId process_id) {
}
for (auto& pair : in_progress_vm_region_requests_) {
QueuedVmRegionRequest* request = pair.second.get();
auto it = request->pending_responses.begin();
while (it != request->pending_responses.end()) {
QueuedVmRegionRequest* in_progress_request = pair.second.get();
auto it = in_progress_request->pending_responses.begin();
while (it != in_progress_request->pending_responses.end()) {
auto current = it++;
if (*current == process_id) {
request->pending_responses.erase(current);
in_progress_request->pending_responses.erase(current);
}
}
}

@ -47,10 +47,10 @@ Manifest& Manifest::Amend(Manifest other) {
}
for (const auto& capability_entry : other.required_capabilities) {
const auto& service_name = capability_entry.first;
const auto& service = capability_entry.first;
const auto& capability_names = capability_entry.second;
for (const auto& capability_name : capability_names)
required_capabilities[service_name].insert(capability_name);
required_capabilities[service].insert(capability_name);
}
for (const auto& filter_entry :
@ -58,12 +58,12 @@ Manifest& Manifest::Amend(Manifest other) {
const auto& filter_name = filter_entry.first;
const auto& capability_maps = filter_entry.second;
for (const auto& capability_entry : capability_maps) {
const auto& service_name = capability_entry.first;
const auto& service = capability_entry.first;
const auto& capability_names = capability_entry.second;
auto& required_capabilities =
required_interface_filter_capabilities[filter_name][service_name];
auto& required =
required_interface_filter_capabilities[filter_name][service];
for (const auto& capability_name : capability_names)
required_capabilities.insert(capability_name);
required.insert(capability_name);
}
}

@ -96,8 +96,8 @@ bool AllowsInterface(const Manifest::RequiredCapabilityMap& source_requirements,
for (const auto& capability : required_capabilities) {
auto it = target_capabilities.find(capability);
if (it != target_capabilities.end()) {
for (const auto& interface_name : it->second)
allowed_interfaces.insert(interface_name);
for (const auto& interface : it->second)
allowed_interfaces.insert(interface);
}
}

@ -219,9 +219,9 @@ TextDetectionImplWin::BuildTextDetectionResult(ComPtr<IOcrResult> ocr_result) {
break;
auto result = shape_detection::mojom::TextDetectionResult::New();
for (uint32_t i = 0; i < words_count; ++i) {
for (uint32_t word_num = 0; word_num < words_count; ++word_num) {
ComPtr<IOcrWord> word;
hr = ocr_words->GetAt(i, &word);
hr = ocr_words->GetAt(word_num, &word);
if (FAILED(hr))
break;