Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: remoting/test/it2me_standalone_host.cc

Issue 1923573006: Implement a dummy host to do capturing and analysis only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review commnets Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/test/it2me_standalone_host.h ('k') | remoting/test/it2me_standalone_host_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/logging.h"
13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/time/time.h"
16 #include "remoting/base/auto_thread_task_runner.h"
17 #include "remoting/host/chromoting_host_context.h"
18 #include "remoting/host/host_extension.h"
19 #include "remoting/protocol/pairing_registry.h"
20 #include "remoting/protocol/protocol_mock_objects.h"
21 #include "remoting/protocol/session_config.h"
22
23 namespace remoting {
24 namespace test {
25
26 namespace {
27
28 void OutputFakeConnectionEventLogger(const FakeConnectionEventLogger* logger) {
29 DCHECK(logger);
30 std::cout << *logger;
31 }
32
33 constexpr char kSessionJid[] = "user@domain/rest-of-jid";
34
35 } // namespace
36
37 using ::remoting::protocol::MockSession;
38
39 It2MeStandaloneHost::It2MeStandaloneHost()
40 : context_(ChromotingHostContext::Create(
41 new AutoThreadTaskRunner(
42 message_loop_.task_runner(), run_loop_.QuitClosure()))),
43 main_task_runner_(context_->file_task_runner()),
44 factory_(main_task_runner_,
45 context_->video_capture_task_runner(),
46 context_->input_task_runner(),
47 context_->ui_task_runner()),
48 connection_(base::WrapUnique(new testing::NiceMock<MockSession>())),
49 session_jid_(kSessionJid),
50 #if defined(OS_LINUX)
51 // We cannot support audio capturing for linux, since a pipe name is
52 // needed to initialize AudioCapturerLinux.
53 config_(protocol::SessionConfig::ForTest()),
54 #else
55 config_(protocol::SessionConfig::ForTestWithAudio()),
56 #endif
57 event_logger_(&connection_) {
58 factory_.set_enable_user_interface(false);
59 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), jid())
60 .WillRepeatedly(testing::ReturnRef(session_jid_));
61 EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), config())
62 .WillRepeatedly(testing::ReturnRef(*config_));
63 connection_.set_audio_stub(event_logger_.audio_stub());
64 connection_.set_video_stub(event_logger_.video_stub());
65 connection_.set_client_stub(event_logger_.client_stub());
66 connection_.set_host_stub(event_logger_.host_stub());
67 connection_.set_video_encode_task_runner(
68 context_->video_encode_task_runner());
69 }
70
71 It2MeStandaloneHost::~It2MeStandaloneHost() {}
72
73 void It2MeStandaloneHost::Run() {
74 main_task_runner_->PostTask(
75 FROM_HERE,
76 base::Bind(&It2MeStandaloneHost::Connect, base::Unretained(this)));
77 run_loop_.Run();
78 }
79
80 void It2MeStandaloneHost::StartOutputTimer() {
81 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1),
82 base::Bind(&OutputFakeConnectionEventLogger, &event_logger_));
83 }
84
85 void It2MeStandaloneHost::Connect() {
86 session_.reset(new ClientSession(
87 &handler_,
88 context_->audio_task_runner(),
89 std::unique_ptr<protocol::ConnectionToClient>(&connection_),
90 &factory_,
91 base::TimeDelta(),
92 scoped_refptr<protocol::PairingRegistry>(),
93 std::vector<HostExtension*>()));
94 session_->OnConnectionAuthenticated(&connection_);
95 session_->OnConnectionChannelsConnected(&connection_);
96 session_->CreateVideoStreams(&connection_);
97 }
98
99 } // namespace test
100 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/it2me_standalone_host.h ('k') | remoting/test/it2me_standalone_host_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698