Skip to content

Commit

Permalink
Change std::find() to use base:: functions: chromecast/
Browse files Browse the repository at this point in the history
Simplifies code slightly.

Bug: 1368812
Change-Id: I8d98b896b11ec2454075b3b67bc31c8cf07074fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3924287
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Sergey Volk <servolk@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1052574}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Sep 28, 2022
1 parent afce72a commit 37216db
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
3 changes: 1 addition & 2 deletions chromecast/browser/cast_web_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ void CastWebService::ClearLocalStorage(ClearLocalStorageCallback callback) {
}

bool CastWebService::IsCastWebUIOrigin(const url::Origin& origin) {
return std::find(cast_webui_hosts_.begin(), cast_webui_hosts_.end(),
origin.host()) != cast_webui_hosts_.end();
return base::Contains(cast_webui_hosts_, origin.host());
}

void CastWebService::RegisterWebUiClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chromecast/cast_core/runtime/browser/streaming_receiver_session_client.h"

#include "base/containers/contains.h"
#include "base/test/task_environment.h"
#include "chromecast/browser/test/mock_cast_web_view.h"
#include "chromecast/cast_core/runtime/browser/streaming_controller.h"
Expand Down Expand Up @@ -183,12 +184,8 @@ TEST_F(StreamingReceiverSessionClientTest, OnSingleValidMessageWithCodecs) {

auto video_codecs = session_constraints_.video_codecs;
EXPECT_EQ(video_codecs.size(), size_t{3});
EXPECT_NE(std::find(video_codecs.begin(), video_codecs.end(),
openscreen::cast::VideoCodec::kVp9),
video_codecs.end());
EXPECT_NE(std::find(video_codecs.begin(), video_codecs.end(),
openscreen::cast::VideoCodec::kVp8),
video_codecs.end());
EXPECT_TRUE(base::Contains(video_codecs, openscreen::cast::VideoCodec::kVp9));
EXPECT_TRUE(base::Contains(video_codecs, openscreen::cast::VideoCodec::kVp8));
EXPECT_TRUE(session_constraints_.video_limits.empty());
}

Expand Down
4 changes: 2 additions & 2 deletions chromecast/graphics/cast_focus_client_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "ui/aura/window.h"

#define LOG_WINDOW_INFO(top_level, window) \
Expand Down Expand Up @@ -59,8 +60,7 @@ void CastFocusClientAura::OnWindowDestroying(aura::Window* window) {
DCHECK(top_level);
DLOG(INFO) << "Removing window, " << LOG_WINDOW_INFO(top_level, window);

auto iter =
std::find(focusable_windows_.begin(), focusable_windows_.end(), window);
auto iter = base::ranges::find(focusable_windows_, window);
if (iter != focusable_windows_.end()) {
focusable_windows_.erase(iter);
window->RemoveObserver(this);
Expand Down
4 changes: 2 additions & 2 deletions chromecast/media/audio/external_audio_pipeline_sample.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <algorithm>
#include <cstdint>
#include <memory>
#include <vector>

#include "base/check.h"
#include "base/ranges/algorithm.h"
#include "chromecast/public/cast_media_shlib.h"
#include "chromecast/public/media/external_audio_pipeline_shlib.h"
#include "chromecast/public/media/mixer_output_stream.h"
Expand Down Expand Up @@ -41,7 +41,7 @@ class TestLoopBack {

void RemoveObserver(
ExternalAudioPipelineShlib::LoopbackAudioObserver* observer) {
auto it = std::find(observers_.begin(), observers_.end(), observer);
auto it = base::ranges::find(observers_, observer);
if (it != observers_.end()) {
observers_.erase(it);
}
Expand Down
4 changes: 2 additions & 2 deletions chromecast/media/audio/fake_external_audio_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <algorithm>
#include <cstdint>
#include <memory>
#include <vector>

#include "base/check.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "chromecast/media/audio/fake_external_audio_pipeline_support.h"
#include "chromecast/public/cast_media_shlib.h"
#include "chromecast/public/media/external_audio_pipeline_shlib.h"
Expand Down Expand Up @@ -82,7 +82,7 @@ class TestLoopBack {

void RemoveExternalLoopbackAudioObserver(
ExternalAudioPipelineShlib::LoopbackAudioObserver* observer) {
auto it = std::find(observers_.begin(), observers_.end(), observer);
auto it = base::ranges::find(observers_, observer);
if (it != observers_.end()) {
observers_.erase(it);
}
Expand Down
5 changes: 2 additions & 3 deletions chromecast/media/cma/backend/android/audio_sink_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#include "chromecast/media/cma/backend/android/audio_sink_manager.h"

#include <algorithm>

#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "chromecast/media/cma/backend/android/audio_sink_android.h"

namespace chromecast {
Expand Down Expand Up @@ -56,7 +55,7 @@ void AudioSinkManager::Remove(AudioSinkAndroid* sink) {

base::AutoLock lock(lock_);

auto it = std::find(sinks_.begin(), sinks_.end(), sink);
auto it = base::ranges::find(sinks_, sink);
if (it == sinks_.end()) {
LOG(WARNING) << __func__ << ": Cannot find sink";
return;
Expand Down

0 comments on commit 37216db

Please sign in to comment.