Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/test/it2me_standalone_host.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/location.h" | |
| 11 #include "base/memory/ptr_util.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "remoting/base/auto_thread_task_runner.h" | |
| 15 #include "remoting/host/chromoting_host_context.h" | |
| 16 #include "remoting/host/host_extension.h" | |
| 17 #include "remoting/protocol/pairing_registry.h" | |
| 18 #include "remoting/protocol/protocol_mock_objects.h" | |
| 19 #include "remoting/protocol/session_config.h" | |
| 20 | |
| 21 namespace remoting { | |
| 22 namespace test { | |
| 23 | |
| 24 using ::remoting::protocol::MockSession; | |
| 25 | |
| 26 It2MeStandaloneHost::It2MeStandaloneHost() | |
| 27 : message_loop_(), | |
|
joedow
2016/05/03 22:28:30
Do these need to be included? I thought default i
Hzj_jie
2016/05/04 02:11:57
Done.
| |
| 28 run_loop_(), | |
| 29 context_(ChromotingHostContext::Create( | |
| 30 new AutoThreadTaskRunner( | |
| 31 message_loop_.task_runner(), run_loop_.QuitClosure()))), | |
| 32 factory_(context_->file_task_runner(), | |
| 33 context_->video_capture_task_runner(), | |
| 34 context_->input_task_runner(), | |
| 35 context_->ui_task_runner()), | |
| 36 connection_(base::WrapUnique(new testing::NiceMock<MockSession>())), | |
| 37 session_jid_("user@domain/rest-of-jid"), | |
| 38 #if defined(OS_LINUX) | |
| 39 // We cannot support audio capturing for linux, since a pipe name is | |
| 40 // needed to initialize AudioCapturerLinux. | |
| 41 config_(protocol::SessionConfig::ForTest()), | |
| 42 #else | |
| 43 config_(protocol::SessionConfig::ForTestWithAudio()), | |
| 44 #endif | |
| 45 audio_stub_(), | |
|
joedow
2016/05/03 22:28:29
You don't need to include these in the initializer
Hzj_jie
2016/05/04 02:11:56
Done.
| |
| 46 client_stub_(), | |
| 47 host_stub_(), | |
| 48 video_stub_(&connection_), | |
| 49 handler_(), | |
| 50 session_() { | |
| 51 factory_.enable_user_interface(false); | |
| 52 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), jid()) | |
| 53 .WillRepeatedly(testing::ReturnRef(session_jid_)); | |
| 54 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), config()) | |
| 55 .WillRepeatedly(testing::ReturnRef(*config_)); | |
| 56 connection_.set_audio_stub(&audio_stub_); | |
| 57 connection_.set_video_stub(&video_stub_); | |
| 58 connection_.set_client_stub(&client_stub_); | |
| 59 connection_.set_host_stub(&host_stub_); | |
| 60 connection_.set_video_encode_task_runner( | |
| 61 context_->video_encode_task_runner()); | |
| 62 } | |
| 63 | |
| 64 void It2MeStandaloneHost::ConnectProxy(It2MeStandaloneHost* host) { | |
| 65 host->Connect(); | |
| 66 } | |
| 67 | |
| 68 void It2MeStandaloneHost::Connect() { | |
| 69 session_.reset(new ClientSession( | |
| 70 &handler_, | |
| 71 context_->audio_task_runner(), | |
| 72 std::unique_ptr<protocol::ConnectionToClient>(&connection_), | |
| 73 &factory_, | |
| 74 base::TimeDelta(), | |
| 75 scoped_refptr<protocol::PairingRegistry>(), | |
| 76 std::vector<HostExtension*>())); | |
| 77 session_->OnConnectionAuthenticated(&connection_); | |
| 78 session_->OnConnectionChannelsConnected(&connection_); | |
| 79 session_->CreateVideoStreams(&connection_); | |
| 80 } | |
| 81 | |
| 82 void It2MeStandaloneHost::Run() { | |
|
joedow
2016/05/03 22:28:30
I'd move this file above the private methods in th
Hzj_jie
2016/05/04 02:11:56
Done.
| |
| 83 context_->file_task_runner()->PostTask( | |
| 84 FROM_HERE, | |
| 85 base::Bind(&It2MeStandaloneHost::ConnectProxy, this)); | |
|
joedow
2016/05/03 22:28:30
This method doesn't need to be static. Instead of
Hzj_jie
2016/05/04 02:11:57
Done.
| |
| 86 run_loop_.Run(); | |
| 87 } | |
| 88 | |
| 89 It2MeStandaloneHost::~It2MeStandaloneHost() {} | |
|
joedow
2016/05/03 22:28:30
d'tor should go below the c'tor
Hzj_jie
2016/05/04 02:11:56
Done.
| |
| 90 | |
| 91 } // namespace test | |
| 92 } // namespace remoting | |
| OLD | NEW |