
This CL implements the CorpHostStatusLogger and hooks it up with the JingleSessionManager, so that it reports the disconnect event to the corp logging service with both the error code and the SessionAuthz reauth token attached. The tricky part of this CL is to pass the reauth token from the SessionAuthzReauthorizer to the CorpHostStatusLogger. There is `HostStatusObserver`, but it implements a mojo interface, meaning it will be rather difficult to pass pointers around (without being rejected by the mojo reviewer). Just passing the reauth token around in callbacks would also work, but that would be very messy. To get that working, this CL introduces a `SessionObserver`, which allows implementations to observer state changes on multiple sessions and know which session has changed. `authentication_type()` and `implementing_authenticator()` are added to `Authenticator` to allow `CorpHostStatusLogger` to extract the reauth token from the generalized `Authenticator` reference. Bug: b/328138087 Change-Id: Ic7b9ea297d28488ef65d4071860836b47e9c3b5d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5359454 Auto-Submit: Yuwei Huang <yuweih@chromium.org> Reviewed-by: Joe Downing <joedow@chromium.org> Commit-Queue: Yuwei Huang <yuweih@chromium.org> Cr-Commit-Position: refs/heads/main@{#1271835}
106 lines
3.1 KiB
C++
106 lines
3.1 KiB
C++
// Copyright 2012 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "remoting/protocol/protocol_mock_objects.h"
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
#include "base/check.h"
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "remoting/protocol/session_plugin.h"
|
|
#include "remoting/protocol/video_stream.h"
|
|
#include "remoting/signaling/signaling_address.h"
|
|
|
|
namespace remoting::protocol {
|
|
|
|
MockAuthenticator::MockAuthenticator() = default;
|
|
MockAuthenticator::~MockAuthenticator() = default;
|
|
|
|
MockConnectionToClientEventHandler::MockConnectionToClientEventHandler() =
|
|
default;
|
|
MockConnectionToClientEventHandler::~MockConnectionToClientEventHandler() =
|
|
default;
|
|
|
|
MockClipboardStub::MockClipboardStub() = default;
|
|
MockClipboardStub::~MockClipboardStub() = default;
|
|
|
|
MockInputStub::MockInputStub() = default;
|
|
MockInputStub::~MockInputStub() = default;
|
|
|
|
MockHostStub::MockHostStub() = default;
|
|
MockHostStub::~MockHostStub() = default;
|
|
|
|
MockClientStub::MockClientStub() = default;
|
|
MockClientStub::~MockClientStub() = default;
|
|
|
|
MockCursorShapeStub::MockCursorShapeStub() = default;
|
|
MockCursorShapeStub::~MockCursorShapeStub() = default;
|
|
|
|
MockVideoStub::MockVideoStub() = default;
|
|
MockVideoStub::~MockVideoStub() = default;
|
|
|
|
MockSession::MockSession() = default;
|
|
MockSession::~MockSession() = default;
|
|
|
|
MockSessionManager::MockSessionManager() = default;
|
|
MockSessionManager::~MockSessionManager() = default;
|
|
|
|
MockSessionObserver::MockSessionObserver() = default;
|
|
MockSessionObserver::~MockSessionObserver() = default;
|
|
|
|
MockPairingRegistryDelegate::MockPairingRegistryDelegate() = default;
|
|
MockPairingRegistryDelegate::~MockPairingRegistryDelegate() = default;
|
|
|
|
base::Value::List MockPairingRegistryDelegate::LoadAll() {
|
|
base::Value::List result;
|
|
for (Pairings::const_iterator i = pairings_.begin(); i != pairings_.end();
|
|
++i) {
|
|
result.Append(i->second.ToValue());
|
|
}
|
|
return result;
|
|
}
|
|
|
|
bool MockPairingRegistryDelegate::DeleteAll() {
|
|
pairings_.clear();
|
|
return true;
|
|
}
|
|
|
|
protocol::PairingRegistry::Pairing MockPairingRegistryDelegate::Load(
|
|
const std::string& client_id) {
|
|
Pairings::const_iterator i = pairings_.find(client_id);
|
|
if (i != pairings_.end()) {
|
|
return i->second;
|
|
} else {
|
|
return protocol::PairingRegistry::Pairing();
|
|
}
|
|
}
|
|
|
|
bool MockPairingRegistryDelegate::Save(
|
|
const protocol::PairingRegistry::Pairing& pairing) {
|
|
pairings_[pairing.client_id()] = pairing;
|
|
return true;
|
|
}
|
|
|
|
bool MockPairingRegistryDelegate::Delete(const std::string& client_id) {
|
|
pairings_.erase(client_id);
|
|
return true;
|
|
}
|
|
|
|
SynchronousPairingRegistry::SynchronousPairingRegistry(
|
|
std::unique_ptr<Delegate> delegate)
|
|
: PairingRegistry(base::SingleThreadTaskRunner::GetCurrentDefault(),
|
|
std::move(delegate)) {}
|
|
SynchronousPairingRegistry::~SynchronousPairingRegistry() = default;
|
|
|
|
void SynchronousPairingRegistry::PostTask(
|
|
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
|
|
const base::Location& from_here,
|
|
base::OnceClosure task) {
|
|
DCHECK(task_runner->BelongsToCurrentThread());
|
|
std::move(task).Run();
|
|
}
|
|
|
|
} // namespace remoting::protocol
|