Commit 954c9c1d authored by avi's avatar avi Committed by Commit bot

Remove ScopedVector from remoting/.

BUG=554289

Review-Url: https://codereview.chromium.org/2627433003
Cr-Commit-Position: refs/heads/master@{#442928}
parent cc331493
......@@ -176,7 +176,7 @@ void PepperVideoRenderer2D::DrawFrame(
if (!done.is_null()) {
pending_frames_done_callbacks_.push_back(
new base::ScopedClosureRunner(done));
base::MakeUnique<base::ScopedClosureRunner>(done));
}
need_flush_ = true;
......
......@@ -6,11 +6,12 @@
#define REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_2D_H_
#include <list>
#include <memory>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "ppapi/cpp/graphics_2d.h"
......@@ -84,10 +85,12 @@ class PepperVideoRenderer2D : public PepperVideoRenderer,
webrtc::DesktopSize source_size_;
// Done callbacks for the frames that have been painted but not flushed.
ScopedVector<base::ScopedClosureRunner> pending_frames_done_callbacks_;
std::vector<std::unique_ptr<base::ScopedClosureRunner>>
pending_frames_done_callbacks_;
// Done callbacks for the frames that are currently being flushed.
ScopedVector<base::ScopedClosureRunner> flushing_frames_done_callbacks_;
std::vector<std::unique_ptr<base::ScopedClosureRunner>>
flushing_frames_done_callbacks_;
// True if there paint operations that need to be flushed.
bool need_flush_ = false;
......
......@@ -6,12 +6,12 @@
#include <stdint.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/thread.h"
......@@ -156,7 +156,7 @@ class SoftwareVideoRendererTest : public ::testing::Test {
TEST_F(SoftwareVideoRendererTest, DecodeFrame) {
const int kFrameCount = 5;
ScopedVector<DesktopFrame> test_frames;
std::vector<std::unique_ptr<DesktopFrame>> test_frames;
// std::vector<bool> doesn't allow to get pointer to individual values, so
// int needs to be used instead.
......
......@@ -125,7 +125,7 @@ void ChromotingHost::RemoveStatusObserver(HostStatusObserver* observer) {
}
void ChromotingHost::AddExtension(std::unique_ptr<HostExtension> extension) {
extensions_.push_back(extension.release());
extensions_.push_back(std::move(extension));
}
void ChromotingHost::SetAuthenticatorFactory(
......@@ -259,9 +259,12 @@ void ChromotingHost::OnIncomingSession(
DesktopEnvironmentOptions options = desktop_environment_options_;
// TODO(zijiehe): Apply HostSessionOptions to options.
// Create a ClientSession object.
std::vector<HostExtension*> extension_ptrs;
for (const auto& extension : extensions_)
extension_ptrs.push_back(extension.get());
clients_.push_back(base::MakeUnique<ClientSession>(
this, std::move(connection), desktop_environment_factory_, options,
max_session_duration_, pairing_registry_, extensions_.get()));
max_session_duration_, pairing_registry_, extension_ptrs));
}
} // namespace remoting
......@@ -11,7 +11,6 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
......@@ -142,8 +141,6 @@ class ChromotingHost : public base::NonThreadSafe,
private:
friend class ChromotingHostTest;
typedef ScopedVector<HostExtension> HostExtensionList;
// Unless specified otherwise all members of this class must be
// used on the network thread only.
......@@ -176,7 +173,7 @@ class ChromotingHost : public base::NonThreadSafe,
scoped_refptr<protocol::PairingRegistry> pairing_registry_;
// List of host extensions.
HostExtensionList extensions_;
std::vector<std::unique_ptr<HostExtension>> extensions_;
base::WeakPtrFactory<ChromotingHost> weak_factory_;
......
......@@ -4,6 +4,7 @@
#include "remoting/host/host_extension_session_manager.h"
#include "base/logging.h"
#include "remoting/base/capabilities.h"
#include "remoting/host/client_session_details.h"
#include "remoting/host/host_extension.h"
......@@ -12,7 +13,7 @@
namespace remoting {
HostExtensionSessionManager::HostExtensionSessionManager(
const std::vector<HostExtension*>& extensions,
const HostExtensions& extensions,
ClientSessionDetails* client_session_details)
: client_session_details_(client_session_details),
client_stub_(nullptr),
......@@ -22,9 +23,8 @@ HostExtensionSessionManager::~HostExtensionSessionManager() {}
std::string HostExtensionSessionManager::GetCapabilities() const {
std::string capabilities;
for (HostExtensions::const_iterator extension = extensions_.begin();
extension != extensions_.end(); ++extension) {
const std::string& capability = (*extension)->capability();
for (const auto& extension : extensions_) {
const std::string& capability = extension->capability();
if (capability.empty()) {
continue;
}
......@@ -44,30 +44,28 @@ void HostExtensionSessionManager::OnNegotiatedCapabilities(
client_stub_ = client_stub;
for (HostExtensions::const_iterator extension = extensions_.begin();
extension != extensions_.end(); ++extension) {
for (const auto& extension : extensions_) {
// If the extension requires a capability that was not negotiated then do
// not instantiate it.
if (!(*extension)->capability().empty() &&
!HasCapability(capabilities, (*extension)->capability())) {
if (!extension->capability().empty() &&
!HasCapability(capabilities, extension->capability())) {
continue;
}
std::unique_ptr<HostExtensionSession> extension_session =
(*extension)
->CreateExtensionSession(client_session_details_, client_stub_);
extension->CreateExtensionSession(client_session_details_,
client_stub_);
DCHECK(extension_session);
extension_sessions_.push_back(extension_session.release());
extension_sessions_.push_back(std::move(extension_session));
}
}
bool HostExtensionSessionManager::OnExtensionMessage(
const protocol::ExtensionMessage& message) {
for(HostExtensionSessions::const_iterator it = extension_sessions_.begin();
it != extension_sessions_.end(); ++it) {
if ((*it)->OnExtensionMessage(client_session_details_, client_stub_,
message)) {
for (const auto& session : extension_sessions_) {
if (session->OnExtensionMessage(client_session_details_, client_stub_,
message)) {
return true;
}
}
......
......@@ -5,11 +5,11 @@
#ifndef REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
#define REMOTING_HOST_HOST_EXTENSION_SESSION_MANAGER_H_
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
namespace remoting {
......@@ -27,7 +27,7 @@ class ExtensionMessage;
// set of capabilities negotiated between client and host.
class HostExtensionSessionManager {
public:
typedef std::vector<HostExtension*> HostExtensions;
using HostExtensions = std::vector<HostExtension*>;
// Creates an extension manager for the specified |extensions|.
HostExtensionSessionManager(const HostExtensions& extensions,
......@@ -48,7 +48,8 @@ class HostExtensionSessionManager {
bool OnExtensionMessage(const protocol::ExtensionMessage& message);
private:
typedef ScopedVector<HostExtensionSession> HostExtensionSessions;
using HostExtensionSessions =
std::vector<std::unique_ptr<HostExtensionSession>>;
// Passed to HostExtensionSessions to allow them to send messages,
// disconnect the session, etc.
......
......@@ -6,11 +6,12 @@
#include <stddef.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "remoting/codec/audio_encoder.h"
......@@ -69,7 +70,7 @@ class AudioPumpTest : public testing::Test, public protocol::AudioStub {
std::unique_ptr<AudioPump> pump_;
ScopedVector<AudioPacket> sent_packets_;
std::vector<std::unique_ptr<AudioPacket>> sent_packets_;
std::vector<base::Closure> done_closures_;
private:
......
......@@ -4,8 +4,10 @@
#include "remoting/protocol/client_video_dispatcher.h"
#include <memory>
#include <vector>
#include "base/bind.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "remoting/base/buffered_socket_writer.h"
......@@ -58,10 +60,10 @@ class ClientVideoDispatcherTest : public testing::Test,
MessageReader reader_;
BufferedSocketWriter writer_;
ScopedVector<VideoPacket> video_packets_;
std::vector<std::unique_ptr<VideoPacket>> video_packets_;
std::vector<base::Closure> packet_done_callbacks_;
ScopedVector<VideoAck> ack_messages_;
std::vector<std::unique_ptr<VideoAck>> ack_messages_;
};
ClientVideoDispatcherTest::ClientVideoDispatcherTest()
......@@ -88,7 +90,7 @@ ClientVideoDispatcherTest::ClientVideoDispatcherTest()
void ClientVideoDispatcherTest::ProcessVideoPacket(
std::unique_ptr<VideoPacket> video_packet,
const base::Closure& done) {
video_packets_.push_back(video_packet.release());
video_packets_.push_back(std::move(video_packet));
packet_done_callbacks_.push_back(done);
}
......@@ -112,7 +114,7 @@ void ClientVideoDispatcherTest::OnMessageReceived(
std::unique_ptr<CompoundBuffer> buffer) {
std::unique_ptr<VideoAck> ack = ParseMessage<VideoAck>(buffer.get());
EXPECT_TRUE(ack);
ack_messages_.push_back(ack.release());
ack_messages_.push_back(std::move(ack));
}
void ClientVideoDispatcherTest::OnReadError(int error) {
......
......@@ -238,8 +238,9 @@ void VideoFramePump::OnVideoPacketSent() {
// Send next packet if any.
if (!pending_packets_.empty()) {
std::unique_ptr<PacketWithTimestamps> next(pending_packets_.front());
pending_packets_.weak_erase(pending_packets_.begin());
std::unique_ptr<PacketWithTimestamps> next =
std::move(pending_packets_.front());
pending_packets_.erase(pending_packets_.begin());
SendPacket(std::move(next));
}
}
......
......@@ -9,9 +9,9 @@
#include <stdint.h>
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
......@@ -179,7 +179,7 @@ class VideoFramePump : public VideoStream,
bool send_pending_ = false;
ScopedVector<PacketWithTimestamps> pending_packets_;
std::vector<std::unique_ptr<PacketWithTimestamps>> pending_packets_;
base::ThreadChecker thread_checker_;
......
......@@ -680,8 +680,8 @@ void WebrtcTransport::AddPendingCandidatesIfPossible() {
if (peer_connection()->signaling_state() ==
webrtc::PeerConnectionInterface::kStable) {
for (auto* candidate : pending_incoming_candidates_) {
if (!peer_connection()->AddIceCandidate(candidate)) {
for (const auto& candidate : pending_incoming_candidates_) {
if (!peer_connection()->AddIceCandidate(candidate.get())) {
LOG(ERROR) << "Failed to add incoming candidate";
Close(INCOMPATIBLE_PROTOCOL);
return;
......
......@@ -7,10 +7,10 @@
#include <memory>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
......@@ -141,7 +141,8 @@ class WebrtcTransport : public Transport {
std::unique_ptr<buzz::XmlElement> pending_transport_info_message_;
base::OneShotTimer transport_info_timer_;
ScopedVector<webrtc::IceCandidateInterface> pending_incoming_candidates_;
std::vector<std::unique_ptr<webrtc::IceCandidateInterface>>
pending_incoming_candidates_;
base::WeakPtrFactory<WebrtcTransport> weak_factory_;
......
......@@ -4,7 +4,9 @@
#include "remoting/signaling/xmpp_signal_strategy.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/memory/ptr_util.h"
......@@ -160,7 +162,7 @@ class XmppSignalStrategyTest : public testing::Test,
std::unique_ptr<XmppSignalStrategy> signal_strategy_;
std::vector<SignalStrategy::State> state_history_;
ScopedVector<buzz::XmlElement> received_messages_;
std::vector<std::unique_ptr<buzz::XmlElement>> received_messages_;
};
void XmppSignalStrategyTest::Connect(bool success) {
......
......@@ -4,10 +4,11 @@
#include "remoting/signaling/xmpp_stream_parser.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -43,7 +44,7 @@ class XmppStreamParserTest : public testing::Test {
base::MessageLoop message_loop_;
std::unique_ptr<XmppStreamParser> parser_;
ScopedVector<buzz::XmlElement> received_stanzas_;
std::vector<std::unique_ptr<buzz::XmlElement>> received_stanzas_;
bool error_;
};
......
......@@ -7,11 +7,12 @@
#include <stdint.h>
#include <cmath>
#include <memory>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -399,7 +400,7 @@ TEST_F(TestVideoRendererTest, VerifyMultipleVideoProcessing) {
// more than one task on the video decode thread, while not too large to wait
// for too long for the unit test to complete.
const int task_num = 20;
ScopedVector<VideoPacket> video_packets;
std::vector<std::unique_ptr<VideoPacket>> video_packets;
for (int i = 0; i < task_num; ++i) {
std::unique_ptr<webrtc::DesktopFrame> original_frame =
CreateDesktopFrameWithGradient(kDefaultScreenWidthPx,
......@@ -407,11 +408,8 @@ TEST_F(TestVideoRendererTest, VerifyMultipleVideoProcessing) {
video_packets.push_back(encoder_->Encode(*original_frame.get()));
}
for (int i = 0; i < task_num; ++i) {
// Transfer ownership of video packet.
VideoPacket* packet = video_packets[i];
video_packets[i] = nullptr;
test_video_renderer_->ProcessVideoPacket(base::WrapUnique(packet),
for (auto& packet : video_packets) {
test_video_renderer_->ProcessVideoPacket(std::move(packet),
base::Bind(&base::DoNothing));
}
}
......
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