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
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_CORP_HOST_STATUS_LOGGER_H_
#define REMOTING_HOST_CORP_HOST_STATUS_LOGGER_H_
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "remoting/base/local_session_policies_provider.h"
#include "remoting/protocol/session.h"
#include "remoting/protocol/session_observer.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace net {
class ClientCertStore;
} // namespace net
namespace remoting {
namespace protocol {
class SessionManager;
} // namespace protocol
class LoggingServiceClient;
class OAuthTokenGetter;
// A class that reports host status changes to the corp logging service. This is
// not used for external users. For internal details, see go/crd-corp-logging.
class CorpHostStatusLogger final : public protocol::SessionObserver {
public:
static std::unique_ptr<CorpHostStatusLogger> CreateForRemoteAccess(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<net::ClientCertStore> client_cert_store,
const LocalSessionPoliciesProvider* local_session_policies_provider,
const std::string& service_account_email,
const std::string& refresh_token);
static std::unique_ptr<CorpHostStatusLogger> CreateForRemoteSupport(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<net::ClientCertStore> client_cert_store,
const LocalSessionPoliciesProvider* local_session_policies_provider,
base::WeakPtr<OAuthTokenGetter> oauth_token_getter);
CorpHostStatusLogger(
std::unique_ptr<LoggingServiceClient> service_client,
const LocalSessionPoliciesProvider* local_session_policies_provider);
~CorpHostStatusLogger() override;
CorpHostStatusLogger(const CorpHostStatusLogger&) = delete;
CorpHostStatusLogger& operator=(const CorpHostStatusLogger&) = delete;
void StartObserving(protocol::SessionManager& session_manager);
private:
// protocol::SessionObserver
void OnSessionStateChange(const protocol::Session& session,
protocol::Session::State state) override;
std::unique_ptr<LoggingServiceClient> service_client_;
raw_ptr<const LocalSessionPoliciesProvider> local_session_policies_provider_;
Subscription observer_subscription_;
};
} // namespace remoting
#endif // REMOTING_HOST_CORP_HOST_STATUS_LOGGER_H_
|