1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/host_status_logger.h"
#include "base/bind.h"
#include "remoting/base/constants.h"
#include "remoting/host/host_status_monitor.h"
#include "remoting/host/server_log_entry_host.h"
#include "remoting/protocol/transport.h"
#include "remoting/signaling/server_log_entry.h"
namespace remoting {
HostStatusLogger::HostStatusLogger(base::WeakPtr<HostStatusMonitor> monitor,
ServerLogEntry::Mode mode,
SignalStrategy* signal_strategy,
const std::string& directory_bot_jid)
: log_to_server_(mode, signal_strategy, directory_bot_jid),
monitor_(monitor) {
monitor_->AddStatusObserver(this);
}
HostStatusLogger::~HostStatusLogger() {
if (monitor_.get())
monitor_->RemoveStatusObserver(this);
}
void HostStatusLogger::LogSessionStateChange(const std::string& jid,
bool connected) {
DCHECK(CalledOnValidThread());
scoped_ptr<ServerLogEntry> entry(
MakeLogEntryForSessionStateChange(connected));
AddHostFieldsToLogEntry(entry.get());
entry->AddModeField(log_to_server_.mode());
if (connected) {
DCHECK_EQ(connection_route_type_.count(jid), 1u);
AddConnectionTypeToLogEntry(entry.get(), connection_route_type_[jid]);
}
log_to_server_.Log(*entry.get());
}
void HostStatusLogger::OnClientConnected(const std::string& jid) {
DCHECK(CalledOnValidThread());
LogSessionStateChange(jid, true);
}
void HostStatusLogger::OnClientDisconnected(const std::string& jid) {
DCHECK(CalledOnValidThread());
LogSessionStateChange(jid, false);
connection_route_type_.erase(jid);
}
void HostStatusLogger::OnClientRouteChange(
const std::string& jid,
const std::string& channel_name,
const protocol::TransportRoute& route) {
// Store connection type for the video channel. It is logged later
// when client authentication is finished.
if (channel_name == kVideoChannelName) {
connection_route_type_[jid] = route.type;
}
}
void HostStatusLogger::SetSignalingStateForTest(SignalStrategy::State state) {
log_to_server_.OnSignalStrategyStateChange(state);
}
} // namespace remoting
|