diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-10 17:21:00 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-10 17:21:00 +0000 |
commit | c5219ddac893aafb507d759773fc9d3be7378464 (patch) | |
tree | 8daec0c05116eae3bf1b584d64ccb828b35d99df | |
parent | 540de66ae2fdf5dcd213ed5c72b414dc7e90047a (diff) | |
download | chromium_src-c5219ddac893aafb507d759773fc9d3be7378464.zip chromium_src-c5219ddac893aafb507d759773fc9d3be7378464.tar.gz chromium_src-c5219ddac893aafb507d759773fc9d3be7378464.tar.bz2 |
Pass SessionConfig by reference instead of pointer.
BUG=88600
TEST=Unittests
Review URL: http://codereview.chromium.org/7796026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100587 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 95 insertions, 116 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 3c033d8..350efc1 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -238,10 +238,8 @@ void ChromotingClient::Initialize() { TraceContext::tracer()->PrintString("Initializing client."); - const protocol::SessionConfig* config = connection_->config(); - // Initialize the decoder. - rectangle_decoder_->Initialize(config); + rectangle_decoder_->Initialize(connection_->config()); // Schedule the input handler to process the event queue. input_handler_->Initialize(); diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index aabbecf..c6426a8 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -52,12 +52,12 @@ RectangleUpdateDecoder::RectangleUpdateDecoder(MessageLoop* message_loop, RectangleUpdateDecoder::~RectangleUpdateDecoder() { } -void RectangleUpdateDecoder::Initialize(const SessionConfig* config) { - initial_screen_size_ = gfx::Size(config->initial_resolution().width, - config->initial_resolution().height); +void RectangleUpdateDecoder::Initialize(const SessionConfig& config) { + initial_screen_size_ = gfx::Size(config.initial_resolution().width, + config.initial_resolution().height); // Initialize decoder based on the selected codec. - ChannelConfig::Codec codec = config->video_config().codec; + ChannelConfig::Codec codec = config.video_config().codec; if (codec == ChannelConfig::CODEC_VERBATIM) { TraceContext::tracer()->PrintString("Creating Verbatim decoder."); decoder_.reset(DecoderRowBased::CreateVerbatimDecoder()); diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index 0fc4ae2..7394bd4 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -34,7 +34,7 @@ class RectangleUpdateDecoder : FrameConsumer* consumer); // Initializes decoder with the infromation from the protocol config. - void Initialize(const protocol::SessionConfig* config); + void Initialize(const protocol::SessionConfig& config); // Decodes the contents of |packet| calling OnPartialFrameOutput() in the // regsitered as data is avaialable. DecodePacket may keep a reference to diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 86ba1c0..8947a27 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -277,10 +277,9 @@ void ChromotingHost::OnIncomingSession( *protocol_config_->mutable_initial_resolution() = protocol::ScreenResolution(2048, 2048); // TODO(sergeyu): Respect resolution requested by the client if supported. - protocol::SessionConfig* config = protocol_config_->Select( - session->candidate_config(), true /* force_host_resolution */); - - if (!config) { + protocol::SessionConfig config; + if (!protocol_config_->Select(session->candidate_config(), + true /* force_host_resolution */, &config)) { LOG(WARNING) << "Rejecting connection from " << session->jid() << " because no compatible configuration has been found."; *response = protocol::SessionManager::INCOMPATIBLE; @@ -406,8 +405,8 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) { } // TODO(sergeyu): Move this to SessionManager? -Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { - const protocol::ChannelConfig& video_config = config->video_config(); +Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig& config) { + const protocol::ChannelConfig& video_config = config.video_config(); if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { return EncoderRowBased::CreateVerbatimEncoder(); diff --git a/remoting/host/chromoting_host.h b/remoting/host/chromoting_host.h index fc35798..7b5cea5 100644 --- a/remoting/host/chromoting_host.h +++ b/remoting/host/chromoting_host.h @@ -177,7 +177,7 @@ class ChromotingHost : public base::RefCountedThreadSafe<ChromotingHost>, void OnClientDisconnected(protocol::ConnectionToClient* client); // Creates encoder for the specified configuration. - Encoder* CreateEncoder(const protocol::SessionConfig* config); + Encoder* CreateEncoder(const protocol::SessionConfig& config); std::string GenerateHostAuthToken(const std::string& encoded_client_token); diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc index 0842832..120fb04 100644 --- a/remoting/host/chromoting_host_unittest.cc +++ b/remoting/host/chromoting_host_unittest.cc @@ -112,8 +112,9 @@ class ChromotingHostTest : public testing::Test { &handler_, &host_stub2_, &event_executor2_); session_.reset(new MockSession()); session2_.reset(new MockSession()); - session_config_.reset(SessionConfig::CreateDefault()); - session_config2_.reset(SessionConfig::CreateDefault()); + session_config_ = SessionConfig::GetDefault(); + session_jid_ = "user@domain/rest-of-jid"; + session_config2_ = SessionConfig::GetDefault(); ON_CALL(video_stub_, ProcessVideoPacket(_, _)) .WillByDefault( @@ -134,9 +135,11 @@ class ChromotingHostTest : public testing::Test { ON_CALL(*connection2_.get(), session()) .WillByDefault(Return(session2_.get())); ON_CALL(*session_.get(), config()) - .WillByDefault(Return(session_config_.get())); + .WillByDefault(ReturnRef(session_config_)); + ON_CALL(*session_, jid()) + .WillByDefault(ReturnRef(session_jid_)); ON_CALL(*session2_.get(), config()) - .WillByDefault(Return(session_config2_.get())); + .WillByDefault(ReturnRef(session_config2_)); EXPECT_CALL(*connection_.get(), video_stub()) .Times(AnyNumber()); EXPECT_CALL(*connection_.get(), client_stub()) @@ -216,14 +219,15 @@ class ChromotingHostTest : public testing::Test { MockChromotingHostContext context_; protocol::LocalLoginCredentials credentials_; scoped_refptr<MockConnectionToClient> connection_; + std::string session_jid_; scoped_ptr<MockSession> session_; - scoped_ptr<SessionConfig> session_config_; + SessionConfig session_config_; MockVideoStub video_stub_; MockClientStub client_stub_; MockHostStub host_stub_; scoped_refptr<MockConnectionToClient> connection2_; scoped_ptr<MockSession> session2_; - scoped_ptr<SessionConfig> session_config2_; + SessionConfig session_config2_; MockVideoStub video_stub2_; MockClientStub client_stub2_; MockHostStub host_stub2_; @@ -461,7 +465,6 @@ TEST_F(ChromotingHostTest, CurtainModeIT2Me) { // When the video packet is received we first shutdown ChromotingHost // then execute the done task. bool curtain_activated = false; - std::string mockJid("user@domain/rest-of-jid"); { Sequence s1, s2; // Can't just expect Times(0) because if it fails then the host will @@ -469,10 +472,6 @@ TEST_F(ChromotingHostTest, CurtainModeIT2Me) { EXPECT_CALL(*curtain_, EnableCurtainMode(_)) .Times(AnyNumber()) .WillRepeatedly(SetBool(&curtain_activated)); - EXPECT_CALL(*session_, jid()) - .Times(1) - .InSequence(s1) - .WillOnce(ReturnRef(mockJid)); EXPECT_CALL(*disconnect_window_, Show(_, "user@domain")) .Times(1) .InSequence(s1); diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 8113366..5ff8422 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -123,7 +123,7 @@ void ConnectionToHost::InitSession() { local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); } -const SessionConfig* ConnectionToHost::config() { +const SessionConfig& ConnectionToHost::config() { return session_->config(); } diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index ada717b..46e7595 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -95,7 +95,7 @@ class ConnectionToHost : public SignalStrategy::StatusObserver, virtual void Disconnect(const base::Closure& shutdown_task); - virtual const SessionConfig* config(); + virtual const SessionConfig& config(); virtual InputStub* input_stub(); diff --git a/remoting/protocol/fake_session.cc b/remoting/protocol/fake_session.cc index 822cfea..2445d0c 100644 --- a/remoting/protocol/fake_session.cc +++ b/remoting/protocol/fake_session.cc @@ -203,7 +203,7 @@ bool FakeUdpSocket::SetSendBufferSize(int32 size) { FakeSession::FakeSession() : candidate_config_(CandidateSessionConfig::CreateDefault()), - config_(SessionConfig::CreateDefault()), + config_(SessionConfig::GetDefault()), message_loop_(NULL), jid_(kTestJid) { } @@ -252,13 +252,12 @@ const CandidateSessionConfig* FakeSession::candidate_config() { return candidate_config_.get(); } -const SessionConfig* FakeSession::config() { - CHECK(config_.get()); - return config_.get(); +const SessionConfig& FakeSession::config() { + return config_; } -void FakeSession::set_config(const SessionConfig* config) { - config_.reset(config); +void FakeSession::set_config(const SessionConfig& config) { + config_ = config; } const std::string& FakeSession::initiator_token() { diff --git a/remoting/protocol/fake_session.h b/remoting/protocol/fake_session.h index 13409d0..d223774 100644 --- a/remoting/protocol/fake_session.h +++ b/remoting/protocol/fake_session.h @@ -149,8 +149,8 @@ class FakeSession : public Session { virtual const std::string& jid(); virtual const CandidateSessionConfig* candidate_config(); - virtual const SessionConfig* config(); - virtual void set_config(const SessionConfig* config); + virtual const SessionConfig& config(); + virtual void set_config(const SessionConfig& config); virtual const std::string& initiator_token(); virtual void set_initiator_token(const std::string& initiator_token); @@ -165,7 +165,7 @@ class FakeSession : public Session { public: scoped_ptr<StateChangeCallback> callback_; scoped_ptr<const CandidateSessionConfig> candidate_config_; - scoped_ptr<const SessionConfig> config_; + SessionConfig config_; MessageLoop* message_loop_; FakeSocket control_channel_; FakeSocket event_channel_; diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc index 3a906e2..b80239c 100644 --- a/remoting/protocol/jingle_session.cc +++ b/remoting/protocol/jingle_session.cc @@ -57,6 +57,7 @@ JingleSession::JingleSession( state_(INITIALIZING), closing_(false), cricket_session_(NULL), + config_set_(false), ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { // TODO(hclam): Need a better way to clone a key. if (local_private_key) { @@ -190,20 +191,20 @@ const std::string& JingleSession::local_certificate() const { return local_cert_; } -const SessionConfig* JingleSession::config() { +const SessionConfig& JingleSession::config() { // TODO(sergeyu): Fix ChromotingHost so that it doesn't call this // method on invalid thread and uncomment this DCHECK. // See crbug.com/88600 . // DCHECK(CalledOnValidThread()); - DCHECK(config_.get()); - return config_.get(); + DCHECK(config_set_); + return config_; } -void JingleSession::set_config(const SessionConfig* config) { +void JingleSession::set_config(const SessionConfig& config) { DCHECK(CalledOnValidThread()); - DCHECK(!config_.get()); - DCHECK(config); - config_.reset(config); + DCHECK(!config_set_); + config_ = config; + config_set_ = true; } const std::string& JingleSession::initiator_token() { @@ -339,18 +340,17 @@ bool JingleSession::InitializeConfigFromDescription( return false; } - scoped_ptr<SessionConfig> config( - content_description->config()->GetFinalConfig()); - if (!config.get()) { + SessionConfig config; + if (!content_description->config()->GetFinalConfig(&config)) { LOG(ERROR) << "Connection response does not specify configuration"; return false; } - if (!candidate_config()->IsSupported(config.get())) { + if (!candidate_config()->IsSupported(config)) { LOG(ERROR) << "Connection response specifies an invalid configuration"; return false; } - set_config(config.release()); + set_config(config); return true; } diff --git a/remoting/protocol/jingle_session.h b/remoting/protocol/jingle_session.h index 288720d..505944fc 100644 --- a/remoting/protocol/jingle_session.h +++ b/remoting/protocol/jingle_session.h @@ -38,8 +38,8 @@ class JingleSession : public protocol::Session, virtual net::Socket* event_channel() OVERRIDE; virtual const std::string& jid() OVERRIDE; virtual const CandidateSessionConfig* candidate_config() OVERRIDE; - virtual const SessionConfig* config() OVERRIDE; - virtual void set_config(const SessionConfig* config) OVERRIDE; + virtual const SessionConfig& config() OVERRIDE; + virtual void set_config(const SessionConfig& config) OVERRIDE; virtual const std::string& initiator_token() OVERRIDE; virtual void set_initiator_token(const std::string& initiator_token) OVERRIDE; virtual const std::string& receiver_token() OVERRIDE; @@ -159,7 +159,8 @@ class JingleSession : public protocol::Session, // The corresponding libjingle session. cricket::Session* cricket_session_; - scoped_ptr<const SessionConfig> config_; + SessionConfig config_; + bool config_set_; std::string initiator_token_; std::string receiver_token_; diff --git a/remoting/protocol/jingle_session_manager.cc b/remoting/protocol/jingle_session_manager.cc index 9312d54..cd81c21 100644 --- a/remoting/protocol/jingle_session_manager.cc +++ b/remoting/protocol/jingle_session_manager.cc @@ -248,7 +248,6 @@ bool JingleSessionManager::AcceptConnection( switch (response) { case protocol::SessionManager::ACCEPT: { // Connection must be configured by the callback. - DCHECK(jingle_session->config()); CandidateSessionConfig* candidate_config = CandidateSessionConfig::CreateFrom(jingle_session->config()); cricket_session->Accept( diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc index 28b3081..adf1af2 100644 --- a/remoting/protocol/jingle_session_unittest.cc +++ b/remoting/protocol/jingle_session_unittest.cc @@ -124,7 +124,7 @@ class JingleSessionTest : public testing::Test { NewCallback(&host_connection_callback_, &MockSessionCallback::OnStateChange)); - session->set_config(SessionConfig::CreateDefault()); + session->set_config(SessionConfig::GetDefault()); session->set_shared_secret(kTestSharedSecret); } diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index 948fdec..7186467 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -120,8 +120,8 @@ class MockSession : public Session { MOCK_METHOD0(video_rtcp_channel, net::Socket*()); MOCK_METHOD0(jid, const std::string&()); MOCK_METHOD0(candidate_config, const CandidateSessionConfig*()); - MOCK_METHOD0(config, const SessionConfig*()); - MOCK_METHOD1(set_config, void(const SessionConfig* config)); + MOCK_METHOD0(config, const SessionConfig&()); + MOCK_METHOD1(set_config, void(const SessionConfig& config)); MOCK_METHOD0(initiator_token, const std::string&()); MOCK_METHOD1(set_initiator_token, void(const std::string& initiator_token)); MOCK_METHOD0(receiver_token, const std::string&()); diff --git a/remoting/protocol/protocol_test_client.cc b/remoting/protocol/protocol_test_client.cc index b9d8d0a..3ed5bb5 100644 --- a/remoting/protocol/protocol_test_client.cc +++ b/remoting/protocol/protocol_test_client.cc @@ -306,7 +306,7 @@ void ProtocolTestClient::OnIncomingSession( SessionManager::IncomingSessionResponse* response) { std::cerr << "Accepting connection from " << session->jid() << std::endl; - session->set_config(SessionConfig::CreateDefault()); + session->set_config(SessionConfig::GetDefault()); *response = SessionManager::ACCEPT; ProtocolTestConnection* test_connection = new ProtocolTestConnection(this); diff --git a/remoting/protocol/session.h b/remoting/protocol/session.h index 73b85c8..920a681 100644 --- a/remoting/protocol/session.h +++ b/remoting/protocol/session.h @@ -87,13 +87,12 @@ class Session : public base::NonThreadSafe { // Protocol configuration. Can be called only after session has been accepted. // Returned pointer is valid until connection is closed. - virtual const SessionConfig* config() = 0; + virtual const SessionConfig& config() = 0; - // Set protocol configuration for an incoming session. Must be called - // on the host before the connection is accepted, from - // ChromotocolServer::IncomingConnectionCallback. Ownership of |config| is - // given to the connection. - virtual void set_config(const SessionConfig* config) = 0; + // Set protocol configuration for an incoming session. Must be + // called on the host before the connection is accepted, from + // ChromotocolServer::IncomingConnectionCallback. + virtual void set_config(const SessionConfig& config) = 0; // The raw auth tokens from the session-initiate, or session-accept stanzas. virtual const std::string& initiator_token() = 0; diff --git a/remoting/protocol/session_config.cc b/remoting/protocol/session_config.cc index 57dbe28..58d1a65 100644 --- a/remoting/protocol/session_config.cc +++ b/remoting/protocol/session_config.cc @@ -52,13 +52,6 @@ bool ScreenResolution::IsValid() const { SessionConfig::SessionConfig() { } -SessionConfig::SessionConfig(const SessionConfig& config) - : control_config_(config.control_config_), - event_config_(config.event_config_), - video_config_(config.video_config_), - initial_resolution_(config.initial_resolution_) { -} - SessionConfig::~SessionConfig() { } void SessionConfig::SetControlConfig(const ChannelConfig& control_config) { @@ -74,20 +67,16 @@ void SessionConfig::SetInitialResolution(const ScreenResolution& resolution) { initial_resolution_ = resolution; } -SessionConfig* SessionConfig::Clone() const { - return new SessionConfig(*this); -} - // static -SessionConfig* SessionConfig::CreateDefault() { - SessionConfig* result = new SessionConfig(); - result->SetControlConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, +SessionConfig SessionConfig::GetDefault() { + SessionConfig result; + result.SetControlConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_UNDEFINED)); - result->SetEventConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, + result.SetEventConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_UNDEFINED)); - result->SetVideoConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, + result.SetVideoConfig(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_VP8)); return result; @@ -105,9 +94,10 @@ CandidateSessionConfig::CandidateSessionConfig( CandidateSessionConfig::~CandidateSessionConfig() { } -SessionConfig* CandidateSessionConfig::Select( +bool CandidateSessionConfig::Select( const CandidateSessionConfig* client_config, - bool force_host_resolution) { + bool force_host_resolution, + SessionConfig* result) { ChannelConfig control_config; ChannelConfig event_config; ChannelConfig video_config; @@ -118,10 +108,9 @@ SessionConfig* CandidateSessionConfig::Select( event_configs_, client_config->event_configs_, &event_config) || !SelectCommonChannelConfig( video_configs_, client_config->video_configs_, &video_config)) { - return NULL; + return false; } - SessionConfig* result = SessionConfig::CreateDefault(); result->SetControlConfig(control_config); result->SetEventConfig(event_config); result->SetVideoConfig(video_config); @@ -132,31 +121,31 @@ SessionConfig* CandidateSessionConfig::Select( result->SetInitialResolution(client_config->initial_resolution()); } - return result; + return true; } bool CandidateSessionConfig::IsSupported( - const SessionConfig* config) const { + const SessionConfig& config) const { return - IsChannelConfigSupported(control_configs_, config->control_config()) && - IsChannelConfigSupported(event_configs_, config->event_config()) && - IsChannelConfigSupported(video_configs_, config->video_config()) && - config->initial_resolution().IsValid(); + IsChannelConfigSupported(control_configs_, config.control_config()) && + IsChannelConfigSupported(event_configs_, config.event_config()) && + IsChannelConfigSupported(video_configs_, config.video_config()) && + config.initial_resolution().IsValid(); } -SessionConfig* CandidateSessionConfig::GetFinalConfig() const { +bool CandidateSessionConfig::GetFinalConfig(SessionConfig* result) const { if (control_configs_.size() != 1 || event_configs_.size() != 1 || video_configs_.size() != 1) { - return NULL; + return false; } - SessionConfig* result = SessionConfig::CreateDefault(); result->SetControlConfig(control_configs_.front()); result->SetEventConfig(event_configs_.front()); result->SetVideoConfig(video_configs_.front()); result->SetInitialResolution(initial_resolution_); - return result; + + return true; } // static @@ -194,12 +183,12 @@ CandidateSessionConfig* CandidateSessionConfig::CreateEmpty() { // static CandidateSessionConfig* CandidateSessionConfig::CreateFrom( - const SessionConfig* config) { + const SessionConfig& config) { CandidateSessionConfig* result = CreateEmpty(); - result->mutable_control_configs()->push_back(config->control_config()); - result->mutable_event_configs()->push_back(config->event_config()); - result->mutable_video_configs()->push_back(config->video_config()); - *result->mutable_initial_resolution() = (config->initial_resolution()); + result->mutable_control_configs()->push_back(config.control_config()); + result->mutable_event_configs()->push_back(config.event_config()); + result->mutable_video_configs()->push_back(config.video_config()); + *result->mutable_initial_resolution() = config.initial_resolution(); return result; } diff --git a/remoting/protocol/session_config.h b/remoting/protocol/session_config.h index 81e4238..3e3f44e 100644 --- a/remoting/protocol/session_config.h +++ b/remoting/protocol/session_config.h @@ -61,6 +61,7 @@ struct ScreenResolution { // chromotocol configuration. class SessionConfig { public: + SessionConfig(); ~SessionConfig(); const ChannelConfig& control_config() const { return control_config_; } @@ -75,15 +76,9 @@ class SessionConfig { void SetVideoConfig(const ChannelConfig& video_config); void SetInitialResolution(const ScreenResolution& initial_resolution); - SessionConfig* Clone() const; - - static SessionConfig* CreateDefault(); + static SessionConfig GetDefault(); private: - SessionConfig(); - explicit SessionConfig(const SessionConfig& config); - SessionConfig& operator=(const SessionConfig& b); - ChannelConfig control_config_; ChannelConfig event_config_; ChannelConfig video_config_; @@ -133,22 +128,23 @@ class CandidateSessionConfig { // NULL is returned if such configuration doesn't exist. When selecting // channel configuration priority is given to the configs listed first // in |client_config|. - SessionConfig* Select(const CandidateSessionConfig* client_config, - bool force_host_resolution); + bool Select(const CandidateSessionConfig* client_config, + bool force_host_resolution, + SessionConfig* result); // Returns true if |config| is supported. - bool IsSupported(const SessionConfig* config) const; + bool IsSupported(const SessionConfig& config) const; // Extracts final protocol configuration. Must be used for the description // received in the session-accept stanza. If the selection is ambiguous // (e.g. there is more than one configuration for one of the channel) // or undefined (e.g. no configurations for a channel) then NULL is returned. - SessionConfig* GetFinalConfig() const; + bool GetFinalConfig(SessionConfig* result) const; CandidateSessionConfig* Clone() const; static CandidateSessionConfig* CreateEmpty(); - static CandidateSessionConfig* CreateFrom(const SessionConfig* config); + static CandidateSessionConfig* CreateFrom(const SessionConfig& config); static CandidateSessionConfig* CreateDefault(); private: diff --git a/remoting/protocol/video_reader.cc b/remoting/protocol/video_reader.cc index d48daaa..464b512 100644 --- a/remoting/protocol/video_reader.cc +++ b/remoting/protocol/video_reader.cc @@ -15,8 +15,8 @@ VideoReader::~VideoReader() { } // static VideoReader* VideoReader::Create(base::MessageLoopProxy* message_loop, - const SessionConfig* config) { - const ChannelConfig& video_config = config->video_config(); + const SessionConfig& config) { + const ChannelConfig& video_config = config.video_config(); if (video_config.transport == ChannelConfig::TRANSPORT_SRTP) { return new RtpVideoReader(message_loop); } else if (video_config.transport == ChannelConfig::TRANSPORT_STREAM) { diff --git a/remoting/protocol/video_reader.h b/remoting/protocol/video_reader.h index 986216e..ada9c30 100644 --- a/remoting/protocol/video_reader.h +++ b/remoting/protocol/video_reader.h @@ -28,7 +28,7 @@ class SessionConfig; class VideoReader { public: static VideoReader* Create(base::MessageLoopProxy* message_loop, - const SessionConfig* config); + const SessionConfig& config); // The callback is called when initialization is finished. The // parameter is set to true on success. diff --git a/remoting/protocol/video_writer.cc b/remoting/protocol/video_writer.cc index f0d4a53..8ebf285 100644 --- a/remoting/protocol/video_writer.cc +++ b/remoting/protocol/video_writer.cc @@ -15,8 +15,8 @@ VideoWriter::~VideoWriter() { } // static VideoWriter* VideoWriter::Create(base::MessageLoopProxy* message_loop, - const SessionConfig* config) { - const ChannelConfig& video_config = config->video_config(); + const SessionConfig& config) { + const ChannelConfig& video_config = config.video_config(); if (video_config.transport == ChannelConfig::TRANSPORT_SRTP) { return new RtpVideoWriter(message_loop); } else if (video_config.transport == ChannelConfig::TRANSPORT_STREAM) { diff --git a/remoting/protocol/video_writer.h b/remoting/protocol/video_writer.h index 2b5a7be..8a3c10f 100644 --- a/remoting/protocol/video_writer.h +++ b/remoting/protocol/video_writer.h @@ -33,7 +33,7 @@ class VideoWriter : public VideoStub { typedef base::Callback<void(bool)> InitializedCallback; static VideoWriter* Create(base::MessageLoopProxy* message_loop, - const SessionConfig* config); + const SessionConfig& config); // Initializes the writer. virtual void Init(Session* session, const InitializedCallback& callback) = 0; |