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 <iostream> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/bind.h" | |
| 11 #include "base/location.h" | |
| 12 #include "base/memory/ptr_util.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "remoting/base/auto_thread_task_runner.h" | |
| 16 #include "remoting/host/chromoting_host_context.h" | |
| 17 #include "remoting/host/host_extension.h" | |
| 18 #include "remoting/protocol/pairing_registry.h" | |
| 19 #include "remoting/protocol/protocol_mock_objects.h" | |
| 20 #include "remoting/protocol/session_config.h" | |
| 21 | |
| 22 namespace remoting { | |
| 23 namespace test { | |
| 24 | |
| 25 namespace { | |
| 26 | |
| 27 void OutputFakeConnectionEventLogger(const FakeConnectionEventLogger* logger) { | |
|
joedow
2016/05/04 22:58:49
Also, why const FakeConnectionEventLogger* instead
joedow
2016/05/04 22:58:49
DCHECK(logger)?
Hzj_jie
2016/05/05 00:47:36
Done.
Hzj_jie
2016/05/05 00:47:36
Bind does not accept reference, but we do not need
| |
| 28 std::cout << *logger; | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 using ::remoting::protocol::MockSession; | |
| 34 | |
| 35 It2MeStandaloneHost::It2MeStandaloneHost() | |
| 36 : context_(ChromotingHostContext::Create( | |
| 37 new AutoThreadTaskRunner( | |
| 38 message_loop_.task_runner(), run_loop_.QuitClosure()))), | |
| 39 factory_(context_->file_task_runner(), | |
|
joedow
2016/05/04 22:58:49
Perhaps use scoped_refptr as an alias for 'context
Hzj_jie
2016/05/05 00:47:36
Done.
| |
| 40 context_->video_capture_task_runner(), | |
| 41 context_->input_task_runner(), | |
| 42 context_->ui_task_runner()), | |
| 43 connection_(base::WrapUnique(new testing::NiceMock<MockSession>())), | |
| 44 session_jid_("user@domain/rest-of-jid"), | |
|
joedow
2016/05/04 22:58:49
Move constant ("user@domain/rest-of-jid") to anony
Hzj_jie
2016/05/05 00:47:36
Done.
| |
| 45 #if defined(OS_LINUX) | |
| 46 // We cannot support audio capturing for linux, since a pipe name is | |
| 47 // needed to initialize AudioCapturerLinux. | |
| 48 config_(protocol::SessionConfig::ForTest()), | |
| 49 #else | |
| 50 config_(protocol::SessionConfig::ForTestWithAudio()), | |
| 51 #endif | |
| 52 stubs_(&connection_) { | |
| 53 factory_.set_enable_user_interface(false); | |
| 54 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), jid()) | |
| 55 .WillRepeatedly(testing::ReturnRef(session_jid_)); | |
| 56 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), config()) | |
| 57 .WillRepeatedly(testing::ReturnRef(*config_)); | |
| 58 connection_.set_audio_stub(stubs_.audio_stub()); | |
| 59 connection_.set_video_stub(stubs_.video_stub()); | |
| 60 connection_.set_client_stub(stubs_.client_stub()); | |
| 61 connection_.set_host_stub(stubs_.host_stub()); | |
| 62 connection_.set_video_encode_task_runner( | |
| 63 context_->video_encode_task_runner()); | |
| 64 } | |
| 65 | |
| 66 It2MeStandaloneHost::~It2MeStandaloneHost() {} | |
| 67 | |
| 68 void It2MeStandaloneHost::Run() { | |
| 69 // Must run in the same thread as | |
| 70 // It2MeDesktopEnvironmentFactory->caller_task_runner() | |
| 71 context_->file_task_runner()->PostTask( | |
| 72 FROM_HERE, | |
| 73 base::Bind(&It2MeStandaloneHost::Connect, base::Unretained(this))); | |
| 74 run_loop_.Run(); | |
| 75 } | |
| 76 | |
| 77 void It2MeStandaloneHost::StartOutputTimer() { | |
| 78 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), | |
| 79 base::Bind(&OutputFakeConnectionEventLogger, &stubs_)); | |
| 80 } | |
| 81 | |
| 82 void It2MeStandaloneHost::Connect() { | |
| 83 session_.reset(new ClientSession( | |
| 84 &handler_, | |
| 85 context_->audio_task_runner(), | |
| 86 std::unique_ptr<protocol::ConnectionToClient>(&connection_), | |
| 87 &factory_, | |
| 88 base::TimeDelta(), | |
| 89 scoped_refptr<protocol::PairingRegistry>(), | |
| 90 std::vector<HostExtension*>())); | |
| 91 session_->OnConnectionAuthenticated(&connection_); | |
| 92 session_->OnConnectionChannelsConnected(&connection_); | |
| 93 session_->CreateVideoStreams(&connection_); | |
| 94 } | |
| 95 | |
| 96 } // namespace test | |
| 97 } // namespace remoting | |
| OLD | NEW |