Chromium Code Reviews| Index: remoting/test/app_remoting_connected_client_fixture.cc |
| diff --git a/remoting/test/app_remoting_connected_client_fixture.cc b/remoting/test/app_remoting_connected_client_fixture.cc |
| index adc22d363b89dd69886a1c571ffe02e5f022f6ca..f377566f7a474e67bd58ed52034a3f4781eebacd 100644 |
| --- a/remoting/test/app_remoting_connected_client_fixture.cc |
| +++ b/remoting/test/app_remoting_connected_client_fixture.cc |
| @@ -4,6 +4,7 @@ |
| #include "remoting/test/app_remoting_connected_client_fixture.h" |
| +#include "base/callback_helpers.h" |
| #include "base/json/json_reader.h" |
| #include "base/logging.h" |
| #include "base/run_loop.h" |
| @@ -47,7 +48,13 @@ AppRemotingConnectedClientFixture::~AppRemotingConnectedClientFixture() { |
| void AppRemotingConnectedClientFixture::SetUp() { |
| connection_helper_.reset( |
| new AppRemotingConnectionHelper(application_details_)); |
| - connection_helper_->Initialize(make_scoped_ptr(new TestChromotingClient())); |
| + scoped_ptr<TestChromotingClient> test_chromoting_client( |
| + new TestChromotingClient()); |
| + |
| + test_chromoting_client_ = test_chromoting_client->GetWeakPtr(); |
| + test_chromoting_client_->AddRemoteConnectionObserver(this); |
| + |
| + connection_helper_->Initialize(test_chromoting_client.Pass()); |
| if (!connection_helper_->StartConnection()) { |
| LOG(ERROR) << "Remote host connection could not be established."; |
| FAIL(); |
| @@ -55,9 +62,19 @@ void AppRemotingConnectedClientFixture::SetUp() { |
| } |
| void AppRemotingConnectedClientFixture::TearDown() { |
| + test_chromoting_client_->RemoveRemoteConnectionObserver(this); |
|
Sergey Ulanov
2015/07/23 19:36:55
Before dereferencing a weak pointer you need to ch
liaoyuke
2015/07/24 02:07:28
Done.
|
| connection_helper_.reset(); |
| } |
| +void AppRemotingConnectedClientFixture::HostMessageReceived( |
| + const protocol::ExtensionMessage& message) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + |
| + if (!host_message_received_callback_.is_null()) { |
| + base::ResetAndReturn(&host_message_received_callback_).Run(message); |
|
Sergey Ulanov
2015/07/23 19:36:55
Do we need to reset the callback? Will we ever nee
Sergey Ulanov
2015/07/23 19:36:55
Do you need to very type of the message, in case i
joedow
2015/07/23 20:26:56
To add on to Sergey's comments, you could get seve
liaoyuke
2015/07/24 02:07:28
Done.
liaoyuke
2015/07/24 02:07:28
Acknowledged.
liaoyuke
2015/07/24 02:07:28
Acknowledged.
|
| + } |
| +} |
| + |
| bool AppRemotingConnectedClientFixture::VerifyResponseForSimpleHostMessage( |
| const std::string& message_request_title, |
| const std::string& message_response_title, |
| @@ -70,11 +87,9 @@ bool AppRemotingConnectedClientFixture::VerifyResponseForSimpleHostMessage( |
| DCHECK(!run_loop_ || !run_loop_->running()); |
| run_loop_.reset(new base::RunLoop()); |
| - HostMessageReceivedCallback host_message_received_callback_ = |
| + host_message_received_callback_ = |
| base::Bind(&SimpleHostMessageHandler, message_response_title, |
| message_payload, run_loop_->QuitClosure(), &message_received); |
| - connection_helper_->SetHostMessageReceivedCallback( |
| - host_message_received_callback_); |
| protocol::ExtensionMessage message; |
| message.set_type(message_request_title); |